/* Spotify-style theme for personal.html#music -- active only while
   body.theme-music is set by assets/personal-music.js. */

body.theme-music {
    --sp-bg: #121212;
    --sp-elev: #1f1f1f;
    --sp-row-hover: rgba(255,255,255,0.07);
    --sp-text: #ffffff;
    --sp-sub: #b3b3b3;
    --sp-green: #1ed760;
    --sp-green-hover: #3be477;
    background: #000;
    transition: background-color .3s ease;
}
body.theme-music .gallery-wrap { max-width: 1400px; padding-left: 8px; padding-right: 8px; }
body.theme-music .back-bar a { color: var(--sp-sub); }
body.theme-music .hero-title,
body.theme-music .hero-sub,
body.theme-music #categoryViewTitle,
body.theme-music .category-view-header .view-toggle,
body.theme-music .category-view-header select,
body.theme-music #guessGameSection,
body.theme-music .gallery-section[data-category="music"] { display: none !important; }

body.theme-music .back-to-categories {
    background: rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.12); color: var(--sp-text);
    font-weight: 600;
}
body.theme-music .back-to-categories:hover { background: #fff; color: #000; }
body.theme-music .category-view-header { margin-bottom: 8px; }
/* The old generic "Add New Card" is replaced on Music by "+ เพิ่มเพลง" (Spotify link) -- other categories still use it. */
body.theme-music .pcms-admin-only[onclick="openDraftModal()"] { display: none !important; }

#spotifyView { display: none; }
body.theme-music #spotifyView { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 8px; align-items: start; }


.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------- hero ---------- */
.sp-hero {
    display: flex; align-items: flex-end; gap: 24px;
    padding: 64px 24px 24px;
    background: linear-gradient(180deg, #1c6b3c 0%, #154d2d 55%, var(--sp-bg) 100%);
}
.sp-hero.is-gold { background: linear-gradient(180deg, #a07a1c 0%, #6b5112 50%, var(--sp-bg) 100%); }
.sp-hero.is-playlist { background: linear-gradient(180deg, #4b3a78 0%, #2e2350 55%, var(--sp-bg) 100%); }
.sp-hero.is-artist { background: linear-gradient(180deg, #3a3a3a 0%, #262626 55%, var(--sp-bg) 100%); }
.sp-hero-art {
    flex: 0 0 auto; width: 212px; height: 212px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.55); border-radius: 4px; overflow: hidden; background: #282828;
}
.sp-hero-art.is-round { border-radius: 50%; }
.sp-hero-art > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-mosaic { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.sp-mosaic.is-single { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.sp-mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-art-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3.5rem; color: #7f7f7f; background: #282828; }
.sp-hero-text { min-width: 0; color: var(--sp-text); }
.sp-kicker { font-size: .8rem; font-weight: 600; }
.sp-title {
    font-family: var(--font-head, 'Outfit', 'Mitr', sans-serif); font-weight: 800;
    font-size: clamp(2.2rem, 7vw, 5.4rem); line-height: 1; letter-spacing: -0.04em;
    margin: .3rem 0 .7rem; color: #fff; overflow-wrap: anywhere;
}
.sp-desc { margin: 0 0 .6rem; color: rgba(255,255,255,0.72); font-size: .92rem; }
.sp-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .88rem; color: rgba(255,255,255,0.85); }
.sp-meta img { border-radius: 50%; }
.sp-meta strong { color: #fff; }

/* ---------- action bar ---------- */
.sp-actions { display: flex; align-items: center; gap: 22px; padding: 24px; flex-wrap: wrap; }
.sp-play-big {
    width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--sp-green); color: #000;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3); transition: transform .1s ease, background .15s ease;
}
.sp-play-big:hover { transform: scale(1.05); background: var(--sp-green-hover); }
.sp-play-big:active { transform: scale(0.97); }
.sp-icon-btn {
    background: none; border: 0; color: var(--sp-sub); cursor: pointer; padding: 6px;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    transition: color .15s ease, transform .1s ease;
}
.sp-icon-btn:hover { color: #fff; transform: scale(1.06); }
.sp-play-big:focus-visible, .sp-icon-btn:focus-visible, .sp-row:focus-visible, .sp-info:focus-visible {
    outline: 2px solid #fff; outline-offset: 2px;
}
.sp-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp-search {
    display: flex; align-items: center; gap: 8px; color: var(--sp-sub);
    background: rgba(255,255,255,0.07); border-radius: 4px; padding: 0 10px; height: 34px;
}
.sp-search input {
    background: none; border: 0; outline: none; color: #fff; font: inherit; font-size: .85rem; width: 170px;
}
.sp-search input::placeholder { color: var(--sp-sub); }
.sp-search:focus-within { box-shadow: 0 0 0 1px rgba(255,255,255,0.5); }
.sp-sort select {
    background: #1f1f1f; color: var(--sp-sub); border: 0; font: inherit; font-size: .85rem;
    padding: 0 8px; height: 34px; border-radius: 4px; cursor: pointer; color-scheme: dark;
}
.sp-sort select:hover { color: #fff; }

/* ---------- track list ---------- */
.sp-list-head, .sp-row {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) 150px var(--sp-btns, 40px);
    align-items: center; gap: 12px; padding: 0 12px;
}
.sp-list-head {
    color: var(--sp-sub); font-size: .8rem; height: 36px;
    border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 12px;
}
.sp-list-head span:first-child { text-align: right; }
.sp-list { list-style: none; margin: 0; padding: 0; }
.sp-row { height: 56px; border-radius: 4px; cursor: pointer; color: var(--sp-sub); }
.sp-row:hover { background: var(--sp-row-hover); }
.sp-row.is-playing { background: rgba(255,255,255,0.1); }
.sp-num { position: relative; text-align: right; font-size: .95rem; font-variant-numeric: tabular-nums; display: flex; justify-content: flex-end; }
.sp-hover-play, .sp-eq { display: none; }
.sp-row:hover .sp-idx { display: none; }
.sp-row:hover .sp-hover-play { display: block; color: #fff; }
.sp-row.is-playing .sp-idx, .sp-row.is-playing .sp-hover-play { display: none; }
.sp-row.is-playing .sp-eq { display: inline-flex; }
.sp-eq { gap: 2px; align-items: flex-end; height: 14px; }
.sp-eq i { width: 3px; background: var(--sp-green); animation: sp-eq 0.9s ease-in-out infinite; }
.sp-eq i:nth-child(2) { animation-delay: .2s; }
.sp-eq i:nth-child(3) { animation-delay: .4s; }
@keyframes sp-eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
@media (prefers-reduced-motion: reduce) { .sp-eq i { animation: none; height: 10px; } }

.sp-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sp-cover { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 4px; overflow: hidden; background: #282828; display: flex; align-items: center; justify-content: center; }
.sp-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-cover-emoji { font-size: 1.2rem; }
.sp-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.sp-name { color: #fff; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row.is-playing .sp-name { color: var(--sp-green); }
.sp-artist { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row:hover .sp-artist { color: #fff; }
.sp-artist em { font-style: normal; opacity: .6; }
.sp-badge {
    margin-left: 8px; font-size: .68rem; padding: 1px 6px; border-radius: 3px;
    background: rgba(255,255,255,0.12); color: #fff; vertical-align: 1px;
}
.sp-stars { font-size: .9rem; letter-spacing: 2px; color: rgba(255,255,255,0.18); }
.sp-stars .on { color: var(--sp-green); }
.sp-info {
    background: none; border: 0; color: var(--sp-sub); cursor: pointer; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%; opacity: 0;
}
.sp-row:hover .sp-info, .sp-row:focus-within .sp-info { opacity: 1; }
.sp-info:hover { color: #fff; background: rgba(255,255,255,0.1); }
.sp-empty { color: var(--sp-sub); text-align: center; padding: 2rem 0; }

/* ---------- bottom player ---------- */
#spPlayer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    display: none; align-items: center; gap: 16px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: #000; border-top: 1px solid #282828;
}
#spPlayer.is-open { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
.sp-now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sp-now-cover { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 4px; overflow: hidden; background: #282828; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.sp-now-cover img { width: 100%; height: 100%; object-fit: cover; }
.sp-now-names { display: flex; flex-direction: column; min-width: 0; }
.sp-now-title { color: #fff; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-now-artist { color: var(--sp-sub); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-embed-wrap { min-width: 0; height: 80px; }
.sp-embed-wrap iframe { display: block; border-radius: 12px; }
.sp-playback-status { grid-column: 1 / -1; margin: 0; color: #e6e6e6; font-size: .8rem; line-height: 1.45; }
.sp-directory-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 32px 24px 16px; }
.sp-directory-head h2 { color: #fff; font-size: 2rem; margin: 8px 0; }
.sp-directory-head p, .sp-spotify-panel p { color: #c6c6c6; line-height: 1.6; margin: 8px 0 16px; }
.sp-directory-search { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 24px; color: #fff; }
.sp-directory-search input, .sp-field select { background: #282828; border: 1px solid #747474; color: #fff; padding: 10px; border-radius: 6px; font: inherit; max-width: 100%; }
.sp-directory-search input::placeholder { color: #bdbdbd; }
.sp-artist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; padding: 12px 24px 24px; }
.sp-directory-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border: 1px solid #424242; border-radius: 10px; background: #202020; color: #fff; padding: 16px; text-align: left; cursor: pointer; min-width: 0; }
.sp-directory-card:hover { background: #303030; border-color: #888; }
.sp-directory-card strong { font-size: 1rem; overflow-wrap: anywhere; }
.sp-directory-card > span:not(.sp-directory-art), .sp-directory-card small { color: #c6c6c6; font-size: .8rem; }
.sp-directory-art { display: flex; width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #343434; align-items: center; justify-content: center; font-size: 2rem; }
.sp-directory-art img { width: 100%; height: 100%; object-fit: cover; }
.sp-field { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; color: #fff; }
.sp-pin-field { flex-direction: row; align-items: center; min-height: 44px; }
.sp-pin-field input { width: 20px; height: 20px; accent-color: #1ed760; }
.sp-pop-help { color: #c6c6c6; font-size: .8rem; line-height: 1.6; }
.sp-artist-notice { padding: 12px 24px; border-bottom: 1px solid #555; background: #242424; color: #fff; }
.sp-spotify-panel { margin: 0 24px 24px; padding: 20px; border: 1px solid #4b4b4b; border-radius: 12px; background: #202020; color: #fff; }
.sp-spotify-panel h3 { font-size: 1rem; margin: 0; }
.sp-spotify-panel iframe { border-radius: 12px; display: block; border: 0; }
.sp-catalog-album { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 0; border-bottom: 1px solid #454545; color: #fff; text-decoration: none; }
.sp-catalog-album img { width: 48px; height: 48px; object-fit: cover; }
.sp-catalog-album small { display: block; color: #c6c6c6; margin-top: 5px; }
.sp-catalog-album > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sp-catalog-release { border-bottom: 1px solid #454545; }
.sp-catalog-songs { padding: 8px 0 16px 12px; }
.sp-catalog-song { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: #fff; }
.sp-catalog-song > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sp-catalog-song small { display: block; color: #c6c6c6; font-size: .8rem; margin-top: 6px; }
.sp-catalog-song .sp-icon-btn { min-width: 44px; min-height: 44px; border: 1px solid #666; }
.sp-catalog-song .sp-icon-btn:disabled { opacity: .65; cursor: default; }
.sp-catalog-album a { display: inline-block; padding: 6px 0; font-size: .8rem; }
@media (max-width: 420px) { .sp-catalog-album { flex-wrap: wrap; } .sp-catalog-song { flex-wrap: wrap; } .sp-catalog-song > .sp-ext { margin-left: 56px; } }
.sp-directory-card:focus-visible, .sp-directory-search input:focus-visible, .sp-field select:focus-visible, .sp-text-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sp-text-btn:disabled { opacity: .65; cursor: wait; }
@media (max-width: 720px) {
    .sp-directory-head { flex-direction: column; padding: 24px 16px 8px; }
    .sp-artist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px; gap: 8px; }
    .sp-directory-card { padding: 12px; }
    .sp-spotify-panel { margin: 0 12px 16px; padding: 12px; }
    .sp-playback-status { grid-row: 3; }
    body.sp-player-open { padding-bottom: 200px; }
}
.sp-player-btns { display: flex; gap: 4px; }

@media (max-width: 720px) {
    .sp-hero { flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 64px; }
    .sp-hero-art { width: 168px; height: 168px; align-self: center; }
    .sp-list-head, .sp-row { grid-template-columns: 28px minmax(0, 1fr) var(--sp-btns, 40px); gap: 10px; padding: 0 6px; }
    .sp-col-rating { display: none; }
    .sp-info { opacity: 1; }
    .sp-tools { margin-left: 0; width: 100%; }
    .sp-search { flex: 1; }
    .sp-search input { width: 100%; }
    #spPlayer.is-open { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
    .sp-embed-wrap { grid-column: 1 / -1; grid-row: 2; }
    .sp-now-cover { flex-basis: 40px; width: 40px; height: 40px; }
    body.theme-music.sp-player-open { padding-bottom: 160px; }
}

/* ---------- v2: library sidebar + panels ---------- */
.sp-side, .sp-main { background: var(--sp-bg); border-radius: 8px; }
.sp-main { overflow: hidden; min-width: 0; padding-bottom: 24px; }
.sp-main .sp-list, .sp-main .sp-list-head, .sp-main .sp-empty { margin-left: 16px; margin-right: 16px; }
.sp-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; padding: 12px 8px; }
body.sp-player-open .sp-side { max-height: calc(100vh - 196px); }
.sp-side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 12px; }
.sp-side-title { display: flex; align-items: center; gap: 10px; color: var(--sp-sub); font-weight: 700; font-size: .95rem; }
.sp-new-pl { background: rgba(255,255,255,0.07); width: 32px; height: 32px; }
.sp-chips { display: flex; gap: 8px; padding: 0 8px 10px; flex-wrap: wrap; }
.sp-chip {
    background: rgba(255,255,255,0.07); color: #fff; border: 0; border-radius: 500px;
    padding: 5px 12px; font: inherit; font-size: .8rem; cursor: pointer;
}
.sp-chip:hover { background: rgba(255,255,255,0.12); }
.sp-chip.is-on { background: #fff; color: #000; }
.sp-lib-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
.sp-lib-item {
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; border-radius: 6px;
    background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.sp-lib-item:hover { background: rgba(255,255,255,0.07); }
.sp-lib-item.is-active { background: rgba(255,255,255,0.12); }
.sp-lib-item:focus-visible, .sp-chip:focus-visible, .sp-see-all:focus-visible, .sp-card-play:focus-visible,
.sp-artist-card:focus-visible, .sp-mp-name:focus-visible, .sp-pop-item:focus-visible, .sp-master-pill:focus-visible,
.sp-text-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sp-lib-thumb {
    flex: 0 0 48px; width: 48px; height: 48px; border-radius: 4px; overflow: hidden; background: #282828;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.sp-lib-thumb.is-round { border-radius: 50%; }
.sp-lib-thumb > img { width: 100%; height: 100%; object-fit: cover; }
.sp-lib-thumb .sp-art-empty { font-size: 1.3rem; }
.sp-thumb-liked { background: linear-gradient(135deg, #450af5, #c4efd9); color: #fff; font-size: 1.3rem; }
.sp-thumb-master { background: linear-gradient(135deg, #f5c542, #8a5a00); font-size: 1.35rem; box-shadow: inset 0 0 0 1px rgba(255,230,150,0.5); }
.sp-lib-text { display: flex; flex-direction: column; min-width: 0; }
.sp-lib-name { color: #fff; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-lib-item.is-active .sp-lib-name { color: var(--sp-green); }
.sp-lib-sub { color: var(--sp-sub); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sp-master-pill {
    margin-left: 8px; border: 0; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 700;
    padding: 4px 12px; border-radius: 500px; color: #2a1c00;
    background: linear-gradient(135deg, #ffe08a, #e0a526); box-shadow: 0 0 18px rgba(245,197,66,0.35);
}
.sp-master-pill:hover { filter: brightness(1.08); }
.sp-gold-text { color: #f5c542; font-weight: 600; }
.sp-ext { color: #fff; text-decoration: none; font-weight: 600; }
.sp-ext:hover { text-decoration: underline; }
.sp-hero-art.is-round > .sp-cover-emoji { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 4rem; }
.sp-title[contenteditable] { outline: none; border-radius: 6px; cursor: text; }
.sp-title[contenteditable]:hover, .sp-title[contenteditable]:focus { box-shadow: 0 0 0 1px rgba(255,255,255,0.35); }
.sp-text-btn {
    background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff; border-radius: 500px;
    padding: 6px 14px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.sp-text-btn:hover { border-color: #fff; }
.sp-text-btn.is-danger { background: #e22134; border-color: #e22134; }

/* shelves */
.sp-shelf { padding: 8px 24px 20px; }
.sp-shelf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sp-shelf-title { font-family: var(--font-head, 'Outfit', 'Mitr', sans-serif); font-size: 1.5rem; font-weight: 700; color: #fff; margin: 0; letter-spacing: -0.01em; }
.sp-all-title { padding: 8px 24px 4px; }
.sp-shelf-sub { margin: 2px 0 0; color: var(--sp-sub); font-size: .85rem; }
.sp-see-all { background: none; border: 0; color: var(--sp-sub); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.sp-see-all:hover { color: #fff; text-decoration: underline; }
.sp-shelf-row {
    display: grid; grid-auto-flow: column; grid-auto-columns: 176px; gap: 12px;
    overflow-x: auto; padding: 4px 4px 10px; margin: 0 -4px; scroll-snap-type: x proximity;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sp-mp-card, .sp-artist-card { scroll-snap-align: start; padding: 12px; border-radius: 8px; transition: background .2s ease; min-width: 0; }
.sp-mp-card:hover, .sp-artist-card:hover { background: rgba(255,255,255,0.07); }
.sp-artist-card { cursor: pointer; }
.sp-mp-art, .sp-artist-art { position: relative; aspect-ratio: 1; margin-bottom: 10px; }
.sp-mp-art > img, .sp-artist-art > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-mp-art {
    border-radius: 6px; overflow: hidden; background: #282828;
    box-shadow: 0 0 0 2px #e0a526, 0 8px 24px rgba(245,197,66,0.22);
}
.sp-mp-art .sp-cover-emoji { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 2.5rem; }
.sp-mp-card.is-playing .sp-mp-art { box-shadow: 0 0 0 2px var(--sp-green), 0 8px 24px rgba(30,215,96,0.3); }
.sp-mp-badge {
    position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 500px;
    font-size: .72rem; font-weight: 800; color: #2a1c00; background: linear-gradient(135deg, #ffe08a, #e0a526);
}
.sp-artist-art { border-radius: 50%; overflow: hidden; background: #282828; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.sp-artist-art .sp-cover-emoji { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 2.5rem; }
.sp-card-play {
    position: absolute; right: 8px; bottom: 8px; width: 46px; height: 46px; border-radius: 50%; border: 0;
    background: var(--sp-green); color: #000; cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 8px rgba(0,0,0,0.3); opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.sp-mp-card:hover .sp-card-play, .sp-artist-card:hover .sp-card-play, .sp-card-play:focus-visible { opacity: 1; transform: none; }
.sp-card-play:hover { transform: scale(1.05); background: var(--sp-green-hover); }
.sp-mp-name {
    display: block; width: 100%; background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
    color: #fff; font: inherit; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-mp-name:hover { text-decoration: underline; }
.sp-mp-artist, .sp-artist-sub { color: var(--sp-sub); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-artist-name { color: #fff; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* masterpiece rows in the track list */
.sp-master-tag {
    margin-left: 8px; font-size: .62rem; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 3px;
    color: #2a1c00; background: linear-gradient(135deg, #ffe08a, #e0a526); vertical-align: 2px;
}
.sp-row.is-master .sp-stars .on { color: #f5c542; }
.sp-row-btns { display: flex; justify-content: flex-end; gap: 2px; }

/* add-to-playlist popover */
#spPop {
    position: fixed; z-index: 1200; min-width: 220px; max-width: 280px; max-height: 320px; overflow-y: auto;
    background: #282828; border-radius: 6px; padding: 4px; box-shadow: 0 16px 24px rgba(0,0,0,0.5);
}
.sp-pop-title { color: #b3b3b3; font-size: .78rem; font-weight: 700; padding: 8px 10px 6px; }
.sp-pop-item {
    width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center;
    padding: 9px 10px; border: 0; border-radius: 3px; background: none; color: #eaeaea;
    font: inherit; font-size: .88rem; text-align: left; cursor: pointer;
}
.sp-pop-item:hover { background: rgba(255,255,255,0.1); }
.sp-pop-item.is-on { color: #1ed760; }
.sp-pop-new { border-top: 1px solid rgba(255,255,255,0.1); border-radius: 0 0 3px 3px; margin-top: 2px; }

@media (max-width: 900px) {
    body.theme-music #spotifyView { grid-template-columns: minmax(0, 1fr); }
    .sp-side { position: static; max-height: none; padding: 10px 8px 6px; }
    body.sp-player-open .sp-side { max-height: none; }
    .sp-lib-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
    .sp-lib-list li { flex: 0 0 auto; }
    .sp-lib-item { width: auto; max-width: 220px; background: rgba(255,255,255,0.05); padding: 6px 12px 6px 6px; }
    .sp-lib-thumb { flex-basis: 40px; width: 40px; height: 40px; }
}
@media (max-width: 720px) {
    .sp-hero { padding: 40px 16px 20px; }
    .sp-actions { padding: 20px 16px; }
    .sp-shelf { padding: 4px 16px 16px; }
    .sp-all-title { padding: 4px 16px; }
    .sp-main .sp-list, .sp-main .sp-list-head, .sp-main .sp-empty { margin-left: 8px; margin-right: 8px; }
    .sp-shelf-row { grid-auto-columns: 140px; }
    .sp-card-play { opacity: 1; transform: none; width: 40px; height: 40px; }
    .sp-master-pill { margin-left: 0; }
}

/* ---------- v3: player outside the Music page, favourites, link editor ---------- */
/* The bar now stays up on other categories, where body.theme-music (and its
   --sp-* tokens) isn't set -- so it carries its own copies. */
#spPlayer { --sp-sub: #b3b3b3; --sp-green: #1ed760; --sp-green-hover: #3be477; color: #fff; font-family: var(--font-body, 'Sarabun', sans-serif); }
#spPlayer .sp-icon-btn { background: none; border: 0; color: var(--sp-sub); cursor: pointer; padding: 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
#spPlayer .sp-icon-btn:hover { color: #fff; }
body.sp-player-open { padding-bottom: 104px; }

.sp-artist-link {
    background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
}
.sp-artist-link:hover, .sp-artist-link:focus-visible { color: #fff; text-decoration: underline; outline: none; }
.sp-linkbtn.is-missing { opacity: 1; color: #f5c542; }
.sp-lib-hint .sp-lib-thumb { background: rgba(255,255,255,0.07); color: var(--sp-sub); font-size: 1.4rem; }
.sp-fav-mark { color: var(--sp-sub); font-weight: 700; font-size: .88rem; }
.sp-text-btn.is-on { border-color: var(--sp-green); color: var(--sp-green); }
.sp-text-btn.is-primary { background: #1ed760; border-color: #1ed760; color: #000; }
.sp-text-btn.is-primary:disabled { opacity: .45; cursor: default; }

.sp-pop-form { padding: 4px 8px 8px; width: 300px; max-width: calc(100vw - 40px); box-sizing: border-box; }
.sp-pop-input {
    width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.18);
    background: #121212; color: #fff; font: inherit; font-size: .85rem; outline: none;
}
.sp-pop-input:focus { border-color: #fff; }
.sp-pop-preview { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 8px 0; color: #b3b3b3; font-size: .82rem; }
.sp-pop-preview img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; flex: 0 0 40px; }
.sp-pop-preview img.is-round { border-radius: 50%; }
.sp-pop-preview span { color: #fff; font-size: .88rem; }
.sp-pop-actions { display: flex; justify-content: flex-end; gap: 8px; }
#spPop .sp-text-btn { color: #fff; }
body.admin-mode #spotifyView { --sp-btns: 104px; }
@media (max-width: 720px) { body.sp-player-open { padding-bottom: 160px; } }

/* v4: Favorite People groups inside the favourite-artists shelf */
.sp-group-title { color: #fff; font-size: 1rem; font-weight: 700; margin: 6px 0 4px; }
.sp-group-title span { color: var(--sp-sub); font-weight: 400; font-size: .85rem; margin-left: 4px; }

/* ---------- v6: song categories + song editor ---------- */
.sp-chipbar { display: flex; flex-direction: column; gap: 8px; margin: 4px 16px 14px; }
.sp-chipgroup { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.sp-chipgroup::-webkit-scrollbar { display: none; }
.sp-chipgroup-label { flex: 0 0 auto; color: var(--sp-sub); font-size: .78rem; font-weight: 700; min-width: 88px; }
.sp-chipgroup .sp-chip { flex: 0 0 auto; white-space: nowrap; }
.sp-chip span { opacity: .6; margin-left: 2px; font-size: .75rem; }
.sp-chip.is-on span { opacity: .75; }

.sp-row { height: auto; min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
.sp-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.sp-tags span { font-size: .68rem; line-height: 1.4; padding: 0 6px; border-radius: 3px; background: rgba(255,255,255,0.08); color: var(--sp-sub); white-space: nowrap; }
.sp-editbtn.is-missing { opacity: 1; color: #f5c542; }

.sp-edit-overlay {
    position: fixed; inset: 0; z-index: 1300; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sp-edit-panel {
    width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box;
    background: #282828; color: #fff; border-radius: 8px; padding: 20px 20px 16px; box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    font-family: var(--font-body, 'Sarabun', sans-serif);
    --sp-sub: #b3b3b3; --sp-green: #1ed760;
}
.sp-edit-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.sp-edit-cover { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 4px; overflow: hidden; background: #3e3e3e; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.sp-edit-cover img { width: 100%; height: 100%; object-fit: cover; }
.sp-edit-names { flex: 1; min-width: 0; }
.sp-edit-names h3 { margin: 2px 0 0; font-family: var(--font-head, 'Outfit', 'Mitr', sans-serif); font-size: 1.4rem; line-height: 1.2; overflow-wrap: anywhere; }
.sp-edit-head .sp-icon-btn { color: #b3b3b3; background: none; border: 0; font-size: 1rem; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; }
.sp-edit-head .sp-icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sp-ed-field { display: block; margin-bottom: 14px; }
.sp-ed-field > span { display: block; font-size: .8rem; font-weight: 700; color: #b3b3b3; margin-bottom: 6px; }
.sp-ed-field small { display: block; margin-top: 4px; color: #8a8a8a; font-size: .75rem; }
.sp-ed-field input[type="text"], .sp-ed-field input[type="url"] {
    width: 100%; box-sizing: border-box; padding: 9px 11px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.15);
    background: #121212; color: #fff; font: inherit; font-size: .9rem; outline: none;
}
.sp-ed-field input:focus { border-color: #fff; }
.sp-ed-rate { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sp-ed-star {
    width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.35); font-size: 1.1rem; cursor: pointer;
}
.sp-ed-star.on { color: #f5c542; }
.sp-ed-star.is-zero { font-size: .8rem; font-weight: 700; }
.sp-ed-star:hover { background: rgba(255,255,255,0.14); }
.sp-ed-ratelabel { margin-left: 8px; color: #b3b3b3; font-size: .85rem; }
.sp-ed-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-ed-add input { width: 120px; padding: 5px 10px; border-radius: 500px; border: 1px dashed rgba(255,255,255,0.3); background: none; color: #fff; font: inherit; font-size: .8rem; outline: none; }
.sp-ed-add input:focus { border-style: solid; border-color: #fff; }
.sp-edit-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 6px; padding-top: 14px; }
.sp-edit-grow { flex: 1; }
.sp-edit-panel .sp-text-btn { color: #fff; }
.sp-edit-panel .sp-text-btn.is-primary { color: #000; }
.sp-ed-star:focus-visible, .sp-edit-panel .sp-chip:focus-visible, .sp-edit-panel .sp-text-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 720px) {
    .sp-chipbar { margin: 4px 8px 12px; }
    .sp-chipgroup-label { min-width: 0; }
    .sp-edit-overlay { align-items: flex-end; padding: 0; }
    .sp-edit-panel { max-width: none; border-radius: 12px 12px 0 0; max-height: 88vh; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
    /* Room is tight on phones: the gold MASTERPIECE label becomes a trophy so it never eats the song title. */
    .sp-master-tag { font-size: 0; padding: 0 2px; background: none; margin-left: 4px; }
    .sp-master-tag::before { content: "\1F3C6"; font-size: .8rem; }
}

/* ---------- v7: reorder mode + add song ---------- */
#spMain.is-reordering .sp-tools, #spMain.is-reordering .sp-shelf, #spMain.is-reordering .sp-chipbar { display: none; }
.sp-reorder-hint { margin: 0 16px 10px; padding: 8px 12px; border-radius: 6px; background: rgba(30,215,96,0.1); color: #b8f5cd; font-size: .85rem; }
.sp-row.is-reorder { cursor: default; background: rgba(255,255,255,0.03); margin-bottom: 4px; }
.sp-row.is-reorder:hover { background: rgba(255,255,255,0.06); }
.sp-drag {
    display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 36px;
    color: #b3b3b3; font-size: 1.2rem; cursor: grab; touch-action: none; user-select: none; border-radius: 4px;
}
.sp-drag:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sp-row.is-dragging { background: #333; box-shadow: 0 8px 24px rgba(0,0,0,0.5); opacity: .95; position: relative; z-index: 2; }
.sp-row.is-dragging .sp-drag { cursor: grabbing; color: var(--sp-green); }
.sp-move { opacity: 1; font-size: .8rem; color: #fff; }
.sp-move:disabled { opacity: .25; cursor: default; background: none; }
.sp-move.is-remove { color: #ff8a8a; }
body.admin-mode #spotifyView .sp-row.is-reorder { --sp-btns: 104px; }
.sp-pop-gap { margin-top: 8px; }
#spPop .sp-pop-form .sp-pop-input + .sp-pop-preview + .sp-pop-input { margin-top: 0; }
.sp-row.is-new { animation: sp-new 2.4s ease; }
@keyframes sp-new { 0%, 40% { background: rgba(30,215,96,0.25); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .sp-row.is-new { animation: none; background: rgba(30,215,96,0.15); } }

/* v8: lyrics link in the player bar */
.sp-lyrics-link { color: #b3b3b3; font-size: .78rem; font-weight: 700; text-decoration: none; padding: 6px 8px; border-radius: 500px; white-space: nowrap; align-self: center; }
.sp-lyrics-link:hover, .sp-lyrics-link:focus-visible { color: #fff; background: rgba(255,255,255,0.08); outline: none; }

/* v9: rating inside the add-song form */
#spPop { max-width: 330px; }
.sp-pop-rate-label { color: #b3b3b3; font-size: .78rem; font-weight: 700; margin: 10px 0 6px; }
.sp-pop-rate { margin-bottom: 10px; }
.sp-pop-rate .sp-ed-star { width: 30px; height: 30px; font-size: 1rem; }
#spPop .sp-ed-star { border: 0; background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.35); border-radius: 50%; cursor: pointer; }
#spPop .sp-ed-star.on { color: #f5c542; }
#spPop .sp-ed-star.is-zero { font-size: .75rem; font-weight: 700; }
#spPop .sp-ed-ratelabel { margin-left: 6px; color: #b3b3b3; font-size: .8rem; }
#spPop .sp-ed-star:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#spPop:has(form) { max-height: min(560px, calc(100vh - 24px)); }

/* v11: real flag emoji on Windows. Windows' emoji font has no country flags,
   so e.g. the Japan flag rendered as the letters "JP". This self-hosted font
   covers ONLY flag code points (unicode-range), so it is downloaded only when
   a flag is on screen and never changes other text. Font from
   country-flag-emoji-polyfill@0.1.10 (MIT); flag art: Twemoji, CC-BY 4.0 --
   see assets/fonts/TwemojiCountryFlags-LICENSE.md. No script from that
   package is loaded. */
@font-face {
    font-family: 'Twemoji Country Flags';
    src: url('/assets/fonts/TwemojiCountryFlags.woff2') format('woff2');
    unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E007F;
    font-display: swap;
}
body.theme-music, #spPlayer, .sp-edit-overlay, .sp-edit-panel, #spPop {
    font-family: 'Twemoji Country Flags', var(--font-body, 'Sarabun'), sans-serif;
}
.sp-credit { margin: 18px 16px 0; color: #6f6f6f; font-size: .7rem; }
.sp-credit a { color: inherit; }

/* Status text adds a real third player row; reserve it in all categories. */
body.sp-player-open { padding-bottom: 140px; }
@media (max-width: 720px) { body.sp-player-open, body.theme-music.sp-player-open { padding-bottom: 210px; } }

.sp-fav-mark.is-favourite { color: var(--sp-green); }
.sp-directory-owner { display: flex; flex-wrap: wrap; gap: 10px; }
.sp-directory-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 24px; }
.sp-directory-toolbar .sp-directory-search { padding: 0; flex: 1 1 260px; }
.sp-directory-toolbar .sp-directory-search input { flex: 1; min-width: 100px; }
.sp-directory-sort { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: #ddd; font-size: .85rem; }
.sp-directory-sort select { background: #282828; border: 1px solid #777; border-radius: 6px; color: #fff; padding: 10px; font: inherit; color-scheme: dark; }
.sp-directory-toolbar input, .sp-directory-sort select { min-height: 44px; box-sizing: border-box; }
.sp-artist-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 24px; }
.sp-artist-filter { min-height: 44px; padding: 8px 12px; border: 1px solid #626262; border-radius: 8px; background: #242424; color: #ededed; font: inherit; font-size: .8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.sp-artist-filter span { color: #ccc; font-weight: 700; }
.sp-artist-filter:hover { background: #343434; }
.sp-artist-filter.is-on { border-color: #efce86; background: #463c29; color: #fff0cf; box-shadow: inset 0 -2px #ac8749; }
.sp-directory-count { margin: 12px 24px 0; color: #c6c6c6; font-size: .85rem; }
.sp-directory-card.is-masterpiece { border: 2px solid #c5a15d; background: #29251d; }
.sp-rating-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 6px; font-size: .85rem; font-weight: 700; line-height: 1.45; text-align: left; color: #eee; background: #353535; }
.sp-rating-badge.rating-unrated { color: #ccc; background: #333; font-weight: 500; }
.sp-rating-badge.rating-0 { color: #ffb4bb; background: #4a242b; }
.sp-rating-badge.rating-1 { color: #ffd2a6; background: #4a3027; }
.sp-rating-badge.rating-2 { color: #ffdb9b; background: #463624; }
.sp-rating-badge.rating-3 { color: #efefef; background: #3a3a3a; }
.sp-rating-badge.rating-4 { color: #c0f4d4; background: #234531; }
.sp-rating-badge.rating-5 { color: #241b0d; background: #f2ce79; box-shadow: 0 2px #a87b25; }
.sp-directory-card > .sp-rating-badge { color: #eee; }
.sp-directory-card > .sp-rating-badge.rating-unrated { color: #ccc; }
.sp-directory-card > .sp-rating-badge.rating-0 { color: #ffb4bb; }
.sp-directory-card > .sp-rating-badge.rating-1 { color: #ffd2a6; }
.sp-directory-card > .sp-rating-badge.rating-2 { color: #ffdb9b; }
.sp-directory-card > .sp-rating-badge.rating-4 { color: #c0f4d4; }
.sp-directory-card > .sp-rating-badge.rating-5 { color: #241b0d; }
.sp-artist-members { margin: 0 24px 24px; border: 1px solid #585858; border-radius: 12px; background: #202020; padding: 20px; color: #fff; }
.sp-artist-members h3 { margin: 0; font-size: 1.1rem; }
.sp-artist-members p { color: #c6c6c6; line-height: 1.5; }
.sp-member-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.sp-member-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px; min-width: 140px; max-width: 190px; background: #2b2b2b; border: 1px solid #606060; border-radius: 8px; color: #fff; cursor: pointer; font: inherit; text-align: left; }
.sp-member-face { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; background: #444; font-size: 2rem; }
.sp-member-face img { width: 100%; height: 100%; object-fit: cover; }
.sp-artist-filter:focus-visible, .sp-directory-sort select:focus-visible, .sp-member-card:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width: 720px) { .sp-directory-toolbar { padding: 8px 16px; } .sp-artist-filters { margin: 12px 16px; } .sp-artist-members { margin: 0 12px 16px; padding: 16px; } }
