/* ===== VARIABLES ===== */
:root {
    --mau-nen: #168cff;
    --mau-nen-2: #7b4fff;
    --transition-color: 0.8s ease;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

button {
    touch-action: manipulation;
}

body {
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Noto Sans", "Segoe UI", Arial, sans-serif;
    color: white;
    background: #0d0d14;
    -webkit-overflow-scrolling: touch;
}

/* ===== BACKGROUND LAYERS ===== */

#bg-video {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -3;
    opacity: 0.55;
    transition: opacity 1s ease;
    transform: translateZ(0);
    will-change: transform;
}

/* Khi ẩn tab: đóng băng toàn bộ animation & render nền để CPU/GPU = 0% */
body.tab-an * {
    animation-play-state: paused !important;
}

body.tab-an #bg-video {
    visibility: hidden !important;
}

.lop-toi {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(0, 0, 0, 0.5) 0%,
        rgba(0, 0, 0, 0.65) 100%
    );
    z-index: -1;
}

#anh-nen {
    position: fixed;
    inset: -30px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(20px) saturate(1.3);
    transform: scale(1.05) translateZ(0);
    opacity: 0;
    transition: opacity 0.8s ease, background-image 0.8s ease;
    z-index: -2;
    pointer-events: none;
    will-change: opacity, transform;
}

/* ===== CHẾ ĐỘ SIÊU NHẸ (TIẾT KIỆM CPU CHO MÁY YẾU / INTEL HD GRAPHICS) ===== */
body.che-do-nhe #bg-video {
    display: none !important;
}

body.che-do-nhe #anh-nen {
    filter: none !important;
    transform: none !important;
    background-image: none !important;
    background: radial-gradient(circle at 50% 25%, var(--mau-nen, #168cff), #0d0d14 65%) !important;
    opacity: 0.2 !important;
}

body.che-do-nhe .cover-wrap::before {
    display: none !important;
}

body.che-do-nhe .cover-inner {
    animation: none !important;
    transform: none !important;
}

body.che-do-nhe .eq-bar {
    animation: none !important;
    transform: none !important;
    height: 12px !important;
}

body.che-do-nhe .music-player {
    background: #141422 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body.che-do-nhe .playlist-panel {
    background: #101018 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ===== MAIN PLAYER ===== */

.noi-dung {
    position: relative;
    width: min(520px, calc(100vw - 32px));
    margin: 0 auto;
    padding-top: 6vh;
    padding-bottom: 24px;
    text-align: center;
    color: white;
    transition: transform 0.35s ease;
}

h1 {
    margin: 0 0 2px;
    font-family: "Noto Serif", "Noto Sans", serif;
    font-size: clamp(28px, 5vw, 42px);
    letter-spacing: 0.03em;
    background: linear-gradient(135deg, #fff 40%, rgba(255,255,255,0.55));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.subtitle {
    margin: 4px 0 20px;
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.5;
}

/* ===== COVER ART ===== */

.cover-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    aspect-ratio: 1;
    margin: 0 auto 20px;
    border-radius: 22px;
    overflow: visible;
    transition: transform 0.4s ease, border-radius 0.4s ease;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.55),
        0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Glow ring xung quanh ảnh bìa — màu theo album art */
.cover-wrap::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 28px;
    background: radial-gradient(ellipse, var(--mau-nen), var(--mau-nen-2, #7b4fff));
    opacity: 0;
    filter: blur(16px);
    transition: opacity 0.8s ease;
    z-index: -1;
    transform: translateZ(0);
}

/* Hiện glow khi đang phát */
body.dang-phat .cover-wrap::before {
    opacity: 0.6;
}

.cover-inner {
    width: 100%;
    height: 100%;
    border-radius: 22px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    transform: translateZ(0);
}

#anhBia {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease, opacity 0.4s ease;
}

.cover-wrap:hover #anhBia {
    transform: scale(1.04);
}

/* Xoay ảnh bìa kiểu vinyl khi đang phát (chỉ xoay .cover-inner, giữ glow cố định) */
body.dang-phat .cover-wrap {
    border-radius: 50%;
}

body.dang-phat .cover-wrap::before {
    border-radius: 50%;
}

body.dang-phat .cover-inner {
    border-radius: 50%;
    animation: vinylSpin 18s linear infinite;
    will-change: transform;
}

body.dang-phat #anhBia {
    border-radius: 50%;
}

@keyframes vinylSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Dừng xoay khi pause */
body:not(.dang-phat) .cover-inner {
    animation-play-state: paused;
}

/* ===== TÊN BÀI HÁT — MARQUEE khi quá dài ===== */

#tenNhac {
    width: min(500px, 90vw);
    margin: 0 auto 16px;
    overflow: hidden;
    line-height: 1.4;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
}

.title-song {
    display: block;
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease;
}

/* Marquee scroll khi tên dài */
.title-song.scroll-text {
    display: inline-block;
    min-width: 100%;
    width: max-content;
    overflow: visible;
    text-overflow: clip;
    text-align: left;
    padding-right: 24px;
    animation: marqueeScroll 12s linear infinite;
}

@keyframes marqueeScroll {
    0%, 15%  { transform: translateX(0); }
    55%, 70% { transform: translateX(var(--marquee-dist, -40%)); }
    100%     { transform: translateX(0); }
}

.artist-song {
    display: block;
    margin-top: 5px;
    font-size: 14px;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

/* Hiệu ứng chuyển bài — fade out rồi fade in */
#tenNhac.dang-chuyen {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#tenNhac {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ===== EQUALIZER BARS (chỉ hiện khi đang phát) ===== */

.eq-bars {
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 18px;
    margin-bottom: 10px;
}

body.dang-phat .eq-bars {
    display: flex;
}

.eq-bar {
    width: 3px;
    background: var(--mau-nen, #168cff);
    border-radius: 2px;
    animation: eqBounce 0.8s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { animation-duration: 0.6s; animation-delay: 0s;    height: 10px; }
.eq-bar:nth-child(2) { animation-duration: 0.9s; animation-delay: 0.1s;  height: 18px; }
.eq-bar:nth-child(3) { animation-duration: 0.7s; animation-delay: 0.2s;  height: 14px; }
.eq-bar:nth-child(4) { animation-duration: 1.0s; animation-delay: 0.05s; height: 18px; }
.eq-bar:nth-child(5) { animation-duration: 0.65s; animation-delay: 0.15s; height: 10px; }

@keyframes eqBounce {
    from { transform: scaleY(0.25); opacity: 0.7; }
    to   { transform: scaleY(1);    opacity: 1;   }
}

/* ===== PLAYER CONTROLS ===== */

.music-player {
    position: relative;
    width: min(460px, 92vw);
    margin: 0 auto 12px;
    padding: 18px 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-radius: 24px;
    background: rgba(18, 18, 28, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

/* Viền sáng theo màu album khi đang phát */
body.dang-phat .music-player {
    border-color: rgba(255,255,255,0.2);
    box-shadow:
        0 8px 40px rgba(0,0,0,0.3),
        0 0 0 1px var(--mau-nen, #168cff) inset;
}

.main-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* ===== BUTTONS ===== */

.nut {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 4px;
    min-height: 40px;
    padding: 9px 18px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.18s ease, background 0.18s ease,
                box-shadow 0.18s ease, border-color 0.18s ease;
}

.nut:hover {
    transform: translateY(-2px) scale(1.03);
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 8px 20px rgba(0, 0, 0, 0.3),
        0 0 12px var(--mau-nen, #168cff44);
}

.nut:active {
    transform: scale(0.97);
}

.control-btn {
    width: 48px;
    height: 44px;
    min-width: 48px;
    margin: 0;
    padding: 0;
    font-size: 17px;
    border-radius: 50%;
}

.play-btn {
    width: 110px;
    height: 48px;
    min-width: 110px;
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 600;
    border-radius: 40px;
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.3);
    letter-spacing: 0.03em;
}

body.dang-phat .play-btn {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--mau-nen, #168cff) 60%, #111),
        color-mix(in srgb, var(--mau-nen-2, #7b4fff) 60%, #111)
    );
    border-color: rgba(255,255,255,0.12);
    color: rgba(255, 255, 255, 0.85);
    box-shadow:
        0 4px 18px rgba(0,0,0,0.3),
        0 0 10px var(--mau-nen, #168cff33);
}

/* Nút random khi bật */
.control-btn.random-on {
    background: rgba(255,255,255,0.22);
    border-color: var(--mau-nen, #168cff);
    box-shadow: 0 0 10px var(--mau-nen, #168cff55);
}

/* Nút loop khi đổi chế độ */
.control-btn.loop-active {
    background: rgba(255,255,255,0.22);
    border-color: var(--mau-nen, #168cff);
    box-shadow: 0 0 10px var(--mau-nen, #168cff55);
}
.control-btn.loop-one {
    background: rgba(251, 191, 36, 0.25) !important;
    border-color: rgba(251, 191, 36, 0.6) !important;
    color: #fde68a !important;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.35) !important;
}
.control-btn.loop-off {
    opacity: 0.45;
}

/* ===== SEEK BAR ===== */

.time-row {
    width: 100%;
    margin: 10px 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.time-label {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    opacity: 0.55;
    white-space: nowrap;
    min-width: 34px;
}

.time-label.right {
    text-align: right;
}

/* Custom seekbar wrapper */
.seekbar-wrap {
    flex: 1;
    position: relative;
    height: 18px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Track */
.seekbar-wrap::before {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
}

/* Progress fill — dùng scaleX cho GPU compositor không gây reflow */
#seekProgress {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--mau-nen, #168cff), var(--mau-nen-2, #7b4fff));
    pointer-events: none;
    transform-origin: left center;
    transform: scaleX(0);
    will-change: transform;
    box-shadow: 0 0 8px var(--mau-nen, #168cff66);
}

#thanhNhac {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    padding: 0;
    accent-color: var(--mau-nen, #168cff);
    touch-action: manipulation;
}

/* ===== VOLUME BAR ===== */
.volume-row {
    width: 100%;
    margin: 4px 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.mute-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 15px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.75;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mute-btn:hover {
    opacity: 1;
    transform: scale(1.12);
}
.volumebar-wrap {
    position: relative;
    width: 120px;
    height: 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.volumebar-wrap::before {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
}
#volumeProgress {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--mau-nen, #168cff), var(--mau-nen-2, #7b4fff));
    pointer-events: none;
    transform-origin: left center;
    transform: scaleX(1);
    box-shadow: 0 0 6px var(--mau-nen, #168cff55);
}
#volumeSlider {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    padding: 0;
    touch-action: manipulation;
}
.volume-label {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    opacity: 0.55;
    min-width: 34px;
    text-align: left;
}

/* ===== PLAYLIST BUTTON + LINK ===== */

.playlist-bottom {
    margin-top: 2px;
}

/* ===== PLAYLIST PANEL ===== */

.playlist-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(380px, 92vw);
    height: 100vh;
    height: 100dvh;
    z-index: 600;
    display: flex;
    flex-direction: column;
    padding: 20px 16px 16px;
    background: rgba(10, 10, 18, 0.82);
    border-left: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: -20px 0 60px rgba(0,0,0,0.4);
    transform: translateX(105%);
    transition: transform 0.38s cubic-bezier(.2,.8,.2,1);
}

.playlist-panel.open {
    transform: translateX(0);
}

.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.playlist-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.playlist-count {
    margin-top: 3px;
    font-size: 12px;
    opacity: 0.5;
}

.close-playlist {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    color: white;
    background: rgba(255,255,255,0.1);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-playlist:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

/* Playlist Search */
.playlist-search-wrap {
    position: relative;
    margin: 12px 0 10px;
    display: flex;
    align-items: center;
}

.playlist-search-input {
    width: 100%;
    padding: 9px 34px 9px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.playlist-search-input:focus {
    border-color: var(--mau-nen, #168cff);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 10px var(--mau-nen, #168cff44);
}

.playlist-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.playlist-search-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.playlist-search-clear:hover {
    color: white;
}

.playlist {
    flex: 1;
    min-height: 0;
    margin-top: 4px;
    overflow-y: auto;
    padding-right: 4px;
    contain: content;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.playlist::-webkit-scrollbar {
    width: 4px;
}

.playlist::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.playlist-item {
    width: 100%;
    display: grid;
    grid-template-columns: 26px 46px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    padding: 8px 8px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: white;
    text-align: left;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    content-visibility: auto;
    contain-intrinsic-size: 0 54px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.playlist-item:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.08);
    transform: translateX(2px);
}

.playlist-item.active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.18);
    box-shadow:
        inset 4px 0 0 var(--mau-nen, #168cff),
        0 2px 12px rgba(0,0,0,0.2);
}

.playlist-number {
    text-align: center;
    font-size: 11px;
    opacity: 0.4;
    font-variant-numeric: tabular-nums;
}

.playlist-item.active .playlist-number {
    color: var(--mau-nen, #168cff);
    opacity: 1;
}

.playlist-cover {
    position: relative;
    width: 46px;
    height: 46px;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(255,255,255,0.07);
    flex-shrink: 0;
    transition: border-radius 0.3s ease;
}

/* Ảnh bìa trong playlist hình tròn khi đang active */
.playlist-item.active .playlist-cover {
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--mau-nen, #168cff);
}

.playlist-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.playlist-cover img:not([src]) {
    opacity: 0;
}

.mini-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.18s ease;
    font-size: 13px;
}

.playlist-item:hover .mini-play,
.playlist-item.active .mini-play {
    opacity: 1;
}

.playlist-info {
    min-width: 0;
}

.playlist-song-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.3s ease;
}

.playlist-item.active .playlist-song-title {
    color: var(--mau-nen, #168cff);
}

.playlist-artist {
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    opacity: 0.5;
}

/* ===== CATEGORY HEADER ===== */

.playlist-category-header {
    margin: 14px 4px 5px;
    padding: 3px 2px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mau-nen, rgba(255,255,255,0.4));
    opacity: 0.7;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: color 0.6s ease;
}

.playlist-category-header:first-child {
    margin-top: 2px;
}

/* ===== LAPTOP / SHORT VIEWPORT ===== */

@media (max-height: 740px) and (min-width: 601px) {
    .noi-dung {
        padding-top: 3vh;
    }

    .subtitle {
        margin: 2px 0 14px;
    }

    .cover-wrap {
        width: 168px;
        height: 168px;
        margin-bottom: 14px;
    }
}

/* ===== MOBILE ===== */

@media (max-width: 600px) {
    .noi-dung {
        padding-top: max(4vh, env(safe-area-inset-top, 0px));
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .cover-wrap {
        width: 160px;
        height: 160px;
    }

    h1 {
        font-size: 28px;
    }

    .playlist-panel {
        width: 96vw;
        padding-top: calc(18px + env(safe-area-inset-top, 0px));
        padding-bottom: env(safe-area-inset-bottom, 16px);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    #anh-nen {
        filter: blur(30px) saturate(1.2);
    }

    .music-player {
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .control-btn,
    .play-btn {
        min-height: 46px;
    }

    .play-btn {
        width: 100px;
        height: 46px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }
}

/* ===== TIME DISPLAY ===== */

#thoiLuong {
    display: none; /* Đã thay bằng .time-label bên trái/phải thanh nhạc */
}

/* ===== SPLASH — LOGO ===== */

#splash-hades {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 40% 40%, #1a1a2e 0%, #0a0a0f 55%, #000 100%);
    animation: splashBienMat 0.7s ease 2.6s forwards;
}

/* Logo container */
.splash-logo {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: splashLogoVao 0.7s cubic-bezier(.22,1,.36,1) 0.2s both;
}

@keyframes splashLogoVao {
    0%   { opacity: 0; transform: scale(0.7) translateY(20px); }
    100% { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Icon */
.splash-logo-img {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    box-shadow:
        0 8px 40px rgba(0,0,0,0.5),
        0 0 0 1px rgba(255,255,255,0.1);
    animation: splashIconPulse 1.8s ease 0.9s infinite alternate;
}

@keyframes splashIconPulse {
    from { box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1); }
    to   { box-shadow: 0 8px 60px rgba(120,80,255,0.45), 0 0 0 1px rgba(255,255,255,0.18); }
}

/* App name */
.splash-logo-name {
    font-family: "Noto Serif", serif;
    font-size: clamp(26px, 6vw, 38px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    animation: splashTextVao 0.6s ease 0.5s both;
}

/* Tagline */
.splash-logo-sub {
    font-size: 13px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    animation: splashTextVao 0.6s ease 0.7s both;
}

@keyframes splashTextVao {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes splashBienMat {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* ===== ECO BUTTON STATUS STYLES ===== */
#ecoBtn.eco-bat {
    background: rgba(34, 197, 94, 0.22) !important;
    border-color: #22c55e !important;
    color: #4ade80 !important;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.35) !important;
}

#ecoBtn.eco-tat {
    background: rgba(168, 85, 247, 0.22) !important;
    border-color: #a855f7 !important;
    color: #d8b4fe !important;
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.35) !important;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    inset: auto auto calc(20px + env(safe-area-inset-bottom, 0px)) 50%;
    margin: 0;
    width: max-content;
    max-width: min(440px, calc(100vw - 32px));
    transform: translateX(-50%) translateY(20px);
    padding: 12px 20px;
    border-radius: 24px;
    background: rgba(15, 15, 25, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28), display 0.3s ease;
    transition-behavior: allow-discrete;
    z-index: 99999;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    white-space: normal;
    word-break: break-word;
}

.toast[popover]:not(:popover-open):not(.show) {
    display: none;
}

.toast:is(.show, :popover-open) {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@starting-style {
    .toast:is(.show, :popover-open) {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}


/* ===== SLEEP TIMER ===== */

/* Cố định góc trái trên */
.sleep-timer-wrap {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 500;
}

/* Nút icon nhỏ gọn */
#sleepBtn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 18px;
    border-radius: 50%;
    background: rgba(15, 15, 28, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    transition: transform 0.18s ease, background 0.18s ease,
                border-color 0.18s ease, box-shadow 0.18s ease,
                width 0.3s cubic-bezier(.22,1,.36,1),
                border-radius 0.3s ease, font-size 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

/* Khi đang đếm ngược: mở rộng ra để hiện thời gian */
#sleepBtn.sleep-active {
    width: auto;
    min-width: 40px;
    padding: 0 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(251, 191, 36, 0.2) !important;
    border-color: rgba(251, 191, 36, 0.6) !important;
    color: #fde68a !important;
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.3) !important;
}

#sleepBtn:hover {
    transform: scale(1.08);
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.3);
}

/* Nhấp nháy khi còn dưới 60s */
#sleepBtn.sleep-urgent {
    animation: sleepUrge 0.9s ease-in-out infinite alternate;
}

@keyframes sleepUrge {
    from { box-shadow: 0 0 10px rgba(251,191,36,0.25); border-color: rgba(251,191,36,0.5); }
    to   { box-shadow: 0 0 24px rgba(239,68,68,0.6);   border-color: rgba(239,68,68,0.8);
           color: #fca5a5; }
}

/* Popup menu — mở xuống (dưới nút) */
.sleep-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 180px;
    background: rgba(10, 10, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    z-index: 200;
    animation: sleepMenuVao 0.18s cubic-bezier(.22,1,.36,1) both;
}

.sleep-menu[hidden] { display: none; }

@keyframes sleepMenuVao {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.sleep-menu-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    text-align: center;
    padding: 2px 0 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 2px;
}

.sleep-option {
    width: 100%;
    padding: 9px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    border-radius: 11px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.sleep-option:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.16);
    transform: translateX(3px);
}

.sleep-option:active { transform: scale(0.97); }

/* Hàng nhập tùy chỉnh */
.sleep-custom-wrap {
    display: flex;
    gap: 6px;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sleep-custom-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    /* Xóa mũi tên spin của input number */
    -moz-appearance: textfield;
}

.sleep-custom-input::-webkit-inner-spin-button,
.sleep-custom-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.sleep-custom-input::placeholder { color: rgba(255,255,255,0.3); }

.sleep-custom-input:focus {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.11);
}

.sleep-custom-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    background: rgba(34,197,94,0.2);
    border: 1px solid rgba(34,197,94,0.45);
    border-radius: 10px;
    color: #86efac;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.sleep-custom-btn:hover { background: rgba(34,197,94,0.35); }
.sleep-custom-btn:active { transform: scale(0.94); }

/* Nút hủy */
.sleep-cancel {
    width: 100%;
    margin-top: 4px;
    padding: 9px 14px;
    background: rgba(239,68,68,0.14);
    border: 1px solid rgba(239,68,68,0.35);
    border-radius: 11px;
    color: #fca5a5;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, transform 0.1s ease;
}

.sleep-cancel:hover { background: rgba(239,68,68,0.28); }
.sleep-cancel:active { transform: scale(0.97); }

/* Safe area cho iPhone notch */
@supports (top: env(safe-area-inset-top)) {
    .sleep-timer-wrap {
        top: calc(16px + env(safe-area-inset-top));
        left: calc(16px + env(safe-area-inset-left));
    }
}

/* ===== MODERN ACCESSIBILITY: REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    body.dang-phat .cover-inner {
        animation: none !important;
        transform: none !important;
    }
    .eq-bar {
        animation: none !important;
        height: 12px !important;
    }
    .title-song.scroll-text {
        animation: none !important;
    }
    .toast {
        transition: none !important;
    }
    * {
        scroll-behavior: auto !important;
    }
}
