:root {
    --bg-color: #050505;
    --text-color: #ffffff;
    --accent-color: #ffffff;
    --glass-bg: rgba(0, 0, 0, 0.45);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    -webkit-touch-callout: none;
}

:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8) !important;
    outline-offset: 2px !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--tk-font);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    background: radial-gradient(circle at center, #111111 0%, #000000 100%);
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 30px 40px 30px;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 30px) env(safe-area-inset-bottom, 40px) env(safe-area-inset-left, 30px);
}

body.ios-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    padding: 0;
}

/* Wallpaper Background */
#wallpaper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#wallpaper.visible {
    opacity: 1;
}

/* Video Background */
#bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    z-index: 1;
    opacity: 0;
    pointer-events: auto;
}

#bg-video.visible {
    opacity: 1;
}

/* Loading Indicator */
#loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: auto;
}

#loading-indicator.visible {
    display: flex;
    opacity: 1;
}

.loading-box {
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 30px 50px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#loading-indicator.visible .loading-box {
    transform: scale(1);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loading-indicator span {
    font-size: 1.8vw;
    font-weight: 600;
    letter-spacing: 1px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Status Label */
#status-label {
    display: none;
    /* ซ่อนตามความต้องการ */
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    z-index: 100;
}

/* OSD Configuration */
#osd-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 150;
    align-items: flex-end;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#osd-container.nav-open {
    top: 110px;
}

/* Hide the entire status stack immediately while song information or a song panel is open. */
#osd-container.panel-open {
    visibility: hidden;
    pointer-events: none;
}

.osd-box {
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 12px 25px;
    border-radius: 12px;
    font-size: 1.8vw;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    text-align: right;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: fit-content;
    display: none;
}

.osd-box.visible {
    opacity: 1;
    transform: scale(1);
    display: flex;
    /* Changed from block to flex for multi-line support */
    flex-direction: column;
}

#next-song-osd {
    max-width: 38vw;
    padding: 20px;
    background: var(--tk-glass-mid) padding-box, var(--tk-border-mid) border-box !important;
    text-align: left;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.4;
    font-weight: normal;
}

#next-song-osd .osd-next-label {
    font-size: 0.7em;
    color: var(--tk-gold);
}

#next-song-osd .osd-next-title {
    font-size: 1em;
    color: #fff;
    width: 100%;
    overflow-wrap: anywhere;
}

#next-song-osd .osd-next-artist {
    font-size: 0.7em;
    color: #aaaabb;
    width: 100%;
    overflow-wrap: anywhere;
}

#song-info-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: clamp(10px, 2vw, 25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 15px clamp(20px, 2.5vw, 50px);
    font-size: clamp(19px, 2.8vw, 35px);
    font-weight: 500;
    display: none;
    align-items: center;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

#song-info-bar.visible {
    display: flex;
    opacity: 1;
}

#song-info-bar .info-details {
    flex: 1;
    min-width: 0;
}

#song-info-bar .info-row {
    display: flex;
}

#song-info-bar .info-label {
    flex-shrink: 0;
    opacity: 0.6;
}

#song-info-bar .info-value {
    word-break: break-word;
}

#song-info-bar .info-artist-row {
    margin-top: 6px;
    font-size: 0.75em;
}

#song-info-bar .info-artist-row .info-label,
#song-info-bar .info-artist-row .info-value {
    opacity: 0.6;
}

#song-info-bar .info-time {
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 40px;
    white-space: nowrap;
}

/* Search Box */
#container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    box-sizing: border-box;
    min-height: clamp(80px, 10vw, 110px);
    max-height: 80vh;
    background-color: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: clamp(10px, 2vw, 25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: none;
    overflow: hidden;
    padding-bottom: 15px;
}

.search-row {
    display: flex;
    align-items: center;
    padding: 0 clamp(20px, 2.5vw, 50px);
    min-height: clamp(80px, 10vw, 110px);
    gap: clamp(15px, 2vw, 40px);
    flex-shrink: 0;
}

#autocomplete-list {
    max-height: 30vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: none;
    position: relative;
    border-radius: 0 0 clamp(10px, 2vw, 25px) clamp(10px, 2vw, 25px);
}

#autocomplete-list::-webkit-scrollbar {
    display: none;
}

#autocomplete-list:empty {
    display: none;
}

#ac-count {
    text-align: right;
    padding: 5px clamp(20px, 2.5vw, 50px) 0;
    font-size: clamp(10px, 1.4vw, 18px);
    color: rgba(255, 255, 255, 0.5);
    display: none;
}

#ac-count.visible {
    display: block;
}

#ac-spacer {
    width: 100%;
    position: relative;
}

#ac-viewport {
    position: absolute;
    width: 100%;
}



.autocomplete-item {
    padding: 15px 30px 20px;
    color: #fff;
    font-size: clamp(19px, 2.8vw, 35px);
    font-weight: 500;
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border-radius: 25px;
    margin: 0;
    position: relative;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item .ac-song {
    flex-shrink: 0;
}

.autocomplete-item .ac-artist {
    font-size: 0.75em;
    opacity: 0.6;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.autocomplete-item mark {
    background: none;
    color: inherit;
    text-decoration: underline;
    text-decoration-color: #ff9933;
    text-underline-offset: 4px;
    text-decoration-thickness: 3px;
}

.autocomplete-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
    margin-left: 10px;
    width: calc(100% - 10px);
}

#container.visible {
    opacity: 1;
    pointer-events: auto;
}

#text-window {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    justify-content: flex-start;
    pointer-events: none;
    cursor: pointer;
    height: 100%;
    align-items: center;
}

#container.visible #text-window {
    pointer-events: auto;
}

#typed-text {
    font-size: clamp(24px, 3.5vw, 44px);
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    white-space: pre;
    flex-shrink: 0;
    line-height: 1.6;
    padding-bottom: 5px;
    position: relative;
}

#typed-text.placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

#typed-text::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #ffffff;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

#typed-text.placeholder::after {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Search & Voice Buttons */
#search-btn,
#rec-btn,
#playlist-btn,
#voice-btn,
#kb-btn {
    width: clamp(40px, 5.5vw, 60px);
    height: clamp(40px, 5.5vw, 60px);
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: clamp(8px, 1.2vw, 18px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    z-index: 510;
    pointer-events: none;
    color: #fff;
}

#container.visible #search-btn,
#container.visible #rec-btn,
#container.visible #playlist-btn,
#container.visible #voice-btn,
#container.visible #kb-btn {
    pointer-events: auto;
}

#search-btn:hover,
#rec-btn:hover,
#playlist-btn:hover,
#voice-btn:hover,
#kb-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

#rec-btn.search-row-focused,
#playlist-btn.search-row-focused,
#voice-btn.search-row-focused,
#kb-btn.search-row-focused {
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 0 24px rgba(255, 255, 255, 0.2);
    color: #fff;
}

#search-btn:active,
#rec-btn:active,
#playlist-btn:active,
#voice-btn:active,
#kb-btn:active {
    transform: scale(0.95);
}

#search-btn:focus-visible,
#rec-btn:focus-visible,
#playlist-btn:focus-visible,
#voice-btn:focus-visible,
#kb-btn:focus-visible {
    outline: none !important;
}

#search-btn svg,
#rec-btn svg,
#playlist-btn svg,
#voice-btn svg,
#kb-btn svg {
    width: 55%;
    height: 55%;
    stroke: currentColor;
    fill: none;
}

#keyboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: none;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    padding: 20px;
    box-sizing: border-box;
}

#keyboard-overlay.visible {
    display: flex;
    opacity: 1;
}

.keyboard-inner {
    width: calc(50% - 30px);
    max-width: none;
    background: rgba(20, 20, 20, 0.95);
    border-radius: clamp(10px, 2vw, 25px);
    padding: clamp(10px, 1.5vw, 25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateX(110%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    box-sizing: border-box;
}

#keyboard-overlay.visible .keyboard-inner {
    transform: translateX(0);
}

/* Keyboard-open mode: search panel shrinks to left half; keyboard fills right half.
   Autocomplete area is forced to its full natural height (30vh — same as the default
   max-height) even when there's no query, so the panel doesn't change size between
   "empty" and "has results". The keyboard's height is then synced to match via JS. */
body.kb-open #container {
    right: 50%;
}
/* D-pad focus ring on a virtual key (or the X close button) */
.key.softkb-focused,
#kb-close.softkb-focused {
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}
body.kb-open #autocomplete-list {
    min-height: 30vh;
    max-height: 30vh;
}
body.kb-open #autocomplete-list:empty {
    display: block;
}
/* Hide the keyboard's own input field — typing flows into the main search bar.
   The header itself uses display:contents so the close button (its only remaining child)
   renders as a direct child of .keyboard-inner and can be absolutely positioned. */
.keyboard-header { display: contents; }
#kb-input-container { display: none; }
.keyboard-inner { position: relative; }

/* Close button: small circle floating at top-right corner. The top/right
   offsets use the same clamp as the keyboard-inner's padding-bottom/right,
   so the gap above-and-right of the X equals the gap below-and-right of the
   "Clear" key on the bottom row. */
#kb-close {
    position: absolute;
    top: clamp(14px, 1.6vw, 22px);
    right: clamp(14px, 1.6vw, 22px);
    width: 26px;
    height: 26px;
    min-width: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    padding: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}
#kb-close svg { width: 80%; height: 80%; }
#kb-close:hover {
    background: rgba(255, 50, 50, 0.45);
    border-color: rgba(255, 50, 50, 0.6);
}

/* Half-width keyboard layout.
   Top padding is large enough to clear the close button (top:14 + 26 = 40, plus
   ~12px gap = ~52). Side/bottom padding gives the frame breathing room.
   Keys use flex:1 so they share the row width — no fixed min-width that could
   sum past the container and overflow. Special keys carry a higher flex-grow
   weight so they appear chunkier without breaking the contain guarantee. */
body.kb-open .keyboard-inner {
    padding: clamp(50px, 5vw, 64px) clamp(14px, 1.6vw, 22px) clamp(14px, 1.6vw, 22px);
    display: flex;
    flex-direction: column;
}
/* The keyboard-layout fills the remaining vertical space inside the inner box.
   Its 5 rows split that space equally via flex:1 — so total height never
   overflows regardless of how short or tall the inner box is. */
body.kb-open .keyboard-layout {
    flex: 1 1 auto;
    min-height: 0;
    gap: clamp(4px, 0.6vw, 8px);
    width: 100%;
}
body.kb-open .keyboard-row {
    flex: 1 1 0;
    min-height: 0;
    gap: clamp(3px, 0.5vw, 6px);
    width: 100%;
    align-items: stretch;
}
body.kb-open .key {
    flex: 1 1 0;
    min-width: 0;
    height: auto;          /* let the row's flex stretch decide */
    min-height: 0;
    font-size: clamp(0.9rem, 1.15vw, 1.35rem);
}
body.kb-open .key.backspace,
body.kb-open .key.shift {
    flex: 1.6 1 0;
}
body.kb-open .key.enter,
body.kb-open .key.clear {
    flex: 2 1 0;
}
body.kb-open .key.lang {
    flex: 1.3 1 0;
}
body.kb-open .key.space {
    flex: 5 1 0;
    max-width: none;
}

@media (max-width: 600px) {
    .keyboard-inner {
        width: 100%;
        border-radius: 0;
        padding: 10px;
    }

    /* Side menu scaling */
    #side-menu {
        width: 70%;
        max-width: 260px;
        top: 10px;
        left: 10px;
    }
    #side-menu-name {
        font-size: 18px;
    }
    #side-menu-expire {
        font-size: 14px;
    }
    .side-menu-item {
        font-size: 16px;
        padding: 10px 16px;
        gap: 10px;
    }
    .side-menu-item svg {
        width: 20px;
        height: 20px;
    }
    #side-menu-version {
        font-size: 14px;
    }

    /* Score overlay scaling */
    .score-card {
        width: 85vw;
        max-width: 320px;
        height: 360px;
        padding: 0; /* Remove padding here */
        border-radius: 25px;
    }
    #score-display {
        font-size: 4rem;
    }
}

.keyboard-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    height: clamp(45px, 5.5vw, 65px);
    min-width: clamp(38px, 4.5vw, 55px);
    border-radius: clamp(8px, 1vw, 12px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.9rem, 1.3vw, 1.3rem);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
}

.key:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.92);
    border-color: rgba(255, 255, 255, 0.4);
}

.key.special {
    background: rgba(255, 255, 255, 0.15);
    font-size: 0.9em;
    font-weight: 600;
}

.key.backspace {
    min-width: clamp(70px, 9vw, 100px);
    background: rgba(255, 80, 80, 0.15);
}

.key.shift {
    min-width: clamp(70px, 9vw, 100px);
}

.key.shift.active {
    background: #fff;
    color: #000;
}

.key.enter {
    min-width: clamp(100px, 12vw, 150px);
    background: rgba(255, 255, 255, 0.25);
    font-weight: 700;
}

.key.space {
    flex: 1;
    max-width: 450px;
}

.key.lang {
    min-width: clamp(60px, 7vw, 90px);
    background: rgba(50, 150, 255, 0.2);
}

.key svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

/* Navigation Menu */
/* Side Menu Panel */
#side-menu {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 25%;
    min-width: 280px;
    width: fit-content;
    max-width: 90vw;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: clamp(10px, 2vw, 20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 20px 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    opacity: 0;
    transform: translateX(-20px) scale(0.97);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-family: inherit;
}

#smenu-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 28px;
    height: 28px;
    padding: 4px;
    flex: 0 0 28px;
    background: transparent;
    border: 0;
    border-radius: 50%;
}
#smenu-refresh.smenu-active { background: rgba(255, 255, 255, 0.12); opacity: 1 !important; }

#side-menu.visible {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

#side-menu-user {
    padding: 4px 20px 16px;
}

#side-menu-name {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
    width: max-content;
}

#side-menu-expire {
    font-size: 19px;
    color: #ffffff;
    margin-top: 4px;
}

.side-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.side-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 22px;
    font-family: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    /* Keyboard selection must paint immediately, including direction changes. */
    transition: none;
    outline: none;
}


.side-menu-item svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    stroke: currentColor;
}

/* Keep row labels on a single line — without this, longer text like
   "โหมดการใช้งาน" wraps inside the fixed-width drawer. */
.side-menu-item > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#side-menu-version {
    padding: 8px 20px 0;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.3);
}

.side-menu-toggle-item {
    cursor: default;
}
.side-menu-toggle-item:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
}
.smenu-switch {
    margin-left: auto;
    flex-shrink: 0;
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    cursor: pointer;
}
.smenu-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.smenu-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.25s, border-color 0.25s;
}
.smenu-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: transform 0.25s, background 0.25s;
}
.smenu-switch input:checked + .smenu-switch-track {
    background: rgba(99, 220, 130, 0.5);
    border-color: rgba(99, 220, 130, 0.7);
}
.smenu-switch input:checked + .smenu-switch-track::after {
    transform: translateX(24px);
    background: #ffffff;
}

.side-menu-item.smenu-active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

#nav-menu {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 20px;
    z-index: 610;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#menu-btn {
    margin-right: auto;
}
/* Keep Settings on the left; members have Top Up beside it. */
#nav-menu.has-topup #menu-btn {
    margin-right: 0;
}
#topup-nav-btn {
    margin-right: auto;
}
#nav-menu.display-mode #menu-btn {
    margin-right: 0;
}

#nav-menu.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-item {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(64, 64, 64, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer !important;
}

.nav-item svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    overflow: visible;
}

.nav-item.active {
    background-color: rgba(64, 64, 64, 0.7);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.nav-item.active svg {
    stroke: #ffffff;
    transform: scale(1.1);
}

.nav-inner-text {
    fill: #ffffff;
    stroke: none;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 400;
}

.key-text {
    font-size: 16px;
}

.speed-text {
    font-size: 12.5px;
    letter-spacing: -0.5px;
    font-weight: 600;
}

.vol-text {
    font-size: 10px;
    font-weight: bold;
}

.nav-gap {
    margin-right: 60px;
}

/* Score Overlay Screen */
#score-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

#score-overlay.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.score-card {
    width: 450px;
    height: 500px;
    padding: 0;
    background-color: #111;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.2) inset;
    transform: translateY(30px) scale(0.9);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Back to centered for both shuffling and final */
    align-items: center;
    padding: 0 !important;
}

#score-overlay.visible .score-card {
    transform: translateY(0) scale(1);
}

.score-card-inner {
    background: rgba(0, 0, 0, 0);
    padding: 30px;
    width: 100%;
    height: 100%; /* Ensure it fills the card completely */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Keep text centered within the full area */
    align-items: center;
    box-sizing: border-box;
    transition: background 0.8s ease;
}

.score-card.revealed {
    /* Keep bright score artwork inside the frame, never underneath its translucent border. */
    background-clip: padding-box;
}

.score-card.revealed .score-card-inner {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
}

.score-title {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.8);
}

.score-label {
    color: #d0a51a;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 180, 0, 0.3);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#score-display {
    font-size: 6.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 3px 3px 10px rgba(0, 0, 0, 1);
    line-height: 1;
    margin: 5px 0 10px;
}

/* Particle/Confetti for high scores */
#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
}

/* ── Recommends + My Playlist Panel (share styling, separate state) ─────────── */
#rec-container,
#playlist-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    box-sizing: border-box;
    max-height: 44vh;
    background-color: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: clamp(10px, 2vw, 25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    padding: 15px 30px 10px;
    z-index: 600;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: none;
    gap: 10px;
    overflow: hidden;
}

#rec-container.visible,
#playlist-container.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.rec-header {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    flex-shrink: 0;
}

#rec-back-btn,
#playlist-back-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0;
    width: clamp(25.5px, 3vw, 36px);
    height: clamp(25.5px, 3vw, 36px);
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    flex-shrink: 0;
}
#rec-back-btn:hover, #playlist-back-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; transform: scale(1.08); }
#rec-back-btn:active, #playlist-back-btn:active { transform: scale(0.93); }
#rec-back-btn.rec-header-focused,
#rec-add-all-btn.rec-header-focused,
#playlist-back-btn.rec-header-focused,
#playlist-add-btn.rec-header-focused,
#queue-clear-all-btn.rec-header-focused {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 0 20px rgba(255, 255, 255, 0.15);
}
#rec-back-btn svg, #playlist-back-btn svg { width: clamp(13.5px, 1.65vw, 19.5px); height: clamp(13.5px, 1.65vw, 19.5px); }

#rec-title,
#playlist-title {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.rec-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 40px 6px 20px;
    scrollbar-width: none;
    flex: 1;
    min-height: 0;
}
.rec-list::-webkit-scrollbar { display: none; }

.rec-cat-item,
.rec-song-item {
    padding: 10px 25px;
    color: #fff;
    font-size: clamp(19px, 2.8vw, 35px);
    font-weight: 500;
    line-height: 1.7;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    border-radius: 25px;
    transition: background 0.15s, transform 0.15s;
    user-select: none;
}
.rec-cat-item:active,
.rec-song-item:active {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
}

.rec-cat-item.rec-active,
.rec-song-item.rec-active {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateX(10px);
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.3);
}

.rec-cat-arrow svg { width: .9em; height: .9em; display: block; }

.rec-cat-item .rec-cat-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    line-height: 1;
    margin-left: auto;
    opacity: 0.35;
    font-size: 0.9em;
}

.rec-song-item span.idx {
    font-size: inherit;
    opacity: 0.3;
    font-weight: 900;
    width: 55px;
    flex-shrink: 0;
    text-align: center;
}
.rec-song-item .rec-song-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.rec-song-item .rec-song-text .ac-artist {
    font-size: 0.75em;
    opacity: 0.6;
}

#rec-add-all-btn,
#playlist-add-btn,
#queue-clear-all-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: clamp(12px, 1.4vw, 18px);
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.5px;
}
#rec-add-all-btn:hover, #playlist-add-btn:hover, #queue-clear-all-btn:hover { background: rgba(255, 255, 255, 0.2); }
#rec-add-all-btn:active, #playlist-add-btn:active, #queue-clear-all-btn:active { background: rgba(255, 255, 255, 0.3); transform: scale(0.97); }

#rec-count,
#playlist-count {
    text-align: right;
    padding: 5px 0 0;
    font-size: clamp(10px, 1.4vw, 18px);
    color: rgba(255, 255, 255, 0.5);
    display: none;
    flex-shrink: 0;
}
#rec-count.visible, #playlist-count.visible { display: block; }

#rec-toast,
#playlist-toast {
    position: absolute;
    bottom: 14px;
    right: 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: clamp(13px, 1.5vw, 18px);
    padding: 8px 18px;
    border-radius: 20px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    white-space: nowrap;
}
#rec-toast.show,
#playlist-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Playlist pick modal (popup to select which playlist to add a song to) ── */
#playlist-pick-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.2s;
}
#playlist-pick-modal.visible { display: flex; opacity: 1; }
.pick-card {
    background: var(--glass-bg, rgba(20, 20, 30, 0.95));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
    border-radius: clamp(10px, 2vw, 22px);
    min-width: clamp(280px, 40vw, 480px);
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.pick-title {
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    letter-spacing: 0.5px;
}
.pick-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    /* Cap at ~6 items; shorter on small viewports */
    max-height: min(50vh, 360px);
    scrollbar-width: none;
}
.pick-list::-webkit-scrollbar { display: none; }
.pick-item {
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pick-item:hover,
.pick-item.pick-active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.pick-item .pick-count { opacity: 0.5;  }
.pick-actions {
    display: flex;
}
/* Pick-modal action buttons — neutral white glass (matches .custom-alert-btn).
   No accent on pick-new in ThaiKara; memberships override with their own gradient. */
.pick-actions button {
    flex: 1;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.pick-actions button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}
.pick-actions button:active { transform: scale(0.97); }
.pick-actions button.pick-btn-focused {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 0 20px rgba(255, 255, 255, 0.15);
}

/* ── End Recommends Panel ────────────────────────────────────── */

/* Queue Popup */
#queue-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    box-sizing: border-box;
    min-height: 100px;
    max-height: 44vh;
    background-color: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: clamp(10px, 2vw, 25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    padding: 15px 30px;
    z-index: 600;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: none;
    gap: 10px;
    overflow: hidden;
}

#queue-container.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.queue-header {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.queue-header .queue-title {
    flex: 1;
    margin-bottom: 0;
    border-bottom: 0;
    padding-bottom: 0;
}
.queue-title {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 34vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 40px 10px 20px;
    scrollbar-width: none;
}

.queue-list::-webkit-scrollbar {
    display: none;
}

.queue-item {
    padding: 10px 25px;
    color: #fff;
    font-size: clamp(19px, 2.8vw, 35px);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: opacity 0.2s ease, transform 0.05s ease-out;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border-radius: 25px;
    margin: 0;
    border-bottom: none;
    position: relative;
    will-change: transform;
}

.queue-item:last-child {
    border-bottom: none;
}

.queue-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(10px);
}

.queue-item.dragging {
    background-color: rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 255, 255, 0.3) !important;
    z-index: 10000 !important;
    opacity: 1 !important;
    cursor: grabbing;
    transition: none !important;
    /* Disable transition while dragging for response */
}

.queue-item.swiping-left,
.rec-cat-item.swiping-left,
.rec-song-item.swiping-left {
    box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.3) !important;
}

.queue-item.swipe-removing,
.rec-cat-item.swipe-removing,
.rec-song-item.swipe-removing {
    transition: transform 0.3s ease-in, opacity 0.3s ease-in !important;
    transform: translateX(-110%) !important;
    opacity: 0 !important;
}

.queue-item span.idx {
    font-size: inherit;
    opacity: 0.3;
    font-weight: 900;
    width: 55px;
    flex-shrink: 0;
    text-align: center;
}

.queue-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.queue-text .ac-artist {
    font-size: 0.75em;
    opacity: 0.6;
}

.queue-empty-msg {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.15);
    font-style: italic;
    font-size: 1.6rem;
}

/* Small screen (landscape phone) */
@media (max-height: 500px) {
    body {
        padding: 10px 15px 20px 15px;
    }

    body.ios-fullscreen {
        padding: 0;
    }

    /* Search box */
    #container {
        top: 10px;
        left: 10px;
        right: 10px;
        min-height: clamp(50px, 8vw, 70px);
        padding-bottom: 8px;
        border-radius: clamp(8px, 1.5vw, 16px);
    }

    .search-row {
        padding: 0 clamp(12px, 2vw, 25px);
        min-height: clamp(50px, 8vw, 70px);
        gap: clamp(8px, 1.5vw, 20px);
    }

    #autocomplete-list {
        max-height: 40vh;
    }

    .autocomplete-item {
        padding: 4px 15px;
        font-size: clamp(15px, 2.4vw, 28px);
        gap: 5px;
    }

    #ac-count {
        padding: 3px clamp(12px, 2vw, 25px) 0;
        font-size: clamp(8px, 1.2vw, 14px);
    }

    /* Song info bar */
    #song-info-bar {
        top: 10px;
        left: 10px;
        right: 10px;
        padding: 8px clamp(12px, 2vw, 25px);
        font-size: clamp(15px, 2.4vw, 28px);
        border-radius: clamp(8px, 1.5vw, 16px);
    }

    #song-info-bar .info-artist-row {
        margin-top: 3px;
    }

    #song-info-bar .info-time {
        padding-left: 20px;
    }

    /* Nav buttons */
    #nav-menu {
        top: 15px;
        right: 10px;
        gap: 10px;
    }

    .nav-item {
        width: 46px;
        height: 46px;
    }

    .nav-item svg {
        width: 23px;
        height: 23px;
    }

    .nav-item.active {
        transform: scale(1.15);
    }

    .nav-gap {
        margin-right: 30px;
    }

    .key-text {
        font-size: 17px;
    }

    .speed-text {
        font-size: 15px;
    }

    .vol-text {
        font-size: 12px;
    }

    /* OSD popups */
    #osd-container {
        top: 10px;
        right: 10px;
        gap: 5px;
    }

    #osd-container.nav-open {
        top: 70px;
    }

    .osd-box {
        padding: 6px 14px;
        border-radius: 8px;
        font-size: 1.5vw;
    }

    /* Status label */
    #status-label {
        bottom: 10px;
        left: 10px;
        font-size: 0.6rem;
    }

    /* Recommends + Playlist panels */
    #rec-container,
    #playlist-container {
        top: 10px;
        left: 10px;
        right: 10px;
        padding: 8px 15px 8px;
        gap: 5px;
        border-radius: clamp(8px, 1.5vw, 16px);
    }
    #rec-title, #playlist-title { font-size: 1rem; }
    .rec-list { gap: 3px; }
    .rec-cat-item, .rec-song-item {
        padding: 5px 12px;
        font-size: clamp(15px, 2.4vw, 28px);
        gap: 10px;
    }
    #rec-add-all-btn, #playlist-add-btn, #queue-clear-all-btn { font-size: clamp(11px, 1.3vw, 15px); padding: 5px 12px; }
    #rec-toast, #playlist-toast { font-size: clamp(11px, 1.3vw, 15px); padding: 6px 14px; bottom: 10px; right: 14px; }

    /* Queue popup */
    #queue-container {
        top: 10px;
        left: 10px;
        right: 10px;
        padding: 8px 15px;
        gap: 5px;
        border-radius: clamp(8px, 1.5vw, 16px);
    }

    .queue-title {
        font-size: 1rem;
        margin-bottom: 4px;
        padding-bottom: 4px;
    }

    .queue-list {
        gap: 3px;
    }

    .queue-item {
        padding: 5px 12px;
        font-size: clamp(15px, 2.4vw, 28px);
        gap: 10px;
    }

    .queue-empty-msg {
        padding: 30px 10px;
        font-size: 1rem;
    }

    /* Score overlay */
    .score-card {
        width: 280px;
        height: 320px;
        padding: 0; /* Remove padding here */
        border-radius: 25px;
    }

    /* Side menu scaling */
    #side-menu {
        top: 10px;
        left: 10px;
        width: 250px;
        padding: 10px 0;
    }
    #side-menu-user {
        padding: 2px 15px 10px;
    }
    #side-menu-name {
        font-size: 18px;
    }
    #side-menu-expire {
        font-size: 14px;
    }
    .side-menu-item {
        font-size: 16px;
        padding: 8px 15px;
        gap: 10px;
    }
    .side-menu-item svg {
        width: 20px;
        height: 20px;
    }
    .smenu-switch { width: 42px; height: 24px; }
    .smenu-switch-track::after { width: 16px; height: 16px; }
    .smenu-switch input:checked + .smenu-switch-track::after { transform: translateX(18px); }
    #side-menu-version {
        font-size: 14px;
        padding: 4px 15px 0;
    }

    #score-display {
        font-size: 3.5rem !important;
    }

    .ring-container {
        width: 140px;
        height: 140px;
        margin: 0 auto 15px;
    }

    /* Loading indicator */
    #loading-indicator {
        font-size: 1.6vw;
        gap: 8px;
    }

    /* Typed text */
    #typed-text {
        font-size: clamp(20px, 3vw, 36px);
    }

    /* Voice button smaller */
    #voice-btn {
        width: clamp(32px, 4.4vw, 48px);
        height: clamp(32px, 4.4vw, 48px);
    }

    /* Active item border-radius reduced 40% */
    .autocomplete-item.active {
        border-radius: 15px;
    }

    .queue-item.active {
        border-radius: 15px;
    }
}

/* Account Info Widget */
#account-info-widget {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 12px 18px;
    color: #ffffff;
    font-family: inherit;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    gap: 15px;
    pointer-events: auto; /* Enable touch/click for logout button */
    text-align: left;
    transition: opacity 0.3s;
}

#account-info-widget.visible {
    display: flex;
}

#acc-name {
    font-weight: 800;
    font-size: 16px;
    color: #ffffff;
    margin-bottom: 8px;
}

#acc-expire {
    font-weight: 600;
    font-size: 13px;
    color: #aaaaaa;
}

#logout-btn, #topup-btn, #lang-btn {
    background: transparent;
    border: none;
    border-radius: 0;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

#logout-btn:hover, #topup-btn:hover, #lang-btn:hover {
    color: #ffffff;
    transform: scale(1.15);
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

#logout-btn svg, #topup-btn svg, #lang-btn svg {
    width: 28px;
    height: 28px;
}

.lang-option {
    display: block;
    width: 100%;
    padding: 9px 16px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.lang-option:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}


/* Collection lists share search row geometry; headers retain their compact spacing. */
#rec-container, #queue-container { padding: 15px 0; gap: 0; max-height: 80vh; }
#rec-container .rec-header, #queue-container .queue-header { min-height: 0; padding: 0 clamp(20px, 2.5vw, 50px) 8px; margin-bottom: 0; gap: 20px; }
#rec-container .rec-list, #queue-container .queue-list { margin: 15px 0; padding: 0 clamp(20px, 2.5vw, 50px) 0 20px; gap: 0; max-height: 30vh; }
#rec-container .rec-cat-item, #rec-container .rec-song-item, #queue-container .queue-item { margin: 0; padding: 15px 30px 20px; line-height: normal; gap: 8px; height: 78px; flex-shrink: 0; box-sizing: border-box; }
@media (max-height: 500px) {
    #rec-container, #queue-container { padding: 8px 0; }
    #rec-container .rec-header, #queue-container .queue-header { padding-right: clamp(12px, 2vw, 25px); padding-left: clamp(12px, 2vw, 25px); }
    #rec-container .rec-list, #queue-container .queue-list { padding-right: clamp(12px, 2vw, 25px); max-height: 40vh; }
    #rec-container .rec-cat-item, #rec-container .rec-song-item, #queue-container .queue-item { padding: 4px 15px; gap: 5px; height: 40px; }
}
