:root {
  --tabbar-height: 72px;
  --bg-dark: #0f0f11;
  --bg-panel: rgba(25, 25, 30, 0.6);
  --text-main: #ffffff;
  --text-muted: #a0a0a5;
  --accent: #1db954;
  --accent-glow: rgba(29, 185, 84, 0.4);
  --player-height: 90px;
  --sidebar-width: 240px;
  --glass-border: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ไม่ให้มีบล็อกสีฟ้าตอนแตะ/กดค้างทั้งเว็บ
   1) -webkit-tap-highlight-color: กรอบสีที่เบราว์เซอร์มือถือวาดทับตอนแตะ (เดิมตั้งไว้แค่ปุ่ม/ลิงก์ ส่วน div ที่กดได้ เช่น แถวเพลง การ์ด ยังขึ้นบล็อกสี)
   2) user-select: บล็อกสีฟ้าจากการเลือกข้อความตอนกดค้าง/แตะสองครั้ง (ช่องกรอกยังเลือก/วางข้อความได้ตามปกติ)
   3) outline: ตัดวงโฟกัสตอนใช้นิ้ว/เมาส์ แต่ยังโชว์ตอนใช้คีย์บอร์ด (:focus-visible) */
* {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.tv-share-url,
.tv-share-code {
  -webkit-user-select: text;
  user-select: text;
}

img {
  -webkit-user-drag: none;
}

:focus:not(:focus-visible) {
  outline: none;
}

html {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Kanit', 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh;
}

.hidden {
  display: none !important;
}

.screen {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  position: absolute;
  top: 0;
  left: 0;
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

#login-screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
  background: radial-gradient(circle at center, #1a1a24 0%, var(--bg-dark) 100%);
}

.login-card {
  width: min(100%, 720px);
  box-sizing: border-box;
  margin: auto;
  padding: clamp(1.5rem, 5vw, 3rem);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff, #a0a0a5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.site-introduction {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: var(--text-muted);
  text-align: left;
  line-height: 1.7;
}

.site-introduction h2,
.site-introduction h3 {
  color: var(--text-main);
}

.site-introduction h2 { margin: 0 0 .75rem; font-size: 1.3rem; }
.site-introduction h3 { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.site-introduction p { margin: .5rem 0; font-size: .9rem; }
.site-introduction ul { margin: .5rem 0 1rem; padding-left: 1.25rem; font-size: .9rem; }

.btn-primary {
  background-color: var(--accent);
  color: #fff;
  border: none;
  padding: 1rem 2rem;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, background-color .2s;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
  background-color: #1ed760;
}

#app-screen {
  overflow: hidden; /* ambient-background ใหญ่กว่าจอ (เพื่อขยับเลื่อนไหล) ต้องถูกตัด ไม่งั้นมือถือจะย่อหน้าเว็บให้พอดีกับส่วนที่ล้น */
  isolation: isolate;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr var(--player-height);
  grid-template-areas: "sidebar main" "player player";
}

@property --amb1 { syntax: '<color>'; inherits: false; initial-value: rgba(29, 185, 84, 0.4); }
@property --amb2 { syntax: '<color>'; inherits: false; initial-value: rgba(29, 185, 84, 0); }
@property --amb3 { syntax: '<color>'; inherits: false; initial-value: rgba(29, 185, 84, 0); }
@property --amb4 { syntax: '<color>'; inherits: false; initial-value: rgba(29, 185, 84, 0); }
@property --amb5 { syntax: '<color>'; inherits: false; initial-value: rgba(29, 185, 84, 0); }

.ambient-background {
  position: absolute;
  top: -15%;
  left: -15%;
  width: 130%;
  height: 130%;
  background:
    radial-gradient(ellipse at 20% 12%, var(--amb1) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 20%, var(--amb2) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 88%, var(--amb3) 0%, transparent 55%),
    radial-gradient(ellipse at 15% 85%, var(--amb4) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, var(--amb5) 0%, transparent 60%);
  z-index: -1;
  transition: --amb1 1.4s ease, --amb2 1.4s ease, --amb3 1.4s ease, --amb4 1.4s ease, --amb5 1.4s ease;
  animation: ambient-drift 30s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes ambient-drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(3%, -2%) scale(1.06); }
  100% { transform: translate(-3%, 3%) scale(1.02); }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-background, .blob { animation: none !important; }
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border-right: 1px solid var(--glass-border);
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 2rem;
  letter-spacing: 1px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex: 1;
}

.nav-item {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.1rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  transition: all .2s;
  font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, .05);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-border);
}

.user-profile img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .2s;
}

.user-profile-btn:hover {
  background: rgba(255, 255, 255, .08);
}

.user-profile-btn .user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-btn .user-chevron {
  color: var(--text-muted);
  font-size: .8rem;
}

.avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.account-menu {
  position: fixed;
  z-index: 1500;
  min-width: 210px;
  background: rgba(30, 30, 35, .97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: .4rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

.account-menu-header {
  padding: .6rem .9rem;
  color: var(--text-muted);
  font-size: .85rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: .3rem;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: .7rem .9rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-main);
  font: inherit;
  font-size: .95rem;
  text-align: left;
  cursor: pointer;
  transition: background .2s;
}

.account-menu-item:hover {
  background: rgba(255, 255, 255, .1);
}

.account-menu-item.danger {
  color: #ff6b6b;
}

.main-content {
  grid-area: main;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2rem;
  position: relative;
}

.main-content::-webkit-scrollbar { display: none; }

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 1rem;
  border-radius: 100px;
  margin-bottom: 2rem;
  display: flex;
}

#search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1.1rem;
  outline: none;
  padding: .5rem 1rem;
}

#search-input::placeholder {
  color: var(--text-muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.search-section {
  margin-bottom: 2rem;
}

.playlists-grid,
.artists-grid,
.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.history-grid {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: .75rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, black 0, black calc(100% - 32px), transparent 100%);
  mask-image: linear-gradient(to right, black 0, black calc(100% - 32px), transparent 100%);
}

.history-grid .history-card {
  flex: 0 0 180px;
  width: 180px;
  max-width: 180px;
  min-width: 0;
  align-self: flex-start;
  scroll-snap-align: start;
  overflow: hidden;
}

.playlist-card,
.track-item {
  background: rgba(255, 255, 255, .02);
  border-radius: 16px;
  padding: 1rem;
  transition: all .3s ease;
  cursor: pointer;
}

.playlist-card:hover,
.track-item:hover {
  background: rgba(255, 255, 255, .08);
  transform: translateY(-5px);
}

.playlist-card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  margin-bottom: 1rem;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.playlist-title {
  font-weight: 600;
  margin-bottom: .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-owner {
  color: var(--text-muted);
  font-size: .9rem;
}

.tracks-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  transform: none;
}

.track-item:hover {
  transform: translateX(5px);
}

.track-item img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.track-item-info {
  flex: 1;
  overflow: hidden;
}

.track-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-item-artist {
  color: var(--text-muted);
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player {
  grid-area: player;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-top: 1px solid var(--glass-border);
  z-index: 20;
}

.track-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 30%;
  min-width: 0;
}

#player-art {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

.track-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.track-title {
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  color: var(--text-muted);
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
  justify-content: center;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: var(--text-main);
  transform: scale(1.1);
}

.btn-icon svg {
  width: 24px;
  height: 24px;
}

.btn-play {
  background: var(--text-main);
  color: var(--bg-dark);
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.btn-play:hover {
  transform: scale(1.05);
  color: var(--bg-dark);
  background: var(--accent);
}

.player-extra {
  width: 30%;
  display: flex;
  justify-content: flex-end;
}

.lyrics-btn {
  background: rgba(255, 255, 255, .1);
  padding: .5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-main);
}

.lyrics-btn:hover {
  background: rgba(255, 255, 255, .2);
}

.lyrics-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .5s ease;
}

.lyrics-modal.hidden {
  display: flex !important;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.modal-blobs {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .8;
  will-change: transform;
  transition: background-color 1.4s ease;
}

.blob-1 {
  width: 60vw;
  height: 60vw;
  top: -15%;
  left: -10%;
  background: var(--blob1, rgba(80, 80, 200, .6));
  animation: blob-move-1 14s ease-in-out infinite alternate;
}

.blob-2 {
  width: 55vw;
  height: 55vw;
  bottom: -20%;
  right: -10%;
  background: var(--blob2, rgba(200, 80, 80, .5));
  animation: blob-move-2 18s ease-in-out infinite alternate;
}

.blob-3 {
  width: 40vw;
  height: 40vw;
  top: 30%;
  left: 30%;
  background: var(--blob3, rgba(80, 160, 100, .35));
  animation: blob-move-3 22s ease-in-out infinite alternate;
}

.blob-4 {
  width: 45vw;
  height: 45vw;
  top: -12%;
  right: -8%;
  background: var(--blob4, rgba(200, 160, 60, .5));
  animation: blob-move-2 20s ease-in-out infinite alternate-reverse;
}

.blob-5 {
  width: 50vw;
  height: 50vw;
  bottom: -15%;
  left: -8%;
  background: var(--blob5, rgba(60, 180, 180, .5));
  animation: blob-move-1 24s ease-in-out infinite alternate-reverse;
}

@keyframes blob-move-1 {
  0% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(8%, 12%) scale(1.1)
  }

  66% {
    transform: translate(-5%, 20%) scale(.95)
  }

  100% {
    transform: translate(12%, 5%) scale(1.05)
  }
}

@keyframes blob-move-2 {
  0% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(-10%, -8%) scale(1.08)
  }

  66% {
    transform: translate(6%, -15%) scale(1.12)
  }

  100% {
    transform: translate(-5%, 10%) scale(.95)
  }
}

@keyframes blob-move-3 {
  0% {
    transform: translate(0, 0) scale(1)
  }

  50% {
    transform: translate(-15%, 10%) scale(1.2)
  }

  100% {
    transform: translate(10%, -12%) scale(.9)
  }
}

.lyrics-modal>*:not(.modal-blobs) {
  position: relative;
  z-index: 1;
}

.lyrics-modal .lyrics-modal-btns {
  position: absolute;
  top: 2rem;
  right: 2.5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  z-index: 60;
}

.btn-modal-icon {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  backdrop-filter: blur(8px);
}

.btn-modal-icon:hover {
  background: rgba(255, 255, 255, .18);
  color: var(--text-main);
  transform: scale(1.1);
}

.btn-modal-icon svg {
  width: 22px;
  height: 22px;
}

.lyrics-layout {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  padding: 4rem;
  gap: 4rem;
  align-items: center;
}

.lyrics-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  max-width: 500px;
  margin-left: auto;
}

.lyrics-left img {
  width: min(100%, 45vh);
  aspect-ratio: 1;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  margin-bottom: 3rem;
  object-fit: cover;
}

.lyrics-track-details {
  margin-bottom: 2rem;
  width: 100%;
}

.lyrics-track-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: .5rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
}

.lyrics-track-title .marquee-inner {
  display: inline-block;
  white-space: nowrap;
}

.lyrics-track-title.is-overflow .marquee-inner {
  animation: marquee-scroll 30s linear infinite;
  padding-right: 3rem;
}

@keyframes marquee-scroll {
  0% {
    transform: translateX(0)
  }

  100% {
    transform: translateX(-50%)
  }
}

.lyrics-track-artist {
  font-size: 1.4rem;
  color: rgba(255, 255, 255, .72);
}

.lyrics-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  width: 100%;
}

/* ปุ่มในหน้าเนื้อเพลง: ขาวชัดบนพื้นหลังสีอะไรก็ได้ และขนาดสมดุลกับปุ่มเล่น/หยุด */
.lyrics-controls .btn-icon {
  color: rgba(255, 255, 255, .9);
}

.lyrics-controls .btn-icon:hover {
  color: #fff;
}

.lyrics-controls .btn-icon svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .25));
}

.lyrics-controls .btn-play {
  width: 64px;
  height: 64px;
  color: #111;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .3);
}

.lyrics-controls .btn-play:hover {
  background: #fff;
  color: #111;
  transform: scale(1.06);
}

.lyrics-controls .btn-play svg {
  width: 30px;
  height: 30px;
  filter: none;
}

.lyrics-right {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  height: 90%;
  margin-right: auto;
  -webkit-mask-image: none;
  mask-image: none;
}

.lyrics-container {
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 1;
  display: flex;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
}

.lyrics-modal.karaoke-mode .lyrics-container {
  min-height: 0;
  height: auto;
  flex: 1;
  -webkit-mask-image: none;
  mask-image: none;
}
.btn-modal-icon#btn-karaoke-mode svg { width: 23px; height: 23px; }
.btn-modal-icon#btn-karaoke-mode[aria-pressed="true"] { color: #fff; background: rgba(29, 185, 84, .75); }

.lyrics-writer-credit {
  flex: 0 0 auto;
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, .16);
  padding: .75rem 1rem .25rem;
  color: rgba(255, 255, 255, .9);
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
}

am-lyrics {
  width: 100%;
  height: 100%;
  max-width: 800px;
  --am-lyrics-color-active: var(--text-main);
  --am-lyrics-color-inactive: rgba(255, 255, 255, .4);
  --am-lyrics-compact-font-size: 42px;
  --am-lyrics-compact-line-spacing: 36px;
  text-align: left;
  pointer-events: none;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .4);
}

.context-menu {
  position: absolute;
  background: rgba(30, 30, 35, .95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: .5rem 0;
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

.context-menu.hidden {
  display: none;
}

.menu-item {
  padding: .75rem 1.5rem;
  cursor: pointer;
  transition: background .2s;
  color: var(--text-main);
  font-size: .95rem;
}

.menu-item:hover {
  background: rgba(255, 255, 255, .1);
}

.playlist-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playlist-modal.hidden {
  display: none;
}

.playlist-modal-content {
  width: 400px;
  max-width: 90%;
  padding: 2rem;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.playlist-list {
  flex: 1;
  overflow-y: auto;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.playlist-list-item {
  padding: .75rem;
  background: rgba(255, 255, 255, .05);
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s;
}

.playlist-list-item:hover {
  background: rgba(255, 255, 255, .1);
}

.btn-close-playlist {
  background: rgba(255, 255, 255, .1);
  color: var(--text-main);
  border: none;
  padding: .75rem;
  border-radius: 12px;
  cursor: pointer;
}

.btn-close-playlist:hover {
  background: rgba(255, 255, 255, .2);
}

.toast-container {
  position: fixed;
  bottom: 100px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: .95rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
  opacity: 0;
  transform: translateY(20px);
  transition: all .3s ease;
}

.toast-error {
  border-left: 4px solid #e74c3c;
}

.toast-info {
  border-left: 4px solid var(--accent);
}

/* ============ Seek bar (แถบเลือกจุดเพลง) ============ */
.player-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}

.player-center .player-controls {
  flex: none;
}

.seek-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
}

.seek-row-mini {
  max-width: 520px;
}

.seek-time {
  font-size: .75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 2.6rem;
  user-select: none;
}

.seek-remaining {
  text-align: right;
}

.seek-bar {
  --track-h: 6px;
  --thumb: 12px;
  --pct: 0%;
  --seek-fill: #fff;
  --seek-track: rgba(255, 255, 255, .25);
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
}

.seek-bar:disabled {
  cursor: default;
  opacity: .6;
}

.seek-bar::-webkit-slider-runnable-track {
  height: var(--track-h);
  border-radius: 999px;
  background: linear-gradient(to right, var(--seek-fill) var(--pct), var(--seek-track) var(--pct));
}

.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((var(--track-h) - var(--thumb)) / 2);
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity .15s;
}

.seek-bar::-moz-range-track {
  height: var(--track-h);
  border-radius: 999px;
  background: var(--seek-track);
}

.seek-bar::-moz-range-progress {
  height: var(--track-h);
  border-radius: 999px;
  background: var(--seek-fill);
}

.seek-bar::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: none;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity .15s;
}

.seek-bar:hover:not(:disabled)::-webkit-slider-thumb,
.seek-bar:active::-webkit-slider-thumb,
.seek-bar:focus-visible::-webkit-slider-thumb {
  opacity: 1;
}

.seek-bar:hover:not(:disabled)::-moz-range-thumb,
.seek-bar:active::-moz-range-thumb,
.seek-bar:focus-visible::-moz-range-thumb {
  opacity: 1;
}

.player .seek-bar:hover:not(:disabled) {
  --seek-fill: var(--accent);
}

/* แถบในหน้าเนื้อเพลง: แถบอยู่บน เวลาอยู่ใต้ปลายซ้าย/ขวา (สไตล์ Apple Music) */
.seek-row-lyrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  row-gap: .1rem;
  margin-bottom: 1.5rem;
}

.seek-row-lyrics .seek-bar {
  --track-h: 8px;
  --thumb: 16px;
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
}

.seek-row-lyrics .seek-current {
  grid-column: 1;
  grid-row: 2;
}

.seek-row-lyrics .seek-remaining {
  grid-column: 2;
  grid-row: 2;
}

.seek-row-lyrics .seek-time {
  font-size: .85rem;
  color: rgba(255, 255, 255, .55);
}

/* ============================================================
   Mobile Drawer Sidebar (Apple Music style)
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity .3s ease;
}
.drawer-overlay.hidden { display: none; }

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 78vw;
  max-width: 320px;
  height: 100%;
  z-index: 300;
  display: flex;
  flex-direction: column;
  padding: 0;
  transform: translateX(-100%);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  background: rgba(20, 20, 26, .97);
  border-right: 1px solid var(--glass-border);
}
.mobile-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  padding: 1.8rem 1.5rem 1rem;
  border-bottom: 1px solid var(--glass-border);
}
.drawer-header .logo {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0;
  letter-spacing: 1px;
}
.drawer-nav {
  display: flex;
  flex-direction: column;
  padding: .6rem .7rem;
  gap: .2rem;
  flex: 1;
}
.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 500;
  transition: background .2s;
}
.drawer-nav-item .nav-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--text-muted); }
.drawer-nav-item.active { background: var(--accent); color: #fff; }
.drawer-nav-item.active .nav-icon { color: #fff; }
.drawer-nav-item:not(.active):hover { background: rgba(255,255,255,.08); }
.drawer-user {
  padding: 1rem 1.2rem 1.5rem;
  border-top: 1px solid var(--glass-border);
}

/* ============================================================
   Mobile Top Navigation Bar (Apple Music style)
   ============================================================ */
.mobile-top-nav {
  display: none;
}

/* ============================================================
   Bottom tab bar (Apple Music style) — ซ่อนไว้บนจอกว้าง
   ============================================================ */
.bottom-tabbar {
  display: none;
}

@media (max-width:768px) {
  #app-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr var(--player-height) var(--tabbar-height);
    grid-template-areas: "main" "player" "sidebar";
  }

  /* ซ่อน sidebar เดิม ใช้ top nav + bottom tabbar แทน */
  .sidebar {
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,.08);
    height: var(--tabbar-height);
    background: rgba(18, 18, 22, .95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 30;
  }

  .sidebar .logo {
    display: none;
  }

  /* มือถือ: ซ่อน user profile ในแถบล่าง (ย้ายไปแสดงใน drawer) */
  .sidebar .user-profile {
    display: none;
  }

  .sidebar nav {
    flex: 1;
    min-width: 0;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
  }

  .account-menu {
    min-width: 200px;
  }

  .nav-item {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: .15rem;
    font-size: .65rem;
    line-height: 1.2;
    padding: .4rem .2rem .3rem;
    flex: 1;
    min-width: 0;
    text-align: center;
    color: var(--text-muted);
    border-radius: 0;
    font-weight: 500;
  }

  .nav-item .nav-icon { width: 24px; height: 24px; opacity: .75; }
  .nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .nav-item.active {
    background: transparent;
    color: var(--accent);
    font-weight: 700;
  }
  .nav-item.active .nav-icon { opacity: 1; color: var(--accent); }

  .main-content {
    padding: 0 1rem 1rem;
    padding-top: 0;
  }

  .playlists-grid,
  .artists-grid,
  .albums-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
  }

  .history-grid {
    gap: 1rem;
  }

  .history-grid .history-card {
    flex-basis: 130px;
  }

  .login-card {
    padding: 2rem;
    width: 90%;
  }

  .player {
    padding: 0 1rem;
    gap: .5rem;
  }

  .track-info {
    width: auto;
    flex: 1;
    overflow: hidden;
  }

  .track-title,
  .track-artist {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-controls {
    width: auto;
    flex: none;
    gap: .5rem;
  }

  .player-extra {
    width: auto;
    flex: none;
  }

  .btn-icon svg {
    width: 20px;
    height: 20px;
  }

  .btn-play {
    width: 36px;
    height: 36px;
  }

  .lyrics-btn {
    padding: .4rem .8rem;
    font-size: .8rem;
  }

  /* ===== หน้าเนื้อเพลงบนมือถือ (สไตล์ Apple Music) =====
     บน: ปกเล็ก + ชื่อเพลง/ศิลปิน | กลาง: เนื้อเพลงชิดซ้าย | ล่าง: แถบเวลา + ปุ่มควบคุมใหญ่ */
  .lyrics-modal {
    height: 100dvh;
  }

  .lyrics-modal .lyrics-modal-btns {
    top: calc(env(safe-area-inset-top, 0px) + 1.4rem);
    right: 1.25rem;
    gap: .4rem;
  }

  .lyrics-modal.mobile-controls-idle .lyrics-modal-btns > :not(#btn-car-mode-exit),
  .lyrics-modal.mobile-controls-idle .seek-row-lyrics,
  .lyrics-modal.mobile-controls-idle .lyrics-controls {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .55s ease, visibility 0s linear .55s;
  }

  .lyrics-modal .lyrics-modal-btns > :not(#btn-car-mode-exit),
  .lyrics-modal .seek-row-lyrics,
  .lyrics-modal .lyrics-controls {
    transition: opacity .2s ease, visibility 0s;
  }

  .btn-modal-icon {
    width: 40px;
    height: 40px;
  }

  .lyrics-layout {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "art details"
      "lyrics lyrics"
      "seek seek"
      "controls controls";
    column-gap: 1rem;
    row-gap: 0;
    align-items: center;
    justify-content: stretch;
    height: 100%;
    padding: calc(env(safe-area-inset-top, 0px) + 1.25rem) 1.5rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
    overflow: hidden;
  }

  .lyrics-left {
    display: contents;
  }

  .lyrics-left img {
    grid-area: art;
    width: 84px;
    height: 84px;
    max-width: none;
    margin: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  }

  .lyrics-track-details {
    grid-area: details;
    min-width: 0;
    margin: 0;
    padding-right: 5.6rem;
    text-align: left;
  }

  .lyrics-track-title {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: .1rem;
  }

  .lyrics-track-artist {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lyrics-right {
    grid-area: lyrics;
    align-self: stretch;
    position: relative;
    flex: none;
    height: auto;
    min-height: 0;
    width: 100%;
    margin: 1.25rem 0 .75rem;
  }

  .lyrics-container {
    position: relative;
    inset: auto;
    height: auto;
    min-height: 0;
    flex: 1;
  }

  am-lyrics {
    text-align: left;
    max-width: none;
    --am-lyrics-compact-font-size: 32px;
    --am-lyrics-compact-line-spacing: 26px;
    --am-lyrics-compact-selected-position: 8%;
    --am-lyrics-color-inactive: rgba(255, 255, 255, .35);
  }

  .seek-row-lyrics {
    grid-area: seek;
    margin-bottom: 1.25rem;
  }

  .lyrics-controls {
    grid-area: controls;
    justify-content: space-around;
    padding: 0 1rem;
  }

  .lyrics-controls .btn-icon {
    color: #fff;
  }

  .lyrics-controls .btn-icon svg {
    width: 48px;
    height: 48px;
  }
  /* ไม่มีเนื้อเพลง (มือถือ): แทนที่จะเป็นปกเพลงเล็กๆ ข้างชื่อเพลงแบบมีแผงเนื้อเพลง ให้ขยายปกเพลงเป็นรูปใหญ่ตรงกลาง
     เหมือนหน้าเล่นเพลงปกติของแอปเพลงทั่วไปตอนเพลงนั้นไม่มีเนื้อเพลง */
  .lyrics-layout.no-lyrics {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "art"
      "details"
      "seek"
      "controls";
  }
  .lyrics-layout.no-lyrics .lyrics-left img {
    width: min(100%, 60vh);
    height: auto;
    justify-self: center;
    align-self: center;
  }
  .lyrics-layout.no-lyrics .lyrics-track-details {
    padding-right: 0;
  }

  .lyrics-controls .btn-play,
  .lyrics-controls .btn-play:hover {
    width: 72px;
    height: 72px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #fff;
  }

  .lyrics-controls .btn-play svg {
    width: 64px;
    height: 64px;
  }

  /* Player ย่อด้านล่างบนมือถือ: แถบเวลาบางๆ ติดขอบบน */
  .player {
    position: relative;
  }

  .player-center {
    flex: none;
    width: auto;
  }

  .seek-row-mini {
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    gap: 0;
  }

  .seek-row-mini .seek-time {
    display: none;
  }

  .seek-row-mini .seek-bar {
    --track-h: 3px;
    --thumb: 12px;
    height: 20px;
  }

  .seek-row-mini .seek-bar::-webkit-slider-runnable-track {
    border-radius: 0;
  }

  .playlist-modal-content {
    width: 90%;
    padding: 1.5rem;
  }
}

/* ============================================================
   RANKING — จัดอันดับเพลง
   ============================================================ */
.rank-header { margin-bottom: 1.25rem; }
.rank-sub { color: var(--text-muted); font-size: .95rem; line-height: 1.5; margin-top: .25rem; }

.rank-search {
  border-radius: 100px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
}
#ranking-search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1.05rem;
  outline: none;
  padding: .25rem 1rem;
}
#ranking-search-input::placeholder { color: var(--text-muted); }

.rank-search-results { margin-bottom: 1.5rem; }
.rank-search-results:empty { display: none; }

.rank-add-btn,
.rank-vote-btn,
.rank-refresh {
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
  transition: transform .2s, background-color .2s, opacity .2s;
}
.rank-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: .5rem 1rem;
  font-size: .85rem;
}
.rank-add-btn:hover { background: #1ed760; transform: translateY(-1px); }

.rank-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 .75rem;
}
.rank-list-head h3 { margin: 0; }
.rank-refresh {
  background: rgba(255, 255, 255, .08);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  padding: .4rem 1rem;
  font-size: .85rem;
}
.rank-refresh:hover { background: rgba(255, 255, 255, .16); }

.rank-list { display: flex; flex-direction: column; gap: .5rem; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background .25s, transform .25s;
}
.rank-item:hover { background: rgba(255, 255, 255, .08); transform: translateX(4px); }

.rank-num {
  width: 2.2rem;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}
.rank-item.top-1 { background: linear-gradient(90deg, rgba(255, 200, 60, .16), rgba(255, 255, 255, .03)); border-color: rgba(255, 200, 60, .35); }
.rank-item.top-2 { background: linear-gradient(90deg, rgba(200, 210, 225, .13), rgba(255, 255, 255, .03)); border-color: rgba(200, 210, 225, .3); }
.rank-item.top-3 { background: linear-gradient(90deg, rgba(210, 130, 70, .15), rgba(255, 255, 255, .03)); border-color: rgba(210, 130, 70, .3); }
.rank-item.top-1 .rank-num { color: #ffc83c; font-size: 1.7rem; }
.rank-item.top-2 .rank-num { color: #d0d8e6; }
.rank-item.top-3 .rank-num { color: #d98a4e; }

.rank-cover {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.rank-cover.is-broken { visibility: hidden; }

.rank-info { flex: 1; min-width: 0; }
.rank-title, .rank-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-title { font-weight: 600; }
.rank-artist { color: var(--text-muted); font-size: .9rem; }

.rank-duration { color: var(--text-muted); font-size: .9rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.rank-votes { display: flex; flex-direction: column; align-items: center; min-width: 3.2rem; flex-shrink: 0; line-height: 1.1; }
.rank-votes strong { font-family: 'Outfit', sans-serif; font-size: 1.3rem; color: var(--accent); }
.rank-votes span { font-size: .7rem; color: var(--text-muted); }

.rank-vote-btn {
  background: rgba(29, 185, 84, .15);
  color: var(--accent);
  border: 1px solid rgba(29, 185, 84, .4);
  padding: .45rem .9rem;
  font-size: .85rem;
  flex-shrink: 0;
}
.rank-vote-btn:hover:not(:disabled) { background: var(--accent); color: #fff; }
.rank-vote-btn:disabled { opacity: .55; cursor: default; }
.is-busy .rank-vote-btn,
.is-busy .rank-add-btn { pointer-events: none; opacity: .6; }

.rank-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--glass-border);
  border-radius: 14px;
  line-height: 1.6;
}

/* Modal ส่งเพลงเข้าอันดับ */
.rk-modal { gap: .75rem; overflow-y: auto; }
.rk-preview { display: flex; align-items: center; gap: 1rem; margin: .5rem 0; }
.rk-preview img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.rk-preview-info { min-width: 0; }
.rk-title { font-weight: 700; font-size: 1.1rem; }
.rk-artist { color: var(--text-muted); margin-top: .15rem; }
.rk-duration { color: var(--accent); font-size: .9rem; margin-top: .4rem; }
.rk-file {
  display: block;
  padding: .75rem 1rem;
  border: 1px dashed var(--glass-border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
  text-align: center;
  transition: background .2s, color .2s;
}
.rk-file:hover { background: rgba(255, 255, 255, .06); color: var(--text-main); }
.rk-file input { display: none; }
.rk-hint { color: var(--text-muted); font-size: .8rem; line-height: 1.4; }
.rk-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.rk-actions { display: flex; gap: .75rem; margin-top: .5rem; }
.rk-actions .btn-close-playlist { flex: 1; font-family: inherit; }
.rk-actions .btn-primary { flex: 2; padding: .75rem 1.25rem; font-size: 1rem; }
.rk-actions .btn-primary:disabled { opacity: .6; cursor: default; transform: none; }

@media (max-width:768px) {
  .rank-item { gap: .6rem; padding: .6rem .7rem; }
  .rank-num { width: 1.6rem; font-size: 1.15rem; }
  .rank-item.top-1 .rank-num { font-size: 1.3rem; }
  .rank-cover { width: 44px; height: 44px; }
  .rank-duration { display: none; }
  .rank-vote-btn { padding: .4rem .65rem; font-size: .78rem; }
  .rank-add-btn { padding: .45rem .75rem; font-size: .78rem; }
  .rank-search-results .rank-duration { display: none; }
}

/* สัญลักษณ์ E (Explicit) */
.rank-explicit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  margin-right: .4rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, .55);
  color: #111;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ============================================================
   RANKING — เลือกหัวข้อ (topics)
   ============================================================ */
.rank-topics { margin-bottom: 1.25rem; }
.rank-topic-chips {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .35rem;
  scrollbar-width: thin;
}
.rank-topic-chip {
  flex-shrink: 0;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-main);
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: .45rem 1rem;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.rank-topic-chip:hover { background: rgba(255, 255, 255, .16); transform: translateY(-1px); }
.rank-topic-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rank-topic-chip.closed:not(.active) { color: var(--text-muted); }
.rank-topic-info { display: flex; align-items: center; gap: .9rem; margin-top: .6rem; }
.rank-topic-info.hidden { display: none; }
.rank-topic-cover { width: 200px; height: 200px; border-radius: 16px; object-fit: cover; flex-shrink: 0; background: rgba(255, 255, 255, .08); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.rank-topic-info { gap: 1.5rem; }
.rank-topic-desc { font-size: 1.05rem; }
@media (max-width: 768px) {
  .rank-topic-cover { width: 120px; height: 120px; border-radius: 12px; }
  .rank-topic-info { gap: 1rem; }
}
.rank-topic-desc { color: var(--text-muted); font-size: .92rem; line-height: 1.5; }
.rank-topic-desc.hidden { display: none; }

/* ============================================================
   RANKING — แสดงเป็นการ์ดปก (grid) เหมือนอัลบัม
   ============================================================ */
.rank-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  align-items: start;
}
.rank-list > .rank-empty { grid-column: 1 / -1; }
.rank-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid transparent; }
.rank-card-cover { position: relative; }
.rank-card-cover img.is-broken { visibility: hidden; }
.rank-badge {
  position: absolute;
  top: .55rem;
  left: .55rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0 .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 15, 17, .78);
  backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
}
.rank-card.top-1 { border-color: rgba(255, 200, 60, .45); background: linear-gradient(180deg, rgba(255, 200, 60, .12), rgba(255, 255, 255, .02)); }
.rank-card.top-2 { border-color: rgba(200, 210, 225, .35); background: linear-gradient(180deg, rgba(200, 210, 225, .10), rgba(255, 255, 255, .02)); }
.rank-card.top-3 { border-color: rgba(210, 130, 70, .35); background: linear-gradient(180deg, rgba(210, 130, 70, .12), rgba(255, 255, 255, .02)); }
.rank-card.top-1 .rank-badge { background: #ffc83c; color: #1a1a1a; }
.rank-card.top-2 .rank-badge { background: #d0d8e6; color: #1a1a1a; }
.rank-card.top-3 .rank-badge { background: #d98a4e; color: #1a1a1a; }
.rank-card-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-card-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .6rem 0; color: var(--text-muted); font-size: .85rem; }
.rank-card-meta .rank-votes { display: flex; align-items: baseline; gap: .3rem; }
.rank-card-meta .rank-votes strong { color: var(--accent); font-size: 1.15rem; }
.rank-card .rank-vote-btn { width: 100%; margin-top: auto; }
@media (max-width: 768px) {
  .rank-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
}

/* ============================================================
   สีพื้นหลัง: วิ่งเร็วขึ้น + เห็นชัดบนมือถือ
   ============================================================ */
.ambient-background { animation: ambient-drift 9s ease-in-out infinite alternate; }
@keyframes ambient-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(6%, -4%) scale(1.12); }
  100% { transform: translate(-6%, 6%) scale(1.04); }
}
.blob-1 { animation-duration: 6s; }
.blob-2 { animation-duration: 8s; }
.blob-3 { animation-duration: 9s; }
.blob-4 { animation-duration: 7s; }
.blob-5 { animation-duration: 10s; }

@media (max-width: 768px) {
  /* บนมือถือ blob ขนาดแบบ vw เล็กเกินไปเมื่อเทียบกับจอแนวตั้ง จึงใช้ vmax และไล่สีแทนการเบลอหนัก ๆ (สีเข้มกว่าและลื่นกว่า) */
  .blob { filter: none; opacity: 1; }
  .blob-1 { width: 90vmax; height: 90vmax; background: radial-gradient(circle, var(--blob1, rgba(80, 80, 200, .8)) 0%, transparent 68%); }
  .blob-2 { width: 85vmax; height: 85vmax; background: radial-gradient(circle, var(--blob2, rgba(200, 80, 80, .7)) 0%, transparent 68%); }
  .blob-3 { width: 65vmax; height: 65vmax; background: radial-gradient(circle, var(--blob3, rgba(80, 160, 100, .6)) 0%, transparent 68%); }
  .blob-4 { width: 75vmax; height: 75vmax; background: radial-gradient(circle, var(--blob4, rgba(200, 160, 60, .7)) 0%, transparent 68%); }
  .blob-5 { width: 80vmax; height: 80vmax; background: radial-gradient(circle, var(--blob5, rgba(60, 180, 180, .7)) 0%, transparent 68%); }

  /* เว้นพื้นที่ให้รอยบาก/Dynamic Island และแถบ Home ของ iPhone (ใช้คู่กับ viewport-fit=cover ใน index.html) */
  #app-screen {
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    grid-template-rows: 1fr var(--player-height) calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
  }
  .sidebar { height: auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ============================================================
   เนื้อเพลง: ให้บรรทัดที่กำลังร้องอยู่ในโซนที่มองเห็น (ไม่ถูกมาสก์จางที่ขอบบน)
   ============================================================ */
.lyrics-right {
  -webkit-mask-image: none;
  mask-image: none;
}
.lyrics-container {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 100%);
}
@media (max-width: 768px) {
  am-lyrics { --am-lyrics-compact-selected-position: 26%; }
}

/* ============================================================
   แชร์ไปหน้าจอ TV (Beta)
   ============================================================ */
.tv-beta { display: inline-block; vertical-align: middle; margin-left: .4rem; padding: .05rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .15); font-size: .7rem; font-weight: 600; letter-spacing: .04em; }
.btn-modal-icon.tv-text { font-size: .85rem; font-weight: 700; color: var(--text-main); }
.lyrics-btn.tv-active, .btn-modal-icon.tv-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tv-share-modal { width: 460px; gap: .75rem; }
.tv-share-hint { color: var(--text-muted); font-size: .9rem; line-height: 1.5; }
.tv-share-code { text-align: center; font-size: 2.6rem; font-weight: 700; letter-spacing: .25em; padding: .4rem 0; font-variant-numeric: tabular-nums; }
.tv-share-url { text-align: center; font-size: .8rem; color: var(--text-muted); word-break: break-all; }
.tv-share-status { text-align: center; min-height: 1.2rem; font-size: .85rem; color: var(--accent); }

/* เว้นระยะระหว่างปุ่ม TV กับ Lyrics ที่แถบเล่นเพลง */
.player-extra { gap: .5rem; align-items: center; }

/* ============================================================
   เลือกอุปกรณ์เล่นเสียง (Spotify Connect) + ปุ่ม TV บนมือถือ
   ============================================================ */
.tv-share-modal { max-height: 88vh; overflow-y: auto; }
.tv-section-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-weight: 600; margin-top: .5rem; }
.tv-devices { display: flex; flex-direction: column; gap: .5rem; max-height: 220px; overflow-y: auto; }
.tv-device { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; padding: .7rem .9rem; border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .06); color: var(--text-main); font: inherit; cursor: pointer; transition: background .2s; }
.tv-device:hover { background: rgba(255, 255, 255, .12); }
.tv-device.active { border-color: var(--accent); background: rgba(29, 185, 84, .14); }
.tv-device-icon { font-size: 1.6rem; flex-shrink: 0; }
.tv-device-info { display: flex; flex-direction: column; min-width: 0; }
.tv-device-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-device-type { font-size: .8rem; color: var(--text-muted); }
.tv-device.active .tv-device-type { color: var(--accent); }
.tv-share-code.hidden { display: none; }

@media (max-width: 768px) {
  /* ให้ปุ่ม TV / Lyrics ที่แถบเล่นเพลงไม่ถูกบีบหรือตกขอบบนจอแคบ */
  .player-extra { flex: 0 0 auto; gap: .3rem; }
  .player-extra .lyrics-btn { padding: .4rem .65rem; min-width: 2.6rem; display: inline-flex; align-items: center; justify-content: center; }
  .track-info { min-width: 0; }
}

/* คำขอเปิดเสียงบนทีวี (หน้าต่างแชร์ TV) */
.tv-audio-request { display: flex; flex-direction: column; gap: .6rem; padding: .9rem 1rem; border-radius: 14px; border: 1px solid var(--accent); background: rgba(29, 185, 84, .12); font-size: .9rem; line-height: 1.5; }
.tv-audio-request.hidden { display: none; }
.tv-audio-title { font-weight: 600; }
.tv-audio-sas { font-size: 1.6rem; letter-spacing: .2em; color: var(--accent); }

/* มือถือ: ไม่แสดงปุ่ม TV (ทั้งที่แถบเล่นเพลงและในหน้าเนื้อเพลง) */
@media (max-width: 768px) {
  #btn-tv-share, #btn-tv-share-lyrics { display: none !important; }
}

/* แก้หน้าต่างแชร์ TV: รายการอุปกรณ์ถูกบีบจนเหลือแถบบาง ๆ (ลูกของ flex ที่มี overflow ย่อได้ถึง 0) */
.tv-share-modal { display: flex; flex-direction: column; }
.tv-share-modal > * { flex-shrink: 0; }
.tv-devices { min-height: 64px; }
.tv-share-status:empty { display: none; }

/* ============================================================
   ปรับ UI ให้ใกล้เคียง Apple Music: แถบข้างมีไอคอน, เพลเยอร์ลอยเป็นแคปซูล
   ============================================================ */
:root { --sidebar-width: 260px; }

.logo { display: flex; align-items: center; gap: .6rem; }
.logo-icon { width: 26px; height: 26px; flex-shrink: 0; color: var(--accent); }
.sidebar-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: .4rem 0 .5rem .9rem; }
.nav-item { display: flex; align-items: center; gap: .85rem; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .85; }
.nav-item.active { font-weight: 700; }
.nav-item.active .nav-icon { color: var(--accent); opacity: 1; }

/* เพลเยอร์แบบแคปซูลลอยกลางล่างจอ เหมือน Apple Music บนเว็บ/เดสก์ท็อป */
/* เฉพาะจอกว้าง (คอม) เท่านั้น ไม่งั้นจะไปทับกฎของมือถือที่อยู่ก่อนหน้านี้ในไฟล์ (เพราะ CSS ใช้อันที่มาทีหลังเมื่อความเฉพาะเจาะจงเท่ากัน) */
@media (min-width: 769px) {
  #app-screen { grid-template-rows: 1fr 0; grid-template-areas: "sidebar main" "sidebar main"; }
}
.player {
  position: fixed;
  left: calc(var(--sidebar-width) + (100% - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  bottom: 1.1rem;
  width: min(880px, calc(100% - var(--sidebar-width) - 3rem));
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0 1.4rem;
  height: 64px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  z-index: 50;
}
.main-content { padding-bottom: calc(64px + 2.5rem); }

@media (max-width: 768px) {
  /* มือถือใช้แถบนำทางด้านบน; ซ่อน sidebar ด้านล่างและยุบแถวที่ไม่มีเนื้อหา */
  .player { position: static; transform: none; width: 100%; border-radius: 0; box-shadow: none; height: var(--player-height); }
  #app-screen {
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "main" "player";
  }
  #app-screen > .sidebar { display: none; }
  .player:not(.hidden) {
    height: calc(var(--player-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .main-content { padding-bottom: 2rem; }
  .sidebar-label { display: none; }
}

/* ============================================================
   หน้าหลัก: แบนเนอร์ใหญ่ 2 ใบด้านบน (คล้าย Apple Music) + เพลย์ลิสต์ของฉัน
   ============================================================ */
.hero-banner { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 2rem; }
.hero-banner.hidden { display: none; }
.hero-card {
  position: relative;
  height: 260px;
  border-radius: 20px;
  background-size: cover;
  background-position: center;
  background-color: rgba(255, 255, 255, .06);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
}
.hero-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, .78) 100%); }
.hero-tag { position: absolute; top: 1rem; left: 1rem; z-index: 2; padding: .25rem .75rem; border-radius: 999px; background: rgba(0, 0, 0, .5); backdrop-filter: blur(6px); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.hero-info { position: absolute; left: 1.25rem; right: 4.5rem; bottom: 1.1rem; z-index: 2; }
.hero-title { font-size: 1.4rem; font-weight: 800; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hero-sub { margin-top: .3rem; color: rgba(255, 255, 255, .75); font-size: .9rem; }
.hero-play { position: absolute; right: 1.1rem; bottom: 1.1rem; z-index: 3; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); }
.hero-play svg { width: 22px; height: 22px; }
.hero-play:hover { transform: scale(1.06); }

.nav-secondary { margin-top: .25rem; gap: .5rem; display: flex; flex-direction: column; }
.empty-hint { color: var(--text-muted); padding: 1rem 0; }
.search-api-status:not(:empty) { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }

@media (max-width: 768px) {
  /* มือถือ: แบนเนอร์ใหญ่ 2 ใบ เลื่อนแนวนอนแทนการเรียงซ้อนกันเป็นแถวยาว พร้อมขอบขวาจางๆ บอกว่ายังเลื่อนต่อได้ */
  .hero-banner {
    display: flex;
    grid-template-columns: unset;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 1rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .25rem;
    -webkit-mask-image: linear-gradient(to right, black 0, black calc(100% - 32px), transparent 100%);
    mask-image: linear-gradient(to right, black 0, black calc(100% - 32px), transparent 100%);
  }
  .hero-card { flex: 0 0 84%; height: 190px; scroll-snap-align: start; }
}

/* ============================================================
   หน้าเนื้อเพลง: ปุ่มถูกใจ (หัวใจ) + เมนูเพิ่มเติม (จุดไข่ปลา 3 จุด)
   ============================================================ */

.lyrics-more-wrap { position: relative; }
.lyrics-more-menu {
  position: absolute;
  top: calc(100% + .6rem);
  right: 0;
  z-index: 2100;
  min-width: 264px;
  max-width: calc(100vw - 2rem);
  padding: .6rem;
  border-radius: 18px;
  background: rgba(32, 32, 38, .88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  transform-origin: top right;
  animation: lyrics-menu-in .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes lyrics-menu-in { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.lyrics-more-menu.hidden { display: none; }
.lyrics-more-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .6rem .65rem;
  border-radius: 12px;
  color: var(--text-main);
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  text-align: left;
  background: transparent;
  transition: background .15s;
}
.lyrics-more-item:hover, .lyrics-more-item:active { background: rgba(255, 255, 255, .1); }
.lyrics-more-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.lyrics-more-item-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lyrics-more-item-icon svg { width: 17px; height: 17px; opacity: .95; }
#menu-like-track.liked-item .lyrics-more-item-icon { background: rgba(29, 185, 84, .18); }
#menu-like-track.liked-item svg path { fill: var(--accent); }
.lyrics-more-sep { height: 1px; margin: .4rem .55rem; background: rgba(255, 255, 255, .1); }

/* ============================================================
   ป็อปอัพกรอกข้อความ (แทน prompt ของเบราว์เซอร์)
   ============================================================ */
.text-prompt-content { width: min(420px, 90vw); }
.text-prompt-input {
  width: 100%;
  margin: 1rem 0 1.5rem;
  padding: .8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .07);
  color: var(--text-main);
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.text-prompt-input:focus { border-color: var(--accent); }

@media (max-width: 768px) {
  /* หน้าเนื้อเพลง: แถบปุ่มบน + แถวชื่อเพลง ต้องมีที่ว่างพอสำหรับปุ่มหัวใจ/เมนูเสมอ ไม่ให้ถูกบีบจนหาย */
  .lyrics-more-menu { right: auto; left: 50%; transform-origin: top center; transform: translateX(-50%) scale(.94); min-width: min(280px, calc(100vw - 2rem)); }
  @keyframes lyrics-menu-in { from { opacity: 0; transform: translateX(-50%) scale(.94) translateY(-4px); } to { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); } }
  .lyrics-track-title { font-size: 1.6rem; }
}

/* ============================================================
   แถวเพลง: ปุ่มถูกใจ + เพิ่มเข้าเพลย์ลิสต์ ท้ายแถว
   ============================================================ */
.track-item-actions { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; margin-left: .5rem; }
.row-icon-btn { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.row-icon-btn svg { width: 19px; height: 19px; }
.row-icon-btn:hover { background: rgba(255, 255, 255, .1); color: var(--text-main); }
.row-like-btn.liked { color: var(--accent); }
.row-like-btn.liked svg path { fill: var(--accent); }

@media (max-width: 768px) {
  .track-item-actions { gap: 0; }
  .row-icon-btn { width: 30px; height: 30px; }
  .row-icon-btn svg { width: 17px; height: 17px; }
}

/* อนิเมชันโหลดตอนกดเล่นเพลง จนกว่าจะเริ่มเล่นจริง */
.btn-play.is-loading svg { visibility: hidden; }
.btn-play.is-loading::after {
  content: '';
  position: absolute;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  border: 2.5px solid rgba(0, 0, 0, .25);
  border-top-color: rgba(0, 0, 0, .85);
  animation: btn-play-spin .7s linear infinite;
}
.btn-play { position: relative; }
.btn-play.is-loading::after { top: 50%; left: 50%; transform: translate(-50%, -50%); }
@keyframes btn-play-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ============================================================
   Player: แก้ข้อความล้น (ภาพ 4)
   ============================================================ */
.track-info {
  min-width: 0;
  overflow: hidden;
}
.track-details {
  min-width: 0;
  overflow: hidden;
}

/* ============================================================
   Daily Chart: หัวเรื่อง + แหล่งข้อมูล (ภาพ 4)
   ============================================================ */
.daily-chart-heading {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}
.daily-chart-title {
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.daily-chart-source {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-muted);
  font-size: .8rem;
}
.daily-chart-source svg { opacity: .7; flex-shrink: 0; }
.daily-chart-source a { color: var(--accent); text-decoration: none; }
.daily-chart-source a:hover { text-decoration: underline; }

/* ============================================================
   Lyrics loading spinner
   ============================================================ */
.lyrics-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.lyrics-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .12);
  border-top-color: var(--accent);
  animation: lyrics-spin .8s linear infinite;
}
@keyframes lyrics-spin { to { transform: rotate(360deg); } }
.lyrics-loading-text { font-size: .9rem; opacity: .7; }
/* ไม่มีเนื้อเพลงสำหรับเพลงนี้ -> ซ่อนแผงเนื้อเพลงทั้งหมด เหลือแค่หน้าเล่นเพลงปกติ (ปกอัลบั้ม/ชื่อเพลง/คอนโทรล)
   เหมือนเปิดเพลงที่ไม่มีเนื้อเพลงในแอปเพลงทั่วไป แทนที่จะมีกล่องข้อความ "ไม่มีเนื้อเพลง" ค้างอยู่กลางจอ */
.lyrics-layout.no-lyrics .lyrics-right {
  display: none;
}
/* ใช้ justify-content:center ของ flex แม่ตรงๆ แทนการพึ่ง margin:auto บนตัวลูกที่ถูก max-width จำกัดไว้
   (ลอง margin:0 auto มาก่อนแล้วแต่เพี้ยน ปกเลื่อนไปทางซ้ายเพราะ flex-grow ยังคิดพื้นที่แบบมี 2 คอลัมน์อยู่)
   วิธีนี้บังคับให้กล่องปก/ชื่อเพลง/คอนโทรลอยู่กึ่งกลางจอเป๊ะๆ ไม่ว่าจอกว้างแค่ไหน */
.lyrics-layout.no-lyrics {
  justify-content: center;
}
.lyrics-layout.no-lyrics .lyrics-left {
  flex: none;
  width: min(100%, 500px);
  margin: 0;
}

/* ============================================================
   View loading / error states (ศิลปิน, อัลบั้ม)
   ============================================================ */
.view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
.view-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .1);
  border-top-color: var(--accent);
  animation: lyrics-spin .8s linear infinite;
}
.view-error {
  padding: 2rem;
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  line-height: 1.6;
}

/* ============================================================
   Offline overlay — ไม่มีสัญญาณอินเทอร์เน็ต/มือถือ
   ============================================================ */
.offline-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(10, 10, 12, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2rem;
  text-align: center;
  transition: opacity .25s ease;
}
.offline-overlay.hidden {
  display: none;
}
.offline-overlay-text {
  color: rgba(255, 255, 255, .85);
  font-size: 1.05rem;
  line-height: 1.6;
}

.spotify-429-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 1.25rem;
  background: rgba(8, 10, 14, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.spotify-429-overlay.hidden { display: none; }
.spotify-429-card {
  width: min(100%, 440px);
  padding: clamp(1.5rem, 6vw, 2.5rem);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(38, 42, 51, .98), rgba(20, 22, 28, .98));
  box-shadow: 0 24px 90px rgba(0, 0, 0, .55);
  color: #fff;
  text-align: center;
}
.spotify-429-icon {
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}
.spotify-429-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.spotify-429-card h1 {
  margin: 0;
  font-size: clamp(1.3rem, 5vw, 1.75rem);
  line-height: 1.35;
}
.spotify-429-return-time {
  margin: .55rem 0 1rem;
  color: #ffd36b;
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 700;
}
.spotify-429-card p {
  color: rgba(255, 255, 255, .72);
  line-height: 1.65;
}
.spotify-429-countdown-label {
  margin-top: 1.5rem;
  color: rgba(255, 255, 255, .6);
  font-size: .9rem;
}
.spotify-429-countdown {
  margin-top: .15rem;
  color: #fff;
  font-family: Outfit, Kanit, sans-serif;
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: .04em;
}
.spotify-429-card .spotify-429-footnote {
  margin: 1rem 0 0;
  font-size: .82rem;
}

/* ============================================================
   คำเตือนก่อนเปิดโหมดรถ
   ============================================================ */
.car-mode-confirm-content {
  max-width: 420px;
}
.car-mode-confirm-text {
  color: var(--text-muted);
  font-size: .92rem;
  line-height: 1.7;
  margin: .75rem 0 1.25rem;
}

/* ============================================================
   โหมดรถ — สะท้อนเนื้อเพลงขึ้นกระจกหน้ารถ (วางโทรศัพท์/แท็บเล็ตบนคอนโซล)
   จอแนวนอน พื้นดำล้วน ไม่มีปก/ชื่อเพลง/คอนโทรล เหลือแค่เนื้อเพลงตรงกลาง และกลับด้านซ้าย-ขวาตั้งใจ
   ============================================================ */
.lyrics-modal.car-mode {
  background: #000 !important;
}
.lyrics-modal.car-mode .modal-blobs {
  display: none; /* ปิดพื้นหลังไล่สี ให้เป็นดำล้วน อ่านง่ายตอนสะท้อนบนกระจก ไม่รบกวนสายตาคนขับ */
}
.lyrics-modal.car-mode .lyrics-left {
  display: none; /* ซ่อนปก/ชื่อเพลง/คอนโทรลทั้งหมด เหลือแค่เนื้อเพลง ตามที่ต้องการ */
}
.lyrics-modal.car-mode .lyrics-layout {
  display: flex;
  min-height: 0;
  padding: 0;
}
.lyrics-modal.car-mode .lyrics-right {
  flex: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  flex-direction: column;
  -webkit-mask-image: none;
  mask-image: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lyrics-modal.car-mode #lyrics-container,
.lyrics-modal.car-mode am-lyrics {
  width: 100%;
  height: 100%;
}
.lyrics-modal.car-mode #lyrics-container {
  flex: 1;
  min-height: 0;
  height: auto;
  -webkit-mask-image: none;
  mask-image: none;
  transform: scaleX(-1); /* กลับด้านซ้าย-ขวาโดยตั้งใจ ให้อ่านถูกทิศตอนมองผ่านการสะท้อนบนกระจกหน้ารถ
     หมายเหตุ: ใส่ transform ไว้ที่ #lyrics-container (ตัวนอก) จุดเดียวพอ เพราะ am-lyrics เป็นลูกอยู่ข้างในอยู่แล้ว
     ถ้าใส่ scaleX(-1) ซ้ำที่ am-lyrics (ลูก) ด้วย มันจะกลับด้านซ้อนกัน 2 ชั้นแล้วหักล้างกันเอง กลายเป็นไม่กลับด้านเลย */
}
.lyrics-modal.car-mode .lyrics-writer-credit {
  flex: 0 0 auto;
  transform: scaleX(-1);
  padding: .25rem 1rem 1rem;
  color: #fff;
  font-size: clamp(1rem, 2vw, 1.5rem);
}
/* แถบปุ่มด้านบน: ตอนอยู่โหมดรถ ซ่อนปุ่มอื่นทั้งหมด เหลือแค่ปุ่ม "ออกจากโหมดรถ" ปุ่มเดียว (ไม่กลับด้าน เพราะไม่ใช่ส่วนของเนื้อเพลงที่สะท้อน) */
.lyrics-modal.car-mode .lyrics-modal-btns > *:not(#btn-car-mode-exit) {
  display: none;
}
#btn-car-mode-exit {
  display: flex;
  align-items: center;
  gap: .4rem;
  width: auto;
  border-radius: 999px;
  padding: 0 .9rem;
}
.car-mode-exit-label {
  font-size: .85rem;
  white-space: nowrap;
}

/* ===== R Music TV (จาก tv.html) ===== */
.tv-connect { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: var(--bg-dark); padding: 2rem; }
    .tv-card { width: min(560px, 100%); padding: 2.5rem; border-radius: 24px; text-align: center; }
    .tv-card h1 { font-size: 2.2rem; margin-bottom: .4rem; }
    .tv-beta { display: inline-block; vertical-align: middle; margin-left: .5rem; padding: .1rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .15); font-size: .8rem; font-weight: 600; letter-spacing: .04em; }
    .tv-card p { color: var(--text-muted); line-height: 1.6; margin-bottom: 1.5rem; }
    #tv-code-input { width: 100%; text-align: center; font: inherit; font-size: 2.6rem; letter-spacing: .5em; padding: .6rem .5rem .6rem 1rem; border-radius: 16px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .06); color: var(--text-main); outline: none; margin-bottom: 1rem; }
    #tv-code-input:focus { border-color: var(--accent); }
    #tv-connect-msg { min-height: 1.5rem; margin: .8rem 0; color: #ffb4b4; }
    .tv-card .btn-primary { width: 100%; font-size: 1.2rem; }
    .tv-status { position: fixed; left: 2rem; bottom: 1.5rem; z-index: 90; padding: .5rem 1rem; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 1rem; opacity: 0; transition: opacity .4s; pointer-events: none; }
    .tv-status.show { opacity: 1; }
    .tv-audio { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 95; max-width: min(520px, 60vw); padding: .9rem 1.2rem; border-radius: 16px; background: rgba(0, 0, 0, .72); color: #fff; font-size: clamp(.95rem, 1.3vw, 1.3rem); line-height: 1.5; backdrop-filter: blur(8px); }
    .tv-audio.err { background: rgba(120, 30, 30, .85); }
    /* ขยายให้เหมาะกับจอ TV */
    .tv-modal .lyrics-layout { padding: 3.5vw; gap: 4vw; }
    .tv-modal .lyrics-left { max-width: 36vw; }
    .tv-modal .lyrics-track-title { font-size: clamp(2rem, 3.2vw, 4.5rem); }
    .tv-modal .lyrics-track-artist { font-size: clamp(1.2rem, 1.9vw, 2.6rem); }
    .tv-modal .seek-bar { pointer-events: none; }
    .tv-modal .seek-time { font-size: clamp(.8rem, 1.1vw, 1.4rem); }
    .tv-modal .lyrics-right {
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .tv-modal .lyrics-container {
      flex: 1;
      min-height: 0;
    }
    .tv-modal .lyrics-writer-credit {
      flex: 0 0 auto;
      width: 100%;
      border-top: 1px solid rgba(255, 255, 255, .16);
      padding: .75rem 1rem 0;
      color: rgba(255, 255, 255, .9);
      font-size: clamp(1rem, 1.4vw, 1.5rem);
      line-height: 1.5;
      text-align: left;
    }

    /* Artist page */
    .artist-hero {
      position: relative;
      min-height: 390px;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      margin: -2rem -2rem 2rem;
      padding: 2rem;
      overflow: hidden;
      isolation: isolate;
      background-color: transparent;
      background-image: none;
    }
    .artist-hero-image {
      position: absolute;
      inset: 0;
      z-index: 0;
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center top;
      opacity: .86;
      -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 38%, rgba(0, 0, 0, .94) 46%, rgba(0, 0, 0, .82) 56%, rgba(0, 0, 0, .64) 66%, rgba(0, 0, 0, .42) 76%, rgba(0, 0, 0, .22) 84%, rgba(0, 0, 0, .08) 90%, transparent 96%, transparent 100%);
      mask-image: linear-gradient(to bottom, #000 0%, #000 38%, rgba(0, 0, 0, .94) 46%, rgba(0, 0, 0, .82) 56%, rgba(0, 0, 0, .64) 66%, rgba(0, 0, 0, .42) 76%, rgba(0, 0, 0, .22) 84%, rgba(0, 0, 0, .08) 90%, transparent 96%, transparent 100%);
    }
    .artist-hero-shade {
      position: absolute;
      inset: 0;
      z-index: 1;
      background: linear-gradient(180deg, rgba(0, 0, 0, .16) 0%, rgba(0, 0, 0, .06) 44%, transparent 76%, transparent 100%);
      pointer-events: none;
    }
    .artist-page-actions {
      position: absolute;
      top: 1.25rem;
      left: 1.25rem;
      right: 1.25rem;
      z-index: 3;
      display: flex;
      justify-content: space-between;
    }
    .artist-page-actions-right {
      display: flex;
      gap: .25rem;
      padding: .25rem;
      border: 1px solid rgba(255, 255, 255, .14);
      border-radius: 999px;
      background: rgba(28, 28, 30, .48);
      backdrop-filter: saturate(180%) blur(20px);
      -webkit-backdrop-filter: saturate(180%) blur(20px);
    }
    .artist-page-icon {
      display: grid;
      place-items: center;
      width: 52px;
      height: 52px;
      border: 1px solid rgba(255, 255, 255, .12);
      border-radius: 50%;
      background: rgba(28, 28, 30, .48);
      color: #fff;
      cursor: pointer;
      backdrop-filter: saturate(180%) blur(20px);
      -webkit-backdrop-filter: saturate(180%) blur(20px);
      transition: background .2s, transform .2s;
    }
    .artist-page-icon:hover { background: rgba(20, 20, 20, .65); transform: scale(1.05); }
    .artist-page-icon svg { width: 25px; height: 25px; }
    .artist-page-active .mobile-top-nav { display: none; }
    .artist-page-active .main-content { scroll-padding-top: 0; }
    .artist-page-active .artist-header { margin-top: 0; }
    .artist-page-active .artist-section h2::after {
      content: '›';
      display: inline-block;
      margin-left: .35rem;
      font-size: 1.25em;
      line-height: .8;
    }
    .artist-hero-content {
      width: min(100%, 900px);
      position: relative;
      z-index: 2;
      text-align: center;
      text-shadow: 0 2px 18px rgba(0, 0, 0, .5);
    }
    .artist-hero-content h1 {
      margin: 0;
      font-size: clamp(2.5rem, 5vw, 4.5rem);
      font-weight: 500;
      line-height: 1.15;
      overflow-wrap: anywhere;
    }
    .artist-genres { margin: .4rem 0 0; color: rgba(255, 255, 255, .78); }
    .artist-hero-actions {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 1.5rem;
      margin-top: 1.5rem;
    }
    .artist-round-btn {
      width: 64px;
      height: 64px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid rgba(255, 255, 255, .16);
      border-radius: 50%;
      background: rgba(255, 255, 255, .12);
      color: #fff;
      font: inherit;
      font-size: 1.8rem;
      cursor: pointer;
      backdrop-filter: blur(8px);
      transition: transform .2s, background .2s;
    }
    .artist-round-btn:hover:not(:disabled) { transform: scale(1.06); background: rgba(255, 255, 255, .22); }
    .artist-round-btn:disabled { opacity: .45; cursor: default; }
    .artist-round-btn svg { width: 28px; height: 28px; }
    .artist-play-btn {
      width: 88px;
      height: 88px;
      border: 0;
      background: #fff;
      color: #171717;
      text-shadow: none;
    }
    .artist-play-btn svg { width: 38px; height: 38px; }
    .album-hero-actions {
      display: flex;
      align-items: center;
      gap: .75rem;
      margin-top: 1rem;
    }
    .album-hero-actions .artist-play-btn { width: 56px; height: 56px; }
    .album-hero-actions .artist-play-btn svg { width: 26px; height: 26px; }
    .album-shuffle-btn { width: 56px; height: 56px; font-size: 1.25rem; }
    .artist-follow-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .artist-follow-btn.is-following { color: var(--accent); background: rgba(29, 185, 84, .2); }
    .artist-follow-btn.is-following svg { fill: currentColor; }
    .artist-section { margin: 0 0 2.5rem; }
    .artist-section h2 { margin-bottom: 1rem; color: var(--text-main); }
    .artist-listening-parties-list { display: grid; gap: .85rem; }
    .artist-listening-party-card {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding: 1rem 1.15rem;
      border: 1px solid rgba(255, 255, 255, .13);
      border-radius: 16px;
      background: rgba(255, 255, 255, .07);
    }
    .artist-listening-party-card.is-spotify-event {
      align-items: stretch;
      flex-direction: column;
      gap: 0;
      overflow: hidden;
      padding: 0;
      background: #1d1d1f;
    }
    .artist-listening-party-image {
      display: block;
      width: 100%;
      aspect-ratio: 16 / 9;
      object-fit: cover;
      background: rgba(255, 255, 255, .06);
    }
    .artist-listening-party-card.is-spotify-event .artist-listening-party-copy {
      padding: 1rem 1.15rem .5rem;
    }
    .artist-listening-party-label {
      color: var(--accent);
      font-size: .85rem;
      font-weight: 700;
    }
    .artist-listening-party-card.is-spotify-event .artist-listening-party-copy h3 {
      font-size: clamp(1.2rem, 3vw, 1.65rem);
    }
    .artist-listening-party-date { color: var(--text-main) !important; }
    .artist-listening-party-card.is-spotify-event .artist-listening-party-play {
      align-self: flex-end;
      margin: .25rem 1.15rem 1rem;
      border: 1px solid rgba(255, 255, 255, .4);
      background: transparent;
    }
    .artist-listening-party-copy { min-width: 0; }
    .artist-listening-party-artist { color: var(--text-muted); font-size: .85rem; }
    .artist-listening-party-copy h3 { margin: .2rem 0; color: var(--text-main); font-size: 1.05rem; }
    .artist-listening-party-copy p { margin: .25rem 0 0; color: var(--text-muted); line-height: 1.5; }
    .artist-listening-party-play {
      display: inline-flex;
      align-items: center;
      flex: 0 0 auto;
      padding: .7rem 1rem;
      border: 0;
      border-radius: 999px;
      background: var(--accent);
      color: #fff;
      font: inherit;
      font-weight: 700;
      cursor: pointer;
      text-decoration: none;
    }
    .artist-listening-party-play:hover { filter: brightness(1.1); }
    .artist-listening-party-error { color: var(--text-muted); }
    #artist-top-tracks .track-item {
      border-radius: 0;
      border-bottom: 1px solid rgba(255, 255, 255, .1);
      background: transparent;
    }
    #artist-top-tracks .track-item:hover { background: rgba(255, 255, 255, .06); transform: none; }
    #artist-top-tracks .track-item img { width: 64px; height: 64px; border-radius: 8px; }
    .artist-release-card {
      width: 100%;
      min-height: 150px;
      display: flex;
      align-items: center;
      gap: 1.25rem;
      padding: 1rem;
      border: 1px solid rgba(255, 255, 255, .13);
      border-radius: 24px;
      background: rgba(255, 255, 255, .08);
      color: var(--text-main);
      text-align: left;
      font: inherit;
      cursor: pointer;
      transition: background .2s, transform .2s;
    }
    .artist-release-card:hover { background: rgba(255, 255, 255, .13); transform: translateY(-2px); }
    .artist-release-card > img { width: 132px; height: 132px; flex: 0 0 auto; object-fit: cover; border-radius: 14px; }
    .artist-release-copy { display: flex; flex-direction: column; gap: .25rem; min-width: 0; color: var(--text-muted); }
    .artist-release-copy strong { color: var(--text-main); font-size: 1.25rem; }
    .artist-release-date { font-size: .9rem; }
    .artist-release-open {
      width: 48px;
      height: 48px;
      display: grid;
      place-items: center;
      flex: 0 0 auto;
      margin-left: auto;
      border-radius: 50%;
      background: rgba(255, 255, 255, .13);
      font-size: 2rem;
      line-height: 1;
    }
    .artist-album-row {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 1rem;
      align-items: start;
    }
    .artist-album-card { min-width: 0; }
    .artist-album-card img {
      display: block;
      width: 100%;
      aspect-ratio: 1;
      object-fit: cover;
      border-radius: 12px;
    }

    @media (min-width: 769px) and (max-width: 1100px) {
      :root {
        --sidebar-width: 200px;
        --player-height: 84px;
      }
      .sidebar { padding: 1rem; }
      .main-content { padding: 1.25rem; }
      .player { gap: .75rem; padding: 0 1.25rem; }
      .artist-album-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
      .artist-hero { min-height: 340px; margin: -1.25rem -1.25rem 1.75rem; }
      .lyrics-layout { padding: 3rem 2rem; gap: 2rem; }
      .lyrics-left { flex: .85; max-width: 38%; }
      .lyrics-right { flex: 1.4; height: 94%; }
      am-lyrics {
        --am-lyrics-compact-font-size: 38px;
        --am-lyrics-compact-line-spacing: 33px;
      }
    }

    @media (min-width: 1101px) {
      .lyrics-layout { gap: 3rem; }
      .lyrics-left { flex: .9; }
      .lyrics-right { flex: 1.5; height: 94%; }
      am-lyrics { max-width: 1000px; }
    }

    @media (max-width: 768px) {
      .artist-hero {
        height: clamp(360px, 100vw, 420px);
        min-height: 0;
        align-items: flex-end;
        margin: 0 -1rem .75rem;
        padding: 1.25rem 1rem 1.25rem;
      }
      #app-screen.artist-page-active { padding-top: 0; }
      #app-screen.artist-page-active .main-content { padding-top: env(safe-area-inset-top, 0px); }
      .artist-page-active .artist-hero { margin-top: calc(-1 * env(safe-area-inset-top, 0px)); }
      .artist-page-actions { top: calc(env(safe-area-inset-top, 0px) + 1rem); left: 1rem; right: 1rem; }
      .artist-page-icon { width: 44px; height: 44px; }
      .artist-page-actions-right { gap: .15rem; }
      .artist-page-actions-right .artist-page-icon { border-color: transparent; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
      .artist-hero-content h1 { font-size: clamp(2rem, 9vw, 3rem); }
      .artist-hero-actions { gap: 1rem; margin-top: .75rem; }
      .artist-round-btn { width: 52px; height: 52px; font-size: 1.5rem; }
      .artist-play-btn { width: 72px; height: 72px; }
      .artist-play-btn svg { width: 32px; height: 32px; }
      .artist-section { margin-bottom: 2rem; }
      .artist-section h2 { font-size: 1.35rem; }
      .artist-listening-party-card { align-items: flex-start; flex-direction: column; }
      .artist-release-card { min-height: 118px; gap: .8rem; padding: .75rem; border-radius: 20px; }
      .artist-release-card > img { width: 88px; height: 88px; border-radius: 12px; }
      .artist-release-copy strong { font-size: 1.05rem; }
      .artist-release-date { font-size: .8rem; }
      .artist-release-open { width: 40px; height: 40px; font-size: 1.7rem; }
      .artist-album-row {
        display: flex;
        gap: .75rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 .1rem .75rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
      }
      .artist-album-card {
        flex: 0 0 min(42vw, 190px);
        scroll-snap-align: start;
      }
      .lyrics-layout { padding-left: 1.25rem; padding-right: 1.25rem; }
      am-lyrics {
        --am-lyrics-compact-font-size: 36px;
        --am-lyrics-compact-line-spacing: 32px;
      }
    }

    /* ============================================================
       Mobile Top Nav Bar (Apple Music style)
       ============================================================ */
@media (max-width: 768px) {
  .mobile-top-nav {
    display: flex;
    align-items: center;
    position: sticky;
    top: .55rem;
    z-index: 50;
    width: calc(100% - 1.5rem);
    min-height: 46px;
    margin: calc(env(safe-area-inset-top, 0px) + .55rem) auto .85rem;
    padding: .25rem .45rem;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 16px;
    background: rgba(28, 28, 30, .42);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .18), inset 0 1px rgba(255, 255, 255, .08);
    gap: .3rem;
  }

  .btn-hamburger {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 12px;
  }
  .btn-hamburger svg { width: 22px; height: 22px; }
  .btn-hamburger:hover { background: rgba(255,255,255,.1); }

  .top-nav-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    gap: .05rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: center;
  }
  .top-nav-tabs::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset-block: .08rem;
    left: 0;
    width: var(--active-tab-width, 0px);
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    box-shadow: inset 0 1px rgba(255, 255, 255, .12);
    transform: translateX(var(--active-tab-x, 0px));
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), width .32s cubic-bezier(.2, .8, .2, 1);
    pointer-events: none;
  }
  .top-nav-tabs::-webkit-scrollbar { display: none; }

  .top-nav-tab {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    padding: .42rem .5rem;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 500;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
  }
  .top-nav-tab.active {
    color: var(--text-main);
    font-weight: 700;
  }
  .top-nav-tab:not(.active):hover { color: var(--text-main); }

  .btn-top-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    color: var(--text-main);
    border-radius: 12px;
  }
  .btn-top-icon:hover { background: rgba(255,255,255,.1); }
  .mobile-top-nav button:focus { outline: none; }
  .mobile-top-nav button:focus-visible,
  .mobile-top-nav a:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .72);
    outline-offset: 2px;
  }
  #btn-top-search.active { color: var(--accent); }
  .btn-top-icon svg { width: 20px; height: 20px; }

  @media (max-width: 380px) {
    .mobile-top-nav { gap: .2rem; padding-left: .5rem; padding-right: .5rem; }
    .top-nav-tab { padding-left: .35rem; padding-right: .35rem; font-size: .82rem; }
    #btn-top-more { display: none; }
  }

  /* Section title on home view */
  .section-title-main {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 1.2rem 0 .75rem;
    letter-spacing: -.01em;
  }

  /* Hero banner: larger cards, horizontal scroll */
  .hero-banner {
    margin-bottom: 1.5rem;
  }
  .hero-card {
    height: 200px;
    flex: 0 0 85%;
  }

  /* daily-charts horizontal scroll section title */
  .daily-chart-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
  }
  .daily-chart-section-title h2 {
    font-size: 1.25rem;
    margin: 0;
  }
  .daily-chart-section-title a {
    color: var(--text-muted);
    font-size: .9rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .2rem;
  }

  /* Drawer user section */
  .drawer-user .user-profile-btn {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .65rem .75rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-main);
    font: inherit;
    cursor: pointer;
    text-align: left;
    transition: background .2s;
  }
  .drawer-user .user-profile-btn:hover { background: rgba(255,255,255,.08); }
  .drawer-user .avatar-fallback,
  .drawer-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
  }
  .drawer-user-info { display: flex; flex-direction: column; min-width: 0; }
  .drawer-user-name { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .drawer-user-sub { font-size: .78rem; color: var(--text-muted); }
}

/* ============================================================
   Sidebar nav labels (แสดงบน desktop, ซ่อนบน mobile แล้ว)
   ============================================================ */
.sidebar-label { display: block; }
@media (max-width: 768px) {
  .sidebar-label { display: none; }
}

.wikipedia-artist-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(8px);
}
.wikipedia-artist-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: min(78vh, 720px);
  overflow-y: auto;
  padding: 1.75rem;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  background: #202024;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.wikipedia-artist-dialog h2 { padding-right: 2.5rem; font-size: 1.5rem; }
.wikipedia-artist-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: 1.7rem;
  cursor: pointer;
}
.wikipedia-artist-content { color: rgba(255, 255, 255, .82); line-height: 1.8; white-space: pre-line; }
.artist-bio-section {
  display: grid;
  gap: .75rem;
  margin: 1rem 0 1.5rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .04);
}
.artist-bio-content { color: rgba(255, 255, 255, .82); line-height: 1.7; }
.artist-bio-content p { margin: 0; }
.artist-bio-image { display: block; width: min(100%, 320px); max-height: 240px; margin: 0 auto 1rem; border-radius: 12px; object-fit: cover; }
.artist-bio-source { width: fit-content; color: #ff6b6b; }
.ios-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  min-height: 3rem;
  padding: 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.ios-spinner {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  color: var(--accent);
}
.ios-spinner-bar {
  position: absolute;
  top: 2px;
  left: 11px;
  width: 2px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 1px 10px;
  transform: rotate(var(--spinner-angle));
  animation: ios-spinner-fade 1.2s linear infinite;
}
@keyframes ios-spinner-fade {
  0% { opacity: 1; }
  100% { opacity: .15; }
}
@media (prefers-reduced-motion: reduce) {
  .ios-spinner-bar { animation-duration: 2s; }
}
.wikipedia-artist-image { display: block; width: min(100%, 320px); max-height: 240px; margin: 0 auto 1rem; border-radius: 14px; object-fit: cover; }
.wikipedia-artist-source { display: inline-block; margin-top: 1.25rem; color: #ff4b4b; }
@media (max-width: 768px) {
  .wikipedia-artist-overlay { align-items: flex-end; padding: 0; }
  .wikipedia-artist-dialog { width: 100%; max-height: 82dvh; padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; }
}

.home-collection { margin: 2rem 0 2.5rem; }
.home-collection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.home-collection-heading h2 { margin: 0; font-size: 1.35rem; }
.home-collection-heading p { margin: .3rem 0 0; color: var(--text-muted); font-size: .85rem; }
.home-collection-more {
  flex: 0 0 auto;
  padding: .45rem .75rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  color: var(--text-main);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.home-collection-more:hover { background: rgba(255, 255, 255, .12); }
.home-artist-row, .home-personalized-row {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding: .25rem .1rem .8rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.home-artist-row::-webkit-scrollbar, .home-personalized-row::-webkit-scrollbar { display: none; }
.home-artist-card, .home-personalized-card {
  min-width: 0;
  flex: 0 0 170px;
  padding: .55rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.home-artist-card:hover, .home-personalized-card:hover { background: rgba(255, 255, 255, .06); transform: translateY(-2px); }
.home-artist-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: .75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .32);
}
.home-artist-card strong, .home-artist-card span, .home-personalized-card strong, .home-personalized-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-artist-card strong, .home-personalized-card strong { font-size: .95rem; font-weight: 600; }
.home-artist-card span, .home-personalized-card span { margin-top: .25rem; color: var(--text-muted); font-size: .83rem; }
.home-personalized-card { flex-basis: 220px; }
.home-personalized-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: .7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .32);
}
.developer-sound-card img, .developer-sound-card .developer-sound-cover-placeholder {
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: .7rem;
  border-radius: 14px;
}
.developer-sound-header { margin-bottom: 1.5rem; }
.developer-sound-hero {
  overflow: hidden;
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  background: linear-gradient(125deg, rgba(255, 164, 38, .14), rgba(175, 74, 94, .12) 52%, rgba(255, 255, 255, .035));
}
.developer-sound-intro {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr);
  align-items: end;
  gap: clamp(.8rem, 2.5vw, 1.5rem);
}
.developer-sound-intro > .page-back { grid-column: 1 / -1; justify-self: start; }
.developer-sound-cover {
  display: block;
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
}
.developer-sound-cover-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(255, 191, 63, .65), rgba(237, 98, 71, .55) 58%, rgba(155, 76, 129, .7));
  color: rgba(255, 255, 255, .9);
  font-size: clamp(3rem, 10vw, 5rem);
}
.developer-sound-details { min-width: 0; }
.developer-sound-kicker { color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.developer-sound-details h1 { margin: .3rem 0; font-size: clamp(1.6rem, 5vw, 3.2rem); overflow-wrap: anywhere; }
.developer-sound-details p { margin: 0 0 1rem; color: var(--text-muted); }
.developer-sound-details .artist-round-btn { width: 54px; height: 54px; }
.home-collection-loading { padding: 2rem 1rem; color: var(--text-muted); }
.page-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}
.page-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .55rem .9rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.page-back:hover { background: rgba(255, 255, 255, .15); }
.page-heading { margin-right: auto; }
.page-kicker { color: rgba(255, 255, 255, .5); font-size: .7rem; font-weight: 700; letter-spacing: .18em; }
.page-heading h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.2; }
.page-note { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}


@media (max-width: 600px) {
  .developer-sound-intro { grid-template-columns: minmax(100px, 36%) minmax(0, 1fr); align-items: center; }
  .developer-sound-details h1 { font-size: clamp(1.35rem, 6vw, 2rem); }
  .developer-sound-details .artist-round-btn { width: 46px; height: 46px; }
}

/* ============================================================
   หน้าเล่นเพลง (Now Playing) โหมดย่อ — เปิดมาเห็นทันทีตามภาพ ไม่ต้องกดเนื้อเพลง
   ปกใหญ่ + บรรทัดเนื้อเพลงปัจจุบัน + ชื่อเพลง + แถบเวลา + ปุ่มควบคุม + การ์ด "เนื้อเพลง" (แตะเพื่อขยายเต็มจอ)
   ใช้ได้ทั้งมือถือและคอม (คอมเป็นคอลัมน์กลางจอ)
   ============================================================ */
.track-info { cursor: pointer; }

/* องค์ประกอบเฉพาะโหมดย่อ: ซ่อนเมื่อเป็นหน้าเนื้อเพลงเต็ม */
.lyrics-modal:not(.np-compact) .np-only { display: none !important; }

/* โหมดย่อ: แผงเนื้อเพลงเต็ม (<am-lyrics> ตัวจริง ซิงก์ตามเวลา) วางซ้อนอยู่ในการ์ด "เนื้อเพลง" ให้เห็นและทำงานจริงตั้งแต่เปิดหน้า
   ไม่รับการแตะ (pointer-events:none) เพื่อให้แตะทะลุไปที่การ์ดแล้วขยายเต็มจอ */
.lyrics-modal.np-compact .lyrics-right {
  grid-area: card;
  position: relative;
  z-index: 2;
  flex: none;
  width: auto;
  height: auto;
  align-self: stretch;
  margin: 3.7rem 1.1rem 1rem;
  contain: size layout;
  overflow: hidden;
  pointer-events: none;
}
.lyrics-modal.np-compact .lyrics-right .lyrics-container { position: relative; height: 100%; }
.lyrics-modal.np-compact .lyrics-writer-credit { display: none !important; }
.lyrics-modal.np-compact .np-card-btns { position: relative; z-index: 3; }
.lyrics-modal.np-compact .np-lyrics-card { min-height: 17rem; }
.lyrics-modal.np-compact .np-card-preview { display: none; }
.lyrics-modal.np-compact .lyrics-layout.no-lyrics .np-card-preview { display: block; -webkit-line-clamp: unset; }
.lyrics-modal.np-compact .np-line { display: none !important; }
.lyrics-modal.np-compact .lyrics-layout.no-lyrics .lyrics-right { display: none; }
.lyrics-modal.np-compact am-lyrics { --am-lyrics-compact-font-size: 22px; --am-lyrics-compact-line-spacing: 16px; text-align: left; }

/* หัวเรื่อง "กำลังเล่นจากอัลบั้ม": อยู่ใน .lyrics-layout (เลื่อนไปกับเนื้อหา)
   จัดกึ่งกลางด้วย left/right:0 + margin auto + fit-content
   (แบบเดิม left:50% + translateX(-50%) ทำให้กล่องมีที่ว่างแค่ครึ่งจอ ชื่ออัลบั้มยาวๆ จะโดนบีบ/ตัดก่อนเวลาและดูเยื้อง) */
.lyrics-modal.np-compact .np-header {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 1.4rem);
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 210px);
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
}
.np-header-label { font-size: .82rem; color: rgba(255, 255, 255, .78); }
.np-header-name { max-width: 100%; font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ชื่อศิลปินในหน้าเล่นเพลง: แตะแล้วไปหน้าศิลปิน */
.np-artist-link { cursor: pointer; border-radius: 4px; -webkit-tap-highlight-color: transparent; }
.np-artist-link:hover { color: #fff; text-decoration: underline; }
.np-artist-link:active { opacity: .6; }
.np-artist-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* แถบปุ่มด้านบน: ลูกศรย่อซ้ายสุด ที่เหลืออยู่ขวา */
.lyrics-modal.np-compact .lyrics-modal-btns {
  top: calc(env(safe-area-inset-top, 0px) + 1.2rem);
  left: 1.25rem;
  right: 1.25rem;
}
.lyrics-modal.np-compact #btn-close-lyrics { order: -1; margin-right: auto; }

.np-line {
  grid-area: line;
  margin: 1rem 0 .5rem;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #fff;
  width: 100%;
}
.np-line:empty { display: none !important; }

.lyrics-modal.np-compact .lyrics-track-details { position: relative; padding-right: 3.6rem; margin: 0 0 .5rem; min-width: 0; }
.lyrics-modal.np-compact .lyrics-track-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .15rem; }
.lyrics-modal.np-compact .lyrics-track-artist { font-size: 1.05rem; color: rgba(255, 255, 255, .62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.np-like {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.np-like svg { width: 38px; height: 38px; }
.np-like.liked { color: var(--accent); }
.np-like:hover { transform: translateY(-50%) scale(1.08); }

.lyrics-modal.np-compact .seek-row-lyrics { margin: .25rem 0 .75rem; }

.lyrics-modal.np-compact .lyrics-controls { justify-content: space-between; gap: .5rem; padding: 0 .25rem; margin-bottom: .4rem; }
.lyrics-modal.np-compact .lyrics-controls .btn-icon:not(.btn-play):not(.np-mode-btn) svg { width: 40px; height: 40px; }
.lyrics-modal.np-compact .lyrics-controls .np-mode-btn svg { width: 28px; height: 28px; }
.lyrics-modal.np-compact .lyrics-controls .np-mode-btn { color: rgba(255, 255, 255, .85); }
.lyrics-modal.np-compact .lyrics-controls .np-mode-btn[aria-pressed="true"] { color: var(--accent); }
.lyrics-modal.np-compact .lyrics-controls .btn-play,
.lyrics-modal.np-compact .lyrics-controls .btn-play:hover {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .3);
}
.lyrics-modal.np-compact .lyrics-controls .btn-play svg { width: 32px; height: 32px; filter: none; }

.np-actions { grid-area: actions; display: flex; align-items: center; justify-content: space-between; margin: .3rem 0 .6rem; padding: 0 .25rem; width: 100%; }
.lyrics-modal.np-compact .np-actions .btn-icon { color: rgba(255, 255, 255, .9); }
.lyrics-modal.np-compact .np-actions .btn-icon svg { width: 26px; height: 26px; filter: none; }

/* การ์ดเนื้อเพลง */
.np-lyrics-card {
  grid-area: card;
  box-sizing: border-box;
  width: 100%;
  margin-top: .25rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .1);
  cursor: pointer;
  text-align: left;
}
.np-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.np-card-title { font-size: 1.15rem; font-weight: 700; }
.np-card-btns { display: flex; gap: .6rem; }
.np-card-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.np-card-btn:hover { background: rgba(255, 255, 255, .26); transform: scale(1.08); }
.np-card-btn svg { width: 20px; height: 20px; }
.np-card-preview {
  margin-top: .6rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: rgba(255, 255, 255, .78);
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.np-card-preview:empty { display: none; }
.lyrics-layout.no-lyrics .np-card-expand-hidden,
.lyrics-layout.no-lyrics #np-card-expand { display: none; }

/* ----- มือถือ ----- */
@media (max-width: 768px) {
  .lyrics-modal.np-compact .lyrics-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto auto;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    row-gap: .1rem;
    grid-template-areas: "art" "line" "details" "seek" "controls" "actions" "card";
    align-items: stretch;
    justify-items: stretch;
    padding: calc(env(safe-area-inset-top, 0px) + 4.6rem) 1.25rem calc(env(safe-area-inset-bottom, 0px) + .75rem);
  }
  .lyrics-modal.np-compact .lyrics-left img {
    grid-area: art;
    width: min(100%, 50vh);
    height: auto;
    max-width: 100%;
    aspect-ratio: 1;
    justify-self: center;
    align-self: center;
    margin: 0;
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
  .lyrics-modal.np-compact .lyrics-track-details { grid-area: details; }
  .lyrics-modal.np-compact .lyrics-track-title { font-size: 1.4rem; }
  .lyrics-modal.np-compact .seek-row-lyrics { grid-area: seek; }
  .lyrics-modal.np-compact .lyrics-controls { grid-area: controls; padding: 0 .25rem; }
  .np-card-preview { -webkit-line-clamp: 2; font-size: .95rem; }
  /* เลื่อนหน้าลงมาดูเนื้อเพลง: การ์ดสูงพอให้อ่านหลายบรรทัด */
  .lyrics-modal.np-compact .np-lyrics-card { min-height: 28rem; margin-bottom: 1rem; }
  .lyrics-modal.np-compact am-lyrics { --am-lyrics-compact-font-size: 26px; --am-lyrics-compact-line-spacing: 18px; }
}

/* ----- คอม: 2 คอลัมน์ ซ้าย = ปก/ชื่อเพลง/คอนโทรล ขวา = การ์ดเนื้อเพลงสูงเต็ม ----- */
@media (min-width: 769px) {
  .lyrics-modal.np-compact .lyrics-modal-btns { left: 2.5rem; right: 2.5rem; top: 1.6rem; }
  .lyrics-modal.np-compact .np-header { top: 1.6rem; }
  .lyrics-modal.np-compact .lyrics-layout {
    display: grid;
    grid-template-columns: minmax(0, 540px);
    grid-template-areas: "left" "card";
    justify-content: center;
    align-content: center;
    align-items: center;
    row-gap: 1rem;
    padding: 6rem 2.5rem 2rem;
    overflow-y: auto;
  }
  .lyrics-modal.np-compact .lyrics-left {
    grid-area: left;
    flex: none;
    width: 100%;
    max-width: none;
    margin: 0;
    align-items: stretch;
  }
  .lyrics-modal.np-compact .lyrics-left img {
    width: min(100%, 30vh);
    min-width: 180px;
    align-self: center;
    margin: 0 0 .8rem;
    border-radius: 12px;
  }
  .lyrics-modal.np-compact .lyrics-track-title { font-size: 1.6rem; }
  .lyrics-modal.np-compact .lyrics-controls { justify-content: space-between; gap: 1rem; width: 100%; }
  .lyrics-modal.np-compact .np-lyrics-card { width: 100%; min-height: 0; height: 16rem; margin-top: 0; }
  .np-card-btn { width: 38px; height: 38px; }
}
@media (min-width: 1000px) {
  .lyrics-modal.np-compact .lyrics-layout {
    grid-template-columns: minmax(0, 460px) minmax(0, 580px);
    grid-template-areas: "left card";
    column-gap: 3.5rem;
  }
  .lyrics-modal.np-compact .lyrics-left img { width: min(100%, 44vh); }
  .lyrics-modal.np-compact .np-lyrics-card { height: min(74vh, 680px); align-self: center; }
  .lyrics-modal.np-compact am-lyrics { --am-lyrics-compact-font-size: 28px; --am-lyrics-compact-line-spacing: 20px; }
}

/* ============================================================
   มือถือ: จัดระยะให้โปร่งขึ้น ไม่อึดอัด (ปรับตัวเลขตรงนี้ที่เดียว)
   - หน้า Now Playing (โหมดย่อ): เว้นระยะระหว่างปก/ชื่อเพลง/แถบเวลา/ปุ่มให้ห่างขึ้น ปกเล็กลงเล็กน้อย
   - หน้าเนื้อเพลงเต็ม: ตัวอักษรเล็กลงนิดหน่อย บรรทัดห่างขึ้น ขอบซ้ายขวากว้างขึ้น
   ============================================================ */
@media (max-width: 768px) {
  .lyrics-modal.np-compact .lyrics-layout {
    row-gap: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 4.75rem) 1.6rem calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  }
  .lyrics-modal.np-compact .lyrics-left img { width: min(100%, 44vh); margin-bottom: 1.5rem; border-radius: 14px; }
  .lyrics-modal.np-compact .lyrics-track-details { margin: 0 0 1rem; }
  .lyrics-modal.np-compact .seek-row-lyrics { margin: .25rem 0 1.25rem; }
  .lyrics-modal.np-compact .lyrics-controls { margin-bottom: 1rem; }
  .np-actions { margin: .5rem 0 1.5rem; }
  .lyrics-modal.np-compact .np-lyrics-card { min-height: 26rem; margin-bottom: 1.5rem; padding: 1.25rem; border-radius: 22px; }
  .lyrics-modal.np-compact am-lyrics { --am-lyrics-compact-font-size: 24px; --am-lyrics-compact-line-spacing: 20px; }

  .lyrics-modal:not(.np-compact):not(.car-mode):not(.karaoke-mode) .lyrics-layout { padding-inline: 1.75rem; column-gap: 1.1rem; }
  .lyrics-modal:not(.np-compact):not(.car-mode):not(.karaoke-mode) .seek-row-lyrics { margin-bottom: 1.5rem; }
  .lyrics-modal:not(.np-compact):not(.car-mode):not(.karaoke-mode) am-lyrics { --am-lyrics-compact-font-size: 28px; --am-lyrics-compact-line-spacing: 32px; }
}

/* ============================================================
   แก้หน้า Now Playing บนมือถือ (v20)
   1) แถบขาวทางขวา = scrollbar ของ .lyrics-layout (เลื่อนได้เพราะ overflow-y:auto)
      ถูกสไตล์ด้วย ::-webkit-scrollbar แบบ global (กว้าง 8px สีขาวจาง) จึงโชว์ค้างบนมือถือ -> ซ่อน
   2) เนื้อเพลงเลยกรอบการ์ด: .lyrics-right เป็นชั้นซ้อนอยู่ในช่อง grid "card" และ margin ถูกวัดจาก "ช่อง grid"
      ไม่ใช่จากขอบการ์ด แต่การ์ดมี margin-bottom 1.5rem + padding 1.25rem ทำให้ชั้นเนื้อเพลงล้นลงมาใต้การ์ดประมาณ .5rem
      -> ตั้ง margin ใหม่ให้ตรงกับ margin/padding ของการ์ดพอดี
   ============================================================ */
@media (max-width: 768px) {
  .lyrics-modal.np-compact .lyrics-layout {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .lyrics-modal.np-compact .lyrics-layout::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  /* บน: .25rem (margin-top การ์ด) + 1.25rem (padding) + 40px (แถวปุ่ม) + .5rem (เว้น) = 4.5rem
     ข้าง: เท่ากับ padding การ์ด 1.25rem
     ล่าง: 1.5rem (margin-bottom การ์ด) + 1.25rem (padding การ์ด) */
  .lyrics-modal.np-compact .lyrics-right {
    margin: 4.5rem 1.25rem 2.75rem;
    border-radius: 0 0 16px 16px;
  }
  /* เฟดขอบล่างให้บรรทัดสุดท้ายค่อยๆ จางแทนการโดนตัดตรงๆ */
  .lyrics-modal.np-compact .lyrics-right .lyrics-container {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 14%, black 86%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 14%, black 86%, transparent 100%);
  }
}


/* ============================================================
   Canvas วิดีโอ (แบบ Spotify Canvas) — หน้า Now Playing บนมือถือเท่านั้น (v21)
   - วิดีโออยู่ในกรอบ .np-canvas ที่ "เลื่อนไปพร้อมหน้า" (absolute ใน .lyrics-layout ที่เลื่อนได้)
   - ขอบล่างจางหายด้วย mask-image แล้วกลืนไปกับพื้นหลังสีไล่โทนของหน้า
   - ตอนมีวิดีโอ (.np-canvas-on) ซ่อนปกอัลบั้ม (ยังกินที่เหมือนเดิม เลย์เอาต์ไม่ขยับ)
   - ปรับความสูง/จุดเริ่มจางที่ --np-canvas-h และ --np-canvas-fade-start
   ============================================================ */
.np-canvas { display: none; }

@media (max-width: 768px) {
  .lyrics-modal.np-compact .lyrics-layout { isolation: isolate; } /* ให้ z-index:-1 ของวิดีโออยู่หลังเนื้อหาแต่เหนือพื้นหลัง */

  .lyrics-modal.np-compact .np-canvas {
    --np-canvas-h: calc(env(safe-area-inset-top, 0px) + 4.75rem + min(44vh, 100vw - 3.2rem) + 6.5rem);
    --np-canvas-fade-start: 50%;
    --np-canvas-top: 0px; /* วิดีโอชิดขอบบน (ไม่มีแถบว่าง) — ข้อความแถบบนอ่านได้ด้วยเงา .np-canvas::before ด้านล่าง */
    display: block;
    position: absolute;
    top: var(--np-canvas-top);
    left: 0;
    right: 0;
    height: var(--np-canvas-h);
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity .6s ease;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 var(--np-canvas-fade-start), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 var(--np-canvas-fade-start), transparent 100%);
  }
  /* โปร่งแสงเล็กน้อย เพื่อให้สีพื้นหลังที่ขยับ (blob) ลอดผ่านวิดีโอให้เห็น — 1 = ทึบเต็มที่, ยิ่งน้อยยิ่งเห็นสีมาก */
  .lyrics-modal.np-compact.np-canvas-on .np-canvas { opacity: var(--np-canvas-opacity, .75); }

  .np-canvas video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top; /* โชว์จากขอบบนของวิดีโอ (หัว/หน้า) แล้วตัดส่วนล่างแทน */
    background: transparent;
  }
  /* เงาบางๆ ด้านบน ให้ปุ่ม/หัวเรื่องอ่านออกบนวิดีโอสว่าง */
  .np-canvas::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: calc(env(safe-area-inset-top, 0px) + 6.5rem);
    z-index: 1;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, .35) 55%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
  }

  .lyrics-modal.np-compact .lyrics-left img { transition: opacity .5s ease; }
  .lyrics-modal.np-compact.np-canvas-on .lyrics-left img { opacity: 0; box-shadow: none; }
}


/* ============================================================
   Canvas วิดีโอบนคอม (v22)
   - เต็มด้านซ้ายของจอ สูงเต็มหน้าจอ ขอบ "ขวา" ของวิดีโอค่อยๆ จางกลืนกับพื้นหลัง
   - แสดงทั้งหน้า Now Playing ปกติ และหน้าเนื้อเพลงเต็ม (ไม่แสดงในโหมดรถ/คาราโอเกะ)
   - ปรับความกว้าง/จุดเริ่มจางที่ --np-canvas-w และ --np-canvas-fade-start
   ============================================================ */
@media (min-width: 769px) {
  .lyrics-modal:not(.car-mode):not(.karaoke-mode) .np-canvas {
    --np-canvas-w: clamp(420px, 48vw, 960px);
    --np-canvas-fade-start: 38%;
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--np-canvas-w);
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity .6s ease;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 var(--np-canvas-fade-start), transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 var(--np-canvas-fade-start), transparent 100%);
  }
  .lyrics-modal.np-canvas-on:not(.car-mode):not(.karaoke-mode) .np-canvas { opacity: 1; }

  .np-canvas video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top; /* โชว์จากขอบบนของวิดีโอ (หัว/หน้า) แล้วตัดส่วนล่างแทน */
    background: transparent;
  }
  /* เงาบางๆ ด้านบนและด้านซ้าย ให้ปุ่ม/ข้อความอ่านออกบนวิดีโอสว่าง */
  .np-canvas::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
      linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0) 28%),
      linear-gradient(to right, rgba(0, 0, 0, .18), rgba(0, 0, 0, 0));
  }

  /* มีวิดีโอแล้ว ซ่อนปกอัลบั้ม (ยังกินที่เท่าเดิม เลย์เอาต์ไม่ขยับ) */
  .lyrics-modal:not(.car-mode):not(.karaoke-mode) .lyrics-left img { transition: opacity .5s ease; }
  .lyrics-modal.np-canvas-on:not(.car-mode):not(.karaoke-mode) .lyrics-left img { opacity: 0; box-shadow: none; }
}

/* ---------- ป็อปอัพตั้งค่า (เมนูโปรไฟล์ > ตั้งค่า) ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; cursor: pointer; }
.settings-text { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.settings-text strong { font-size: 1rem; font-weight: 600; }
.settings-text small { font-size: .8rem; opacity: .7; line-height: 1.35; }
.settings-switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 46px; height: 28px; border-radius: 999px; margin: 0; cursor: pointer;
  background: rgba(255, 255, 255, .22); transition: background .2s ease;
}
.settings-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .2s ease; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.settings-switch:checked { background: var(--accent, #1db954); }
.settings-switch:checked::after { transform: translateX(18px); }
/* เนื้อเพลงใช้ฟอนต์ Mitr (Cadson Demak) เฉพาะเนื้อเพลง */
am-lyrics, .np-line, .np-card-preview { font-family: 'Mitr', 'Kanit', sans-serif; }
am-lyrics { font-weight: 400; }

/* ซ่อนเมนู "ตั้งค่า Canvas (sp_dc)" */
#menu-canvas-setup { display: none !important; }

/* ============================================================
   RAM Glass — เอฟเฟกต์กระจกเหลว (ตั้งค่า > RAM Glass)
   JS ใส่ data-rg ให้แผงที่เลือก และตั้ง backdrop-filter (url(#filter) หรือโหมดกระจกฝ้า) ให้แผงละตัว
   ============================================================ */
html.rg-on [data-rg] {
  background:
    linear-gradient(rgba(10, 10, 14, var(--rg-dim, .28)), rgba(10, 10, 14, var(--rg-dim, .28))),
    rgba(var(--rg-tint, 255, 255, 255), var(--rg-tint-a, .06)) !important;
  box-shadow:
    inset 0 0 var(--rg-in-blur, 20px) var(--rg-in-spread, -5px) var(--rg-in-color, #fff),
    0 4px var(--rg-out-blur, 24px) rgba(0, 0, 0, .18) !important;
}
/* หน้าเพลง (Now Playing / เนื้อเพลง): ใสกว่าที่อื่น ให้เห็นปก/Canvas ทะลุกระจก */
html.rg-on .lyrics-modal [data-rg] {
  background:
    linear-gradient(rgba(10, 10, 14, .04), rgba(10, 10, 14, .04)),
    rgba(var(--rg-tint, 255, 255, 255), .025) !important;
  box-shadow:
    inset 0 0 16px -4px rgba(255, 255, 255, .55),
    0 4px 20px rgba(0, 0, 0, .12) !important;
}

/* หน้าเพลง: ตอนหยุดเล่น ปกอัลบั้มยุบลงนิดหน่อย พอกดเล่นก็คืนขนาดเดิม (เฉพาะเพลงที่ไม่มี Canvas) */
.lyrics-modal:not(.car-mode):not(.karaoke-mode) .lyrics-left img {
  transition: opacity .5s ease, transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .45s ease;
}
.lyrics-modal.np-paused:not(.np-canvas-on):not(.car-mode):not(.karaoke-mode) .lyrics-left img {
  transform: scale(.9);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .4);
}
@media (prefers-reduced-motion: reduce) {
  .lyrics-modal:not(.car-mode):not(.karaoke-mode) .lyrics-left img { transition: opacity .5s ease; }
}

/* ============================================================
   หน้า Now Playing: ทุกส่วนเป็นกระจกใสแบบหน้าตั้งค่า (RAM Glass) และลดสีขาวให้ไม่รก
   ใช้สูตรเดียวกับแผงตั้งค่า: พื้นมืดจาง + เบลอ + ขอบในจางๆ ไม่มีขอบขาว/พื้นขาวทึบ
   ปรับได้ที่ตัวแปรชุดนี้ที่เดียว
   ============================================================ */
.lyrics-modal.np-compact {
  --np-glass-dim: rgba(10, 10, 14, .22);      /* พื้นมืดจางแบบแผงตั้งค่า */
  --np-glass-tint: rgba(255, 255, 255, .03);  /* ฝ้าขาวบางมาก */
  --np-glass-edge: rgba(255, 255, 255, .14);  /* ขอบในจางๆ (เดิมขาวจัด) */
  --np-glass-blur: 10px;
  --np-ico: rgba(255, 255, 255, .72);         /* ไอคอนรอง: ขาวนวล ไม่จัด */
}
.lyrics-modal.np-compact .lyrics-controls .btn-play,
.lyrics-modal.np-compact .lyrics-controls .btn-play:hover,
.lyrics-modal.np-compact .btn-modal-icon,
.lyrics-modal.np-compact .btn-modal-icon:hover {
  background: linear-gradient(var(--np-glass-dim), var(--np-glass-dim)), var(--np-glass-tint) !important;
  border: none !important;
  box-shadow: inset 0 0 14px -5px var(--np-glass-edge), 0 4px 18px rgba(0, 0, 0, .16) !important;
  backdrop-filter: blur(var(--np-glass-blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--np-glass-blur)) saturate(1.2);
}
/* ปุ่มเล่น/หยุด: ไอคอนขาว แต่ตัวปุ่มไม่ขาว */
.lyrics-modal.np-compact .lyrics-controls .btn-play,
.lyrics-modal.np-compact .lyrics-controls .btn-play svg { color: #fff; }
.lyrics-modal.np-compact .btn-modal-icon { color: var(--np-ico); }
/* ปุ่มรอง: ไม่มีพื้น ไม่มีเงาดำ ไอคอนขาวนวล */
.lyrics-modal.np-compact .lyrics-controls .btn-icon:not(.btn-play),
.lyrics-modal.np-compact .np-actions .btn-icon,
.lyrics-modal.np-compact .np-like {
  background: transparent;
  box-shadow: none;
  color: var(--np-ico);
}
.lyrics-modal.np-compact .lyrics-controls .btn-icon:not(.btn-play):hover,
.lyrics-modal.np-compact .np-actions .btn-icon:hover,
.lyrics-modal.np-compact .np-like:hover { color: #fff; }
.lyrics-modal.np-compact .lyrics-controls .btn-icon svg,
.lyrics-modal.np-compact .np-actions .btn-icon svg,
.lyrics-modal.np-compact .np-like svg { filter: none; }
/* ปุ่มที่เปิดใช้อยู่ (สุ่ม/ซ้ำ/คาราโอเกะ) ใช้สีเขียวแทนสีขาว */
.lyrics-modal.np-compact .lyrics-controls .btn-icon.np-mode-btn[aria-pressed="true"],
.lyrics-modal.np-compact .btn-modal-icon[aria-pressed="true"] { color: var(--accent); }
/* แถบเวลา: เส้นบางลงและสีนวลลง */
.lyrics-modal.np-compact .seek-bar { --seek-fill: rgba(255, 255, 255, .8); --seek-track: rgba(255, 255, 255, .16); }
.lyrics-modal.np-compact .seek-row-lyrics .seek-time { color: rgba(255, 255, 255, .45); }
/* ชื่อศิลปิน/หัวเรื่อง: ลดความขาวจัด */
.lyrics-modal.np-compact .lyrics-track-artist { color: rgba(255, 255, 255, .6); }
.lyrics-modal.np-compact .np-header-label { color: rgba(255, 255, 255, .55); }
/* การ์ดเนื้อเพลง (RAM Glass): ลดขอบสว่างด้านในจาก .55 เหลือ .16 */
html.rg-on .lyrics-modal [data-rg] {
  box-shadow: inset 0 0 16px -5px rgba(255, 255, 255, .16), 0 4px 20px rgba(0, 0, 0, .12) !important;
}
@media (max-width: 768px) {
  .lyrics-modal.np-compact .lyrics-controls .btn-play,
  .lyrics-modal.np-compact .lyrics-controls .btn-play:hover { border-radius: 50%; }
}

/* ===================== Live (ผู้ชมไม่ต้องล็อกอิน) ===================== */
.btn-live {
  display: block;
  margin: 1rem auto 0;
  padding: .85rem 1.6rem;
  background: transparent;
  color: var(--text-main, #fff);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 30px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.btn-live:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .5); }
.live-dot { color: #ff3b30; margin-right: .4rem; }

.live-badge { display: none; position: absolute; top: 16px; left: 16px; z-index: 9; padding: .25rem .7rem; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .8rem; font-weight: 700; letter-spacing: .08em; backdrop-filter: blur(8px); }
html.live-mode .live-badge { display: block; }

/* เพลเยอร์ YouTube: เพลง = กล่องเล็กมุมจอ (YouTube กำหนดขั้นต่ำ 200x200) / ไลฟ์สด = เต็มจอ */
.live-yt-wrap { position: absolute; right: 12px; bottom: 12px; width: 200px; height: 200px; z-index: 6; overflow: hidden; border-radius: 14px; background: #000; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.live-yt-wrap.hidden { display: none; }
.live-yt-wrap iframe { width: 100%; height: 100%; border: 0; }
.live-yt-shield { position: absolute; inset: 0; z-index: 2; }
.lyrics-modal.live-stream .live-yt-wrap { inset: 0; width: auto; height: auto; border-radius: 0; z-index: 8; box-shadow: none; }
@media (max-width: 768px) { .live-yt-wrap { right: 12px; top: 72px; bottom: auto; } }

.live-tap { position: absolute; inset: 0; z-index: 10; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font: inherit; font-size: 1.3rem; font-weight: 600; cursor: pointer; }
.live-tap.hidden, .live-empty.hidden { display: none; }
.live-empty { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .4rem; background: rgba(10, 10, 14, .92); color: #fff; font-size: 1.2rem; }
.live-empty small { color: var(--text-muted, #a0a0a5); font-size: .9rem; }

/* โหมด Live: ไม่มีปุ่มควบคุม/แชร์/เมนู เหลือแค่ปุ่มปิด (ออกจาก Live) และแถบเวลาแบบอ่านอย่างเดียว */
html.live-mode .lyrics-modal-btns > :not(#btn-close-lyrics),
html.live-mode .lyrics-controls,
html.live-mode #btn-np-like,
html.live-mode #btn-karaoke-mode { display: none !important; }
html.live-mode .seek-bar { pointer-events: none; }
html.live-mode .seek-bar::-webkit-slider-thumb { opacity: 0; }
html.live-mode .seek-bar::-moz-range-thumb { opacity: 0; }

/* ============================================================
   ปุ่มในหน้าเนื้อเพลงเต็ม + หน้าเพลงปกติ (Now Playing): กระจกใสแบบล็อก ไม่ต้องเปิด RAM Glass
   ค่าตามเดโม: Blur 0 / Specular 0 / Tint 0% / Shadow 0.40 — พื้นโปร่งใส ไม่มีขอบสว่าง ไม่มีเบลอ
   การหักเหแสง (Thickness 50 / Bezel 60 / IOR 3) ทำใน JS (BG_P) ผ่าน backdrop-filter ของแต่ละปุ่ม
   ============================================================ */
.lyrics-modal:not(.tv-modal) { --lg-shadow: .4; --np-ico: rgba(255, 255, 255, .88); }
.lyrics-modal:not(.tv-modal) .btn-modal-icon:not([aria-pressed="true"]):not(.tv-active),
.lyrics-modal:not(.tv-modal) .btn-modal-icon:not([aria-pressed="true"]):not(.tv-active):hover,
.lyrics-modal.np-compact .btn-modal-icon[aria-pressed="true"],
.lyrics-modal.np-compact .btn-modal-icon[aria-pressed="true"]:hover,
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon,
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:hover,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon:hover,
.lyrics-modal:not(.tv-modal) .np-like,
.lyrics-modal:not(.tv-modal) .np-like:hover {
  background: transparent !important;                                   /* Tint 0% */
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow)) !important;    /* Specular 0 = ไม่มีขอบสว่าง, Shadow 0.40 */
  backdrop-filter: none;                                                /* Blur 0 (JS ใส่ url(#filter) ทับเมื่อเบราว์เซอร์รองรับ) */
  -webkit-backdrop-filter: none;
  border-radius: 50%;                                                   /* Radius = วงกลม */
}
.lyrics-modal:not(.tv-modal) .btn-modal-icon:not([aria-pressed="true"]):not(.tv-active) { color: var(--np-ico); }
.lyrics-modal:not(.tv-modal) .btn-modal-icon:not([aria-pressed="true"]):not(.tv-active):hover { color: #fff; }
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-play,
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-play:hover,
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-play svg { color: #fff; }
/* ไอคอนรอง (สุ่ม/ก่อนหน้า/ถัดไป/ซ้ำ/อุปกรณ์/แชร์/เพิ่มในคลัง): สีขาวนวล */
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play),
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon,
.lyrics-modal:not(.tv-modal) .np-like { color: var(--np-ico); }
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play):not([aria-pressed="true"]):hover,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon:hover,
.lyrics-modal:not(.tv-modal) .np-like:hover { color: #fff; }
.lyrics-modal.np-compact .lyrics-controls .btn-icon.np-mode-btn[aria-pressed="true"] { color: var(--accent); }

/* แถบเวลา: รางเป็นกระจกใส (พื้นโปร่งใส ไม่เบลอ มีเงา + หักเหแสงจาก JS) ส่วนที่เล่นแล้วยังเป็นสีขาว */
.lyrics-modal:not(.tv-modal) .seek-row-lyrics .seek-bar {
  --seek-track: transparent;
  --track-h: 16px;   /* ส่วนที่เล่นแล้ว (สีขาว) สูงเต็มรางกระจก */
  --thumb: 16px;
  height: 16px;
  border-radius: 999px;
  background: transparent !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.lyrics-modal:not(.tv-modal) .seek-row-lyrics .seek-bar::-webkit-slider-runnable-track { box-shadow: none; }

/* ชื่อเพลงยาวเบียดเนื้อเพลง (หน้าเนื้อเพลงเต็ม):
   ชื่อเป็น nowrap (และซ้ำ 2 ชุดสำหรับ marquee) จึงดันความกว้างขั้นต่ำของคอลัมน์ซ้ายให้ใหญ่ขึ้น
   ทำให้คอลัมน์เนื้อเพลงโดนบีบ → ให้คอลัมน์หดได้ และไม่นับความกว้างชื่อเป็นขนาดของคอลัมน์ */
.lyrics-left,
.lyrics-right,
.lyrics-track-details { min-width: 0; }
.lyrics-track-title { min-width: 0; max-width: 100%; contain: inline-size; }

/* แชร์ลงสตอรี่ */
.share-choice { display: flex; flex-direction: column; gap: .7rem; min-width: min(320px, 86vw); }
.share-choice h3 { margin: 0 0 .3rem; }
.story-modal-content { display: flex; flex-direction: column; align-items: center; gap: .8rem; max-width: min(92vw, 420px); }
.story-modal-content h3 { margin: 0; }
.story-preview-wrap { display: flex; justify-content: center; width: 100%; }
#story-preview { height: min(58vh, 560px); width: auto; max-width: 100%; aspect-ratio: 9 / 16; border-radius: 16px; background: #111; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.story-modal-content .rk-actions { width: 100%; }
.story-modal-content .rk-actions button:disabled { opacity: .5; pointer-events: none; }

/* ไอคอนรอง (สุ่ม / ก่อนหน้า / ถัดไป / เล่นซ้ำ / อุปกรณ์ / แชร์): โชว์เฉพาะตัวสัญลักษณ์ ไม่มีวงกลมกระจก/เงารอบปุ่ม */
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play),
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play):hover,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ============================================================
   แก้ UI โหมด Live ที่เพี้ยน
   สาเหตุ: กฎ ".lyrics-modal>*:not(.modal-blobs){position:relative;z-index:1}" (ความเฉพาะเจาะจง 0,2,0)
   ชนะ .live-badge/.live-yt-wrap/.live-tap/.live-empty (0,1,0) ทำให้ position:absolute ของตัว Live ถูกทับเป็น relative
   องค์ประกอบพวกนี้จึงหลุดมาอยู่ในลำดับปกติของ flex column: ป้าย LIVE ยืดเต็มความกว้าง, เพลเยอร์ YouTube 200x200 ดันเลย์เอาต์ลงมาทับชื่อเพลง
   ============================================================ */
.lyrics-modal > .live-badge,
.lyrics-modal > .live-yt-wrap,
.lyrics-modal > .live-tap,
.lyrics-modal > .live-empty { position: absolute; }
.lyrics-modal > .live-badge { z-index: 9; }
.lyrics-modal > .live-yt-wrap { z-index: 6; }
.lyrics-modal > .live-empty { z-index: 7; }
.lyrics-modal > .live-tap { z-index: 10; }
.lyrics-modal.live-stream > .live-yt-wrap { z-index: 8; }

/* ป้าย LIVE: อยู่กึ่งกลางด้านบน ไม่ทับปุ่มย่อ (มือถือโหมดย่อปุ่มอยู่ซ้าย / โหมดเต็มอยู่ขวา) */
html.live-mode .lyrics-modal > .live-badge {
  left: 50%;
  right: auto;
  width: max-content;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 1.4rem + 8px);
  white-space: nowrap;
}
@media (min-width: 769px) {
  html.live-mode .lyrics-modal > .live-badge { top: 2.2rem; }
}

/* Live ไม่มีอัลบั้ม/ปุ่มอุปกรณ์/ปุ่มแชร์: ซ่อนหัวเรื่อง "กำลังเล่นจากอัลบั้ม" (ชื่ออัลบั้มว่าง) กับแถวปุ่มเลือกอุปกรณ์+แชร์ */
html.live-mode .np-header,
html.live-mode .np-actions { display: none !important; }
/* ============================================================
   ตัวสัญลักษณ์รอง (สุ่ม / ก่อนหน้า / ถัดไป / เล่นซ้ำ / อุปกรณ์ / แชร์): ใสเต็มที่ เหลือแต่เงาบางๆ รอบตัวสัญลักษณ์
   ตัวไอคอนโปร่งใส 100% (เห็นพื้นหลังทะลุ) ใช้ฟิลเตอร์ #sym-glass (นิยามใน index.html) วาดเงาเฉพาะ "นอกรูปไอคอน"
   ปรับความเข้มเงาที่ --lg-shadow (ค่าเดียวกับปุ่มควบคุม) หรือแก้ค่าในฟิลเตอร์ใน index.html
   ============================================================ */
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play) svg,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon svg {
  filter: url(#sym-glass);
}
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play),
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon {
  color: #fff; /* ต้องมีสีทึบเพื่อให้ฟิลเตอร์สร้างเงาได้ แล้วฟิลเตอร์จะเจาะตัวไอคอนให้ใสเอง */
}
/* เมาส์ชี้: เงาเข้มขึ้นนิดหน่อย */
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play):hover svg,
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon:hover svg {
  filter: url(#sym-glass-hover);
}
/* ปุ่มที่เปิดใช้อยู่ (สุ่ม/เล่นซ้ำ): ยังเป็นสีเขียวทึบตามเดิม ไม่ใส เพื่อให้รู้ว่าเปิดอยู่ */
.lyrics-modal.np-compact .lyrics-controls .btn-icon.np-mode-btn[aria-pressed="true"] { color: var(--accent); }

/* ชั้นกระจกหักเหแสงรูปตัวสัญลักษณ์ (สร้างโดย app.js: symInit) — ตัดรูปด้วย mask จากไอคอน, มีขอบสว่างบางๆ และหักเหพื้นหลัง */
.lyrics-modal:not(.tv-modal) .lyrics-controls .btn-icon:not(.btn-play),
.lyrics-modal:not(.tv-modal) .np-actions .btn-icon { position: relative; }
.sym-glass-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-position: center; mask-position: center;
}
svg.hidden + .sym-glass-layer { display: none; }
/* ปุ่มที่เปิดใช้อยู่ (สุ่ม/เล่นซ้ำ): เป็นกระจกสีเขียวใส (ขอบเขียว + พื้นเขียวโปร่ง) ยังหักเหพื้นหลังเหมือนเดิม */
.btn-icon[aria-pressed="true"] .sym-glass-layer {
  background-image: var(--sym-rim-g) !important;
  background-color: rgba(29, 185, 84, .34);
}

/* มือถือ: แถบเมนูด้านบน (หน้าแรก / จัดอันดับ / เพลย์ลิสต์) = กระจกใสชุดเดียวกับปุ่ม
   พื้นโปร่งใส ไม่มีเบลอ ไม่มีขอบขาว เหลือเงา Shadow 0.40 (--lg-shadow) ส่วนการหักเหแสงมาจาก JS (BG_P ใน app.js) */
@media (max-width: 768px) {
  .mobile-top-nav {
    background: transparent !important;
    border: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow, .4)) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .top-nav-tabs::before { background: rgba(255, 255, 255, .14); box-shadow: none; }
  .btn-top-icon:hover, .btn-hamburger:hover { background: rgba(255, 255, 255, .08); }

  /* หน้าค้นหา: ช่องค้นหาเดิม sticky top:0 จึงไปซ้อนอยู่ใต้แถบเมนูบน (เห็นเป็นแผ่นมืดโผล่รอบแถบเมนู)
     ให้ไหลต่อจากแถบเมนูตามปกติ ไม่ลอยซ้อน */
  #search-bar-container { position: static; margin: 0 0 1.25rem; }
}

/* ช่องกรอกข้อความ: ตอนเลือกข้อความที่เคยพิมพ์ (autofill) เบราว์เซอร์จะทาพื้นสีฟ้า/เหลืองทับ และตอนเลือกข้อความเป็นสีฟ้าสด
   ปรับให้พื้นโปร่งใสและไฮไลต์เป็นสีขาวจาง ไม่รก */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-main, #fff);
  caret-color: var(--text-main, #fff);
  -webkit-box-shadow: 0 0 0 1000px transparent inset;
  box-shadow: 0 0 0 1000px transparent inset;
  transition: background-color 600000s 0s, color 600000s 0s; /* กันสีพื้น autofill ของ Chrome */
}
input::selection, textarea::selection { background: rgba(255, 255, 255, .22); color: inherit; }

/* ช่องค้นหา: กระจกใสชุดเดียวกับปุ่ม (พื้นโปร่งใส ไม่มีเบลอ ไม่มีขอบขาว เงา 0.40 + หักเหแสงจาก JS) */
#search-bar-container.top-bar {
  background: transparent !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow, .4)) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* มือถือ: แถบเมนูบนอยู่กับที่ (ไม่ลอยตามเวลาเลื่อนลง) เลื่อนหน้าแล้วแถบจะเลื่อนหายไปพร้อมเนื้อหา */
@media (max-width: 768px) {
  .mobile-top-nav { position: relative; top: auto; }
}

/* หน้าศิลปิน: การ์ดผลงานล่าสุด = กระจกใสชุดเดียวกับปุ่ม (พื้นโปร่งใส ไม่มีขอบขาว เงา 0.40 + หักเหแสงจาก JS: app.js > bgInit) */
.artist-release-card,
.artist-release-card:hover,
.artist-release-open {
  background: transparent !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow, .4)) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* หน้าศิลปิน: ชื่อศิลปินเป็นตัวอักษรใส (เห็นรูปด้านหลังทะลุตัวอักษร) มีขอบบางและเงานิดหน่อย
   ปรับความใส: alpha ของ color (น้อย = ใสขึ้น) / ความชัดของขอบ: alpha ของ -webkit-text-stroke */
.artist-hero-content h1 {
  color: rgba(255, 255, 255, .22);
  -webkit-text-stroke: .6px rgba(255, 255, 255, .5);
  text-shadow: 0 4px 10px rgba(0, 0, 0, var(--lg-shadow, .4));
}

/* ============================================================
   แอนิเมชันท้ายเพลง (JS: npEndTick ใส่คลาส np-ending ตอนเหลือ ~4 วินาที)
   Canvas เฟดออก -> ปกอัลบั้มเฟด/ซูมกลับมา, ชื่อเพลงเลื่อนไปเป็นชื่อเพลงถัดไป
   ============================================================ */
.lyrics-modal.np-ending .np-canvas { opacity: 0 !important; transition: opacity 1s ease !important; }
@keyframes np-cover-return { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: scale(1); } }
.lyrics-modal.np-canvas-on.np-ending:not(.np-ending-pair):not(.car-mode):not(.karaoke-mode) .lyrics-left img {
  animation: np-cover-return 1.1s cubic-bezier(.2, .8, .2, 1) both;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.np-swap-inner { display: inline-flex; white-space: nowrap; will-change: transform; }
.np-swap-cur { padding-right: 3rem; }
@media (prefers-reduced-motion: reduce) {
  .lyrics-modal.np-canvas-on.np-ending .lyrics-left img { animation-duration: .01s; }
}

/* รูปแบบที่ 2: ปกเพลงปัจจุบัน + ปกเพลงถัดไปเรียงคู่กัน แล้วปกถัดไปขยายเต็ม */
.np-pair { position: fixed; z-index: 3; pointer-events: none; }
.np-pair img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); will-change: transform, opacity; }
.lyrics-modal.np-ending-pair .lyrics-left img#lyrics-modal-art { opacity: 0 !important; animation: none !important; }
.lyrics-modal > .np-pair { position: fixed; z-index: 3; }


/* แถวเลื่อนแนวนอนบนคอม: ปุ่มลูกศร + ลากด้วยเมาส์ (JS: setupHScroll ใน app.js) */
.h-scroll-wrap { position: relative; min-width: 0; }
.h-scroll-btn {
  position: absolute; top: 70px; z-index: 5; width: 40px; height: 40px; border-radius: 50%;
  display: none; align-items: center; justify-content: center; padding: 0 0 4px;
  border: 1px solid rgba(255, 255, 255, .18); background: rgba(20, 20, 26, .78); color: #fff;
  font: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4); opacity: 0; transition: opacity .2s, transform .2s, background .2s;
}
.h-scroll-btn:hover { background: rgba(60, 60, 70, .9); transform: scale(1.08); }
.h-scroll-left { left: -6px; } .h-scroll-right { right: -6px; }
.history-grid + .h-scroll-btn, .artist-album-row + .h-scroll-btn { top: 60px; }
@media (hover: hover) and (pointer: fine) {
  .h-scroll-wrap.can-left > .h-scroll-left, .h-scroll-wrap.can-right > .h-scroll-right { display: flex; }
  .h-scroll-wrap:hover.can-left > .h-scroll-left, .h-scroll-wrap:hover.can-right > .h-scroll-right { opacity: 1; }
  .h-scroll-wrap > .home-artist-row, .h-scroll-wrap > .home-personalized-row, .h-scroll-wrap > .history-grid, .h-scroll-wrap > .artist-album-row { cursor: grab; }
  .h-scroll-wrap > .is-dragging { cursor: grabbing; scroll-snap-type: none !important; scroll-behavior: auto; }
  .h-scroll-wrap > .is-dragging * { pointer-events: none; }
}
@media (hover: none), (pointer: coarse) { .h-scroll-btn { display: none !important; } }

/* แถบเวลา: ไม่แสดงจุดลาก (thumb) ทุกกรณี — ยังกดข้ามช่วง/ลากได้ตามปกติ */
.seek-bar::-webkit-slider-thumb,
.seek-bar:hover:not(:disabled)::-webkit-slider-thumb,
.seek-bar:active::-webkit-slider-thumb,
.seek-bar:focus-visible::-webkit-slider-thumb { opacity: 0 !important; box-shadow: none !important; }
.seek-bar::-moz-range-thumb,
.seek-bar:hover:not(:disabled)::-moz-range-thumb,
.seek-bar:active::-moz-range-thumb,
.seek-bar:focus-visible::-moz-range-thumb { opacity: 0 !important; box-shadow: none !important; }

/* ปุ่มลูกศรเลื่อนแถว: ตั้งค่าเหมือนช่องค้นหา (#search-bar-container)
   พื้นโปร่งใส ไม่มีขอบขาว ไม่มีเบลอ เหลือเงา Shadow 0.40 (--lg-shadow) ส่วนการหักเหแสงมาจาก JS (BG_P ใน app.js: bgInit) */
.h-scroll-btn,
.h-scroll-btn:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, var(--lg-shadow, .4)) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}


/* ชื่ออัลบั้ม/เพลย์ลิสต์ยาว: บรรทัดเดียว เลื่อนเอา (JS: hMarquee ใน app.js) */
#album-header h1, .developer-sound-details h1 { white-space: nowrap; overflow: hidden; display: block; max-width: 100%; }
#album-header h1 { font-size: clamp(1.5rem, 5vw, 2.5rem) !important; line-height: 1.3; }
.developer-sound-details h1 { line-height: 1.3; }
#album-header > div > div { min-width: 0; flex: 1; }
.h-mq-inner { display: inline-block; white-space: nowrap; will-change: transform; }

/* ---------- โหมดเบาของ Canvas (np-canvas-lite): เปิดอัตโนมัติเมื่อเฟรมวิดีโอหลุดเยอะ — หยุดแอนิเมชันบลอบเท่านั้น
   (ห้ามเปลี่ยน mask-image เป็นการไล่สีทับด้วยสีพื้นตายตัว: พื้นหลังจริงเป็นสีตามอัลบั้ม ขอบวิดีโอจะกลายเป็นเส้นตัดแข็ง) ---------- */
.lyrics-modal.np-canvas-lite .blob { animation-play-state: paused; }

/* ============================================================
   โหมดประหยัดแรงกราฟิก (class np-perf-1/2/3 บน <html> — app.js ปรับให้อัตโนมัติตาม FPS และขนาดจอ)
   1: หยุดแอนิเมชันพื้นหลัง (blob/ambient) + blob เปลี่ยนจาก blur(80px) เป็นไล่สี radial (หน้าตาใกล้เคียง) + กระจกหักเหแบบเบา
   2: ปิด backdrop-filter ทั้งหมดในหน้า Now Playing
   3: ปิดวิดีโอ Canvas (แสดงปกอัลบั้มแทน) — จัดการใน app.js
   ============================================================ */
html.np-perf-1 .blob { filter: none; opacity: 1; }
html.np-perf-1 .blob-1 { width: 75vw; height: 75vw; background: radial-gradient(circle, var(--blob1, rgba(80, 80, 200, .8)) 0%, transparent 68%); }
html.np-perf-1 .blob-2 { width: 70vw; height: 70vw; background: radial-gradient(circle, var(--blob2, rgba(200, 80, 80, .7)) 0%, transparent 68%); }
html.np-perf-1 .blob-3 { width: 52vw; height: 52vw; background: radial-gradient(circle, var(--blob3, rgba(80, 160, 100, .6)) 0%, transparent 68%); }
html.np-perf-1 .blob-4 { width: 58vw; height: 58vw; background: radial-gradient(circle, var(--blob4, rgba(200, 160, 60, .7)) 0%, transparent 68%); }
html.np-perf-1 .blob-5 { width: 64vw; height: 64vw; background: radial-gradient(circle, var(--blob5, rgba(60, 180, 180, .7)) 0%, transparent 68%); }
html.np-perf-1 .blob, html.np-perf-1 .ambient-background { animation: none !important; } /* ตัวที่ได้ผลที่สุดบนจอ 4K: เลิกขยับเลเยอร์ขนาดเกือบเต็มจอทุกเฟรม (วัดแล้ว ~44 -> 60 fps) */
html.np-perf-2 .lyrics-modal *, html.np-perf-2 .lyrics-modal *::before, html.np-perf-2 .lyrics-modal *::after {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}