:root {
    /* Light theme (default) */
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --text-color: #2d3436;
    --light-text: #636e72;
    --background-color: #f9f9f9;
    --card-bg: #ffffff;
    --card-bg-menu: #f9f9f900;
    --accent-color: #fd79a8;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    --shadow-color: -5px -5px 15px 0px #f2b5d422, 5px 5px 15px 0px #7bdef222;
    --transition: all 0.3s ease;
    --primary-color-rgb: 108, 92, 231;
    --background: 
        linear-gradient(135deg, rgba(108, 92, 231, 0.2) 0%, rgba(253, 121, 168, 0.2) 100%),
        radial-gradient(circle at top left, rgba(162, 155, 254, 0.25) 0%, transparent 70%),
        radial-gradient(circle at bottom right, rgba(253, 121, 168, 0.25) 0%, transparent 70%),
        var(--background-color);
    --background-spring: 
        radial-gradient(circle at 50% 80%, #e6d8fd 0%, transparent 50%),
        radial-gradient(circle at 30% 60%, #afcfdb 0%, transparent 50%),
        radial-gradient(circle at 65% 45%, #65acd8bd 0%, transparent 60%),
        linear-gradient(0deg, #ffffff 60%, #f2d5eeb4 100%),
        var(--background-color);
}

/* Dark theme */
[data-theme="dark"] {
    --primary-color: #9f94ff;
    --secondary-color: #b4aeff;
    --text-color: #f1f1f1;
    --light-text: #b3b3b3;
    --background-color: #1a1a2e;
    --card-bg: #252541;
    --card-bg-menu: #1a1a2eb3;
    --accent-color: #ff79ac;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    --primary-color-rgb: 159, 148, 255;
    --background: 
        linear-gradient(135deg, rgba(159, 148, 255, 0.3) 0%, rgba(255, 121, 172, 0.25) 100%),
        radial-gradient(circle at top right, rgba(180, 174, 255, 0.35) 0%, transparent 80%),
        radial-gradient(circle at bottom left, rgba(255, 121, 172, 0.3) 0%, transparent 80%),
        var(--background-color);
    --background-spring: 
        radial-gradient(circle at 50% 80%, #9e7ca294 0%, transparent 60%),
        radial-gradient(circle at 30% 60%, #515ad874 0%, transparent 50%),
        radial-gradient(circle at 60% 50%, #a6597db4 0%, transparent 70%),
        linear-gradient(0deg, #412242 30%, #5a527c 100%),
        var(--background-color);
}

/* Apply dark theme automatically if system preference is dark */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #9f94ff;
        --secondary-color: #b4aeff;
        --text-color: #f1f1f1;
        --light-text: #b3b3b3;
        --background-color: #1a1a2e;
        --card-bg: #252541;
        --accent-color: #ff79ac;
        --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    }
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    background: var(--background-color);
    background-attachment: fixed;
    background-size: cover; /* 改用 cover 而不是 100vw 100vh */
    background-repeat: no-repeat; /* 防止背景重复 */
    min-height: 100lvh; /* 确保至少占满整个视口高度 */
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0; /* 使用 bottom 代替 height 以確保完全覆蓋 */
    width: 100%;
    height: 100%;
    z-index: -1;
    transition: background-color 0.3s ease, color 0.3s ease;
    background: var(--background-spring);
    background-size: cover; /* 使用 cover 而不是 100% 100% */
}

/* Dark theme background */
[data-theme="dark"] body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body::before {
    transition: background-color 0.3s ease, color 0.3s ease;
    background: var(--background-spring);
    background-size: cover; /* 使用 cover 而不是 100% 100% */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: center; /* 改为居中对齐 */
    position: relative; /* 添加相对定位，允许绝对定位子元素 */
    margin-bottom: 1rem;
    animation: fadeIn 1s ease-out;
}

.header-content {
    text-align: left; /* 改为左对齐 */
}

header h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0rem;
    font-weight: 700;
    text-align: center; /* 标题文本居中 */
}

header p {
    color: var(--light-text);
    font-size: 1.2rem;
}

.search-container {
    margin-bottom: 1rem;
}

.search-box {
    position: relative;
    display: flex;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border-radius: 50px;
    overflow: hidden;
}

.search-box input {
    flex: 1;
    padding: .5rem 1rem;
    border: none;
    outline: none;
    font-size: 1rem;
}

.search-box button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.search-box button:hover {
    background-color: var(--secondary-color);
}

.filter-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.filter-options select {
    padding: 0.5rem .5rem;
    border: 0px solid #ddd;
    border-radius: 25px;
    outline: none;
    cursor: pointer;
    flex: 1;
    min-width: 100px;
    transition: var(--transition);
    background-color: rgba(255, 255, 255, 0.5);

    /* Add styling for custom dropdown arrow */
    padding-right: 30px; /* Increase right padding to make room for arrow */
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none; /* For Safari */
    -moz-appearance: none; /* For Firefox */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636e72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center; /* Position arrow 10px from right edge */
    background-size: 14px; /* Size of the arrow */
}

/* Add highlight for the sort dropdown when active */
#sortOptions {
    background-color: var(--background-color);
}

#sortOptions option[value="default"] {
    font-weight: normal;
}

/* Add special styling for the currently active sort option */
.sort-active {
    background-color: var(--primary-color);
    color: white;
}

/* Fix dropdown arrow appearance in different theme */
[data-theme="dark"] .filter-options select {
    background-color: var(--card-bg-menu);
    color: var(--text-color);
    border-color: var(--light-text);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b3b3b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--light-text);
}

.results-count-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.clear-filters-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.clear-filters-btn:hover {
    background-color: var(--primary-color);
    transform: scale(1.05);
}

.clear-filters-btn i {
    font-size: 0.7rem;
}

/* Added to group view toggle and theme switch together */
.view-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.view-toggle {
    display: flex;
}

.view-toggle button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--light-text);
    transition: var(--transition);
}

.view-toggle button.active {
    color: var(--primary-color);
}

/* Grid view */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.song-card {
    background-color: rgba(249, 249, 249, 0.5); /* Light theme semi-transparent background - closer to background color */
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: none;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05), 0 1px 8px rgba(0, 0, 0, 0.04);
    transition: var(--transition);
    position: relative;
    cursor: pointer;
    border: 0px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.song-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08), 0 5px 15px rgba(0, 0, 0, 0.06);
    background-color: rgba(249, 249, 249, 0.8); /* Slightly less transparent on hover */
}

/* Dark theme card styles */
[data-theme="dark"] .song-card {
    background-color: rgba(26, 26, 46, 0.5); /* Dark theme semi-transparent background - closer to background color */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14), 0 1px 8px rgba(0, 0, 0, 0.1);
    border: 0px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .song-card:hover {
    background-color: rgba(26, 26, 46, 0.7); /* Slightly less transparent on hover */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.12);
}

/* Grid-specific card styles */
.grid-view .song-card {
    display: flex;
    flex-direction: column;
    position: relative; /* Ensure relative positioning for absolute children */
    padding-bottom: 20px; /* Space for the tags */
}

.grid-view .card-image {
    height: 0px; /* Reduced from 60px to 10px */
    /* Remove display flex, align-items, justify-content since we won't have an icon */
}

.grid-view .card-content {
    padding: 0.6rem;
    flex: 1;
}

.grid-view .song-title {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    /* Cross-browser text truncation */
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    max-height: 2.4em; /* fallback for non-webkit browsers */
}

.grid-view .song-artist {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-view .song-details {
    font-size: 0.7rem;
}

/* Simplified badge styling for grid view */
.grid-view .song-card .song-genre,
.grid-view .song-card .song-mood.grid-badge {
    position: absolute;
    right: 7px;
    color: white;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5;
}

/* Position genre tag at bottom right */
.grid-view .song-card .song-genre {
    right: 53px;
    bottom: 7px;
    max-width: 80%;
}

/* Position mood tag above genre tag */
.grid-view .song-card .song-mood.grid-badge {
    bottom: 7px; /* Position above genre tag */
    background-color: var(--accent-color);
    max-width: 80%;
}

/* Hide the mood in the details section since we show it as a badge */
.grid-view .song-details .song-mood {
    display: none;
}

/* Mobile responsiveness - simplified */
@media (max-width: 480px) {
    .grid-view .song-card {
        padding-bottom: 20px; /* Slightly less padding on mobile */
    }
    
    .grid-view .song-card .song-genre,
    .grid-view .song-card .song-mood.grid-badge {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
        right: 4px;
        max-width: 75%;
    }
    
    .grid-view .song-card .song-genre {
        bottom: 4px;
    }
    
    .grid-view .song-card .song-mood.grid-badge {
        bottom: 25px; /* Less space on mobile */
    }
}

/* Common card elements */
.song-card .card-image {
    background-color: transparent; /* Changed from var(--secondary-color) */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color); /* Default color */
}

.song-card .card-image i {
    font-size: 2.2rem; /* Make the music icon larger */
    transition: var(--transition);
}

/* Remove genre-specific styles */
.song-card .song-genre {
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.7rem;
    position: absolute;
    bottom: 10px; /* Position at bottom */
    right: 10px; /* Position at right */
    z-index: 5; /* Ensure it appears above other elements */
    max-width: 90%; /* Prevent from being too wide */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Add more styling for song genre and mood badges in grid view */
.song-card .song-genre,
.song-card .song-mood.grid-badge {
    color: white;
    padding: 0.15rem 0.6rem; /* Reduced padding */
    border-radius: 20px;
    font-size: 0.65rem; /* Smaller font */
    position: absolute;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5; /* Ensure it appears above other elements */
    max-width: 75%; /* Increase max width since they're stacked */
    right: 7px; /* Both aligned to the right */
}

/* Position the genre badge at bottom right */
.song-card .song-genre {
    bottom: 7px;
}

/* Position the mood badge above the genre badge, also aligned right */
.song-card .song-mood.grid-badge {
    bottom: 32px; /* Position above the genre badge with spacing */
    background-color: var(--accent-color);
}

/* Keeping the existing mood styling for other views */
.song-mood {
    margin-left: 8px;
    color: var(--accent-color);
    font-size: 0.8rem;
}

.grid-view .song-details .song-mood {
    display: none; /* Hide mood from song details since we're showing it as a badge */
}

/* List view styling updates */
.list-view .song-meta-bottom .song-mood {
    margin-left: 8px;
    font-weight: 500;
}

/* Hide the grid-style badge in list view */
.list-view .song-mood.grid-badge {
    display: none;
}

/* Mobile responsiveness for grid badges */
@media (max-width: 480px) {
    .song-card .song-genre,
    .song-card .song-mood.grid-badge {
        font-size: 0.55rem; /* Even smaller on mobile */
        padding: 0.1rem 0.3rem;
        max-width: 70%;
        right: 4px; /* Both aligned to the right */
    }
    
    .song-card .song-genre {
        bottom: 4px;
    }
    
    .song-card .song-mood.grid-badge {
        bottom: 25px; /* Less space on mobile screens */
    }
}

/* List view - restore original styles */
.list-view {
    display: flex;
    flex-direction: column;
    gap: .7rem;
}

.list-view .song-card {
    display: flex;
    height: 75px;
    align-items: center;
    flex-direction: row; /* Ensure horizontal layout */
}

.list-view .card-image {
    width: 75px;
    height: 75px;
    flex-shrink: 0;
    font-size: 2rem; /* Restore original size for list view */
    opacity: 0.7;
}

.list-view .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    padding: 0.6rem 1.2rem;
    gap: 0.3rem;
}

.list-view .song-title {
    margin-bottom: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    height: auto; /* Reset the height constraint */
}

.list-view .song-artist {
    margin-bottom: 0;
    color: var(--light-text);
    font-size: 0.85rem;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .song-genre-container {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--light-text);
}

.list-view .song-genre {
    display: none; /* Hide genre badge in list view */
}

/* Removed lyrics button styling */

.song-card .card-content {
    padding: 0.6rem;
    flex: 1;
}

.song-card .song-title {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    /* Cross-browser text truncation */
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    max-height: 2.4em; /* fallback for non-webkit browsers */
}

.song-card .song-artist {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-card .song-artist.artist-clickable {
    cursor: pointer;
    color: var(--light-text); /* Changed from var(--primary-color) to match regular text */
    transition: var(--transition);
    /* Remove underline styling */
    text-decoration: none;
}

.song-card .song-artist.artist-clickable:hover {
    opacity: 0.8;
}

/* Remove duplicate hover style */
.song-card .song-artist.artist-clickable:hover {
    opacity: 0.8;
    /* Remove the underline on hover */
    text-decoration: none;
}

/* Styling for multiple artists */
.song-artist .artist-clickable,
.song-genre .genre-clickable,
.song-genre-container .genre-clickable {
    cursor: pointer;
    color: var(--light-text);
    transition: var(--transition);
    display: inline-block;
}

.song-artist .artist-clickable:hover,
.song-genre .genre-clickable:hover,
.song-genre-container .genre-clickable:hover {
    opacity: 0.8;
    color: var(--primary-color);
}

/* Small spacing for separators */
.song-artist span + span,
.song-genre span + span,
.song-genre-container span + span {
    margin-left: 2px;
}

/* Genre popup specific styles */
.genre-popup {
    z-index: 101; /* Ensure genre popup appears above artist popup */
}

/* Styling for multiple artists */
.song-artist .artist-clickable {
    cursor: pointer;
    color: var(--light-text);
    transition: var(--transition);
    display: inline-block;
}

.song-artist .artist-clickable:hover {
    opacity: 0.8;
}

/* Small spacing for artist separators */
.song-artist span + span {
    margin-left: 2px;
}

.song-card .song-details {
    display: flex;
    justify-content: space-between;
    color: var(--light-text);
    font-size: 0.7rem;
}

/* Popup menu styles */
.artist-popup {
    position: absolute;
    background-color: rgba(249, 249, 249, 0); /* Light theme semi-transparent popup - matches card */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 100;
    min-width: 180px;
    max-width: 250px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.artist-popup.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.artist-popup-header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist-popup-options {
    padding: 5px 0;
}

.artist-popup-option {
    padding: 8px 15px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.artist-popup-option:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .artist-popup-option:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.artist-popup-option i {
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
}

/* Dark theme artist popup */
[data-theme="dark"] .artist-popup {
    background-color: rgba(26, 26, 46, 0); /* Dark theme semi-transparent popup - matches card */
}

/* List view */
.list-view {
    display: flex;
    flex-direction: column;
    gap: .7rem;
}

.list-view .song-card {
    display: flex;
    height: 65px;
    align-items: center;
}

.list-view .card-image {
    width: 75px;
    height: 75px;
    flex-shrink: 0;
}

.list-view .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    padding: 0.6rem 1.2rem;
    gap: 0.3rem;
}

.list-view .song-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.list-view .song-title {
    margin-bottom: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.list-view .song-artist {
    margin-bottom: 0;
    color: var (--light-text);
    font-size: 0.85rem;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-view .song-meta-top,
.list-view .song-meta-bottom {
    display: flex;
    gap: 0.1rem;
    font-size: 0.85rem;
    color: var(--light-text);
    align-items: center;
    justify-content: flex-end;
}

/* Remove the artist dash prefix we previously added */
.list-view .song-artist:before {
    content: "";
    margin-right: 0;
}

.list-view .song-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.list-view .song-meta span {
    font-size: 0.9rem;
    color: var (--light-text);
}

.hidden {
    display: none;
}

#noResults {
    text-align: center;
    padding: 3rem;
    color: var(--light-text);
}

#noResults i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var (--light-text);
    margin-top: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.song-card {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Copy notification styles */
.copy-notification {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center; /* 水平置中內容 */
    gap: 0.8rem;
    transition: bottom 0.5s ease;
    z-index: 1000;
    max-width: 90%;
    min-width: 300px;
    width: auto;
    text-align: center; /* 文字置中對齊 */
}

.copy-notification i {
    font-size: 1.2rem;
    flex-shrink: 0; /* 防止圖標被壓縮 */
}

.copy-notification span {
    white-space: nowrap; /* 確保文字不換行 */
    overflow: hidden; /* 超出部分隱藏 */
    text-overflow: ellipsis; /* 顯示省略號 */
    text-align: center; /* 確保文字置中顯示 */
}

.copy-notification.show {
    bottom: 30px;
}

/* Updated theme switch styles for the new position */
.theme-switch-container {
    display: flex;
    align-items: center;
    gap: 0.3rem; /* 减小间距 */
    position: absolute; /* 绝对定位 */
    right: 0; /* 靠右 */
    top: 50%; /* 垂直居中 */
    transform: translateY(-50%); /* 垂直居中微调 */
}

.theme-switch {
    position: relative;
    width: 40px; /* 减小宽度 */
    height: 20px; /* 减小高度 */
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--light-text);
    transition: var(--transition);
    border-radius: 20px; /* 调整为匹配高度 */
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; /* 减小滑块高度 */
    width: 14px; /* 减小滑块宽度 */
    left: 3px; /* 调整左侧位置 */
    bottom: 3px; /* 调整底部位置 */
    background-color: var(--card-bg);
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(18px); /* 调整移动距离 */
}

.theme-icon {
    color: var(--text-color);
    font-size: 0.8rem; /* 减小图标尺寸 */
}

/* Sort button styles */
.sort-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--light-text);
    transition: var(--transition);
    font-size: 1rem;
}

.sort-button:hover,
.sort-button.active {
    color: var(--primary-color);
}

/* Sort popup styles */
.sort-popup {
    position: absolute;
    background-color: var(--card-bg-menu);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 8px;
    box-shadow: var (--shadow);
    z-index: 100;
    min-width: 200px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sort-popup.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sort-popup-header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
}

.sort-popup-options {
    padding: 5px 0;
}

.sort-popup-option {
    padding: 8px 15px;
    cursor: pointer;
    transition: var (--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.sort-popup-option:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sort-popup-option.active {
    background-color: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.sort-popup-option i {
    width: 16px;
    text-align: center;
}

/* Dark theme sort popup */
[data-theme="dark"] .sort-popup {
    background-color: var(--card-bg-menu);
}

[data-theme="dark"] .sort-popup-option:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .sort-popup-option.active {
    background-color: rgba(var(--primary-color-rgb), 0.2);
}

/* Multi-select styling */
.multi-select-container {
    position: relative;
    flex: 1;
    min-width: 100px;
}

.multi-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.5);
    transition: var(--transition);
}

[data-theme="dark"] .multi-select-header {
    background-color: rgba(26, 26, 46, .7);
    color: var(--text-color);
}

.multi-select-header span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background-color: var(--card-bg-menu);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 20px;
    box-shadow: 0px 0px 40px rgba(0, 0, 0, 0.3);
    max-height: 0;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 1000;
}

.multi-select-dropdown.show {
    max-height: 250px;
    max-height: 70vh;
    opacity: 1;
    pointer-events: auto;
}

.multi-select-option {
    font-size: 1.1rem;
    padding: 8px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.multi-select-option:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .multi-select-option:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.multi-select-option.selected {
    background-color: rgba(var(--primary-color-rgb), 0.1);
}

[data-theme="dark"] .multi-select-option.selected {
    background-color: rgba(var(--primary-color-rgb), 0.2);
}

.multi-select-option i {
    display: none;
}

.multi-select-option.selected i {
    display: block;
    color: var(--primary-color);
}

.multi-select-search {
    font-size: 1.1rem;
    width: 100%;
    padding: 8px 15px;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    outline: none;
    background-color: var(--card-bg-menu);
}

[data-theme="dark"] .multi-select-search {
    color: var(--text-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile responsive adjustments for multi-select */
@media (max-width: 768px) {
    .multi-select-dropdown {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        margin: 0;
        border-radius: 20px 20px 0 0;
        z-index: 1001;
    }
    
    .multi-select-dropdown.show {
        max-height: 60vh;
    }
    
    /* Style for when keyboard is visible */
    .multi-select-dropdown.keyboard-visible {
        border-radius: 20px;
        box-shadow: 0px -5px 25px rgba(0, 0, 0, 0.2);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header {
        /* 在小屏幕上保持左右结构 */
        justify-content: center;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    .theme-switch-container {
        /* 调整小屏幕上的主题切换组件位置 */
        position: absolute;
        right: 0;
    }
    
    .grid-view {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.8rem;
    }
    
    .list-view .card-content {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    
    .list-view .song-info,
    .list-view .song-meta {
        width: 100%;
    }
    
    .list-view .song-meta {
        margin-top: 0.5rem;
    }

    body {
        /* 在移动设备上使用替代方案，避免iOS的问题 */
        background-attachment: scroll; /* 某些移动设备不支持fixed */
        /* 创建一个包含背景的伪元素 */
        position: relative;
    }

}

/* 添加橫向螢幕特定樣式 */
@media (max-width: 768px) and (orientation: landscape) {
    body::before {
        /* 重新確認在橫向模式下背景完全覆蓋 */
        height: 100lvh;
        width: 100vw;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem; /* 更小的屏幕上减小标题大小 */
        padding-right: 25px; /* 确保标题不会被主题开关覆盖 */
    }
    
    .grid-view {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
    
    .grid-view .song-card .card-image {
        height: 5px; /* Even smaller on mobile */
    }
    
    .grid-view .song-card .card-content {
        padding: 0.4rem;
    }
    
    .grid-view .song-card .song-title {
        font-size: 1rem;
        margin-bottom: 0.2rem;
    }
    
    .grid-view .song-card .song-artist {
        font-size: 0.7rem;
        margin-bottom: 0.2rem;
    }
    
    .grid-view .song-card .song-details {
        font-size: 0.65rem;
    }
    
    .grid-view .song-card .song-genre {
        font-size: 0.55rem; /* Even smaller on mobile */
        padding: 0.1rem 0.3rem;
        max-width: 40%;
    }
    
    .grid-view .song-card .song-genre {
        bottom: 7px;
        right: 38px;
    }
    
    .grid-view .song-card .song-mood.grid-badge {
        font-size: 0.55rem; /* Even smaller on mobile */
        padding: 0.1rem 0.3rem;
        max-width: 40%;
    }
    
    .grid-view .song-card .song-mood.grid-badge {
        bottom: 7px; /* Less space on mobile screens */
        right: 7px;
    }
    
    /* List view mobile adjustments */
    .list-view .song-card {
        height: 60px;
    }
    
    .list-view .card-image {
        width: 70px;
        height: 70px;
    }
    
    .list-view .card-content {
        padding: 0.5rem 0.8rem;
    }
}

@media (max-width: 350px) {
    .grid-view {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Random button styles */
.random-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--light-text);
    transition: var(--transition);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.random-button span {
    font-size: 0.85rem;
}

.random-button:hover,
.random-button.active {
    color: var(--primary-color);
}

/* Random song container styles */
.random-song-container {
    margin: 1rem auto 1.5rem;  /* 縮減上下邊距 */
    position: relative;
    border-radius: 15px; /* Match the border-radius with the song card */
    overflow: hidden;
    animation: fadeInScale 0.6s cubic-bezier(0.2, 1, 0.3, 1) forwards;
    max-width: 600px;  /* 縮減最大寬度 */
    box-shadow: 0 15px 30px -12px rgba(var(--primary-color-rgb), 0.25);
    /* Add background to prevent corner artifacts */
    background-color: var(--card-bg); 
}

/* Close button for random song */
.random-close-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;  /* 縮小按鈕 */
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
    /* 移除定位屬性，讓按鈕跟隨 flex 佈局 */
}

.random-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

[data-theme="dark"] .random-close-btn {
    background-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .random-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Unified card style for random song */
.random-song-container .song-card {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.08) 0%, rgba(var(--accent-color-rgb), 0.12) 100%);
    -webkit-backdrop-filter: blur(20px); /* Ensure -webkit prefix is added */
    backdrop-filter: blur(20px);
    border: none;
    box-shadow: none;
    border-radius: 15px; /* Ensure same radius as container */
    padding: 0;
    height: auto;
    display: block;
    transform: none !important;
    /* Ensure the card itself has background color to prevent artifacts */
    background-color: var(--card-bg);
    /* Prevent corner artifacts */
    overflow: hidden;
    isolation: isolate; /* Create a new stacking context */
}

[data-theme="dark"] .random-song-container .song-card {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.2) 0%, rgba(var(--accent-color-rgb), 0.25) 100%);
    /* Add background color to prevent artifacts */
    background-color: var(--card-bg);
}

/* 隨機歌曲頭部區域 */
.random-header {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 0.7rem 1.2rem;  /* 縮減內邊距 */
    display: flex;
    justify-content: space-between; /* 確保標題和關閉按鈕分別在兩端 */
    align-items: center;
    /* Ensure no corner artifacts */
    border-radius: 15px 15px 0 0; /* Round top corners only */
    position: relative;
    z-index: 2; /* Ensure it's above other elements */
}

/* 歌曲內容區 */
.random-content {
    display: flex;
    padding: 1rem 1.2rem;  /* 縮減內邊距 */
    gap: 1rem;  /* 縮減元素間距 */
    align-items: center;
    /* Ensure background matches the container */
    background-color: var(--card-bg);
    position: relative;
    z-index: 1;
}

/* 隨機歌曲卡片 - 全新設計 */
.random-song-container {
    margin: 1rem auto 1.5rem;  /* 縮減上下邊距 */
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    animation: fadeInScale 0.6s cubic-bezier(0.2, 1, 0.3, 1) forwards;
    max-width: 600px;  /* 縮減最大寬度 */
    box-shadow: 0 15px 30px -12px rgba(var(--primary-color-rgb), 0.25);
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.98) translateY(-8px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.random-song-container .song-card {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.08) 0%, rgba(var(--accent-color-rgb), 0.12) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    box-shadow: none;
    border-radius: 15px;
    padding: 0;
    height: auto;
    display: block;
    transform: none;
}

[data-theme="dark"] .random-song-container .song-card {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.2) 0%, rgba(var(--accent-color-rgb), 0.25) 100%);
}

/* 隨機歌曲頭部區域 */
.random-header {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 0.7rem 1.2rem;  /* 縮減內邊距 */
    display: flex;
    justify-content: space-between; /* 確保標題和關閉按鈕分別在兩端 */
    align-items: center;
}

.random-header-title {
    order: 1; /* 確保標題在左側 */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;  /* 減小字體 */
    font-weight: 600;
}

.random-header-title i {
    font-size: 1.1rem;
}

.random-header .random-close-btn {
    order: 2; /* 確保關閉按鈕在右側 */
}

/* 歌曲內容區 */
.random-content {
    display: flex;
    padding: 1rem 1.2rem;  /* 縮減內邊距 */
    gap: 1rem;  /* 縮減元素間距 */
    align-items: center;
}

.random-album-art {
    width: 80px;  /* 縮小專輯封面 */
    height: 80px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.2rem;  /* 縮小圖標 */
    box-shadow: 0 15px 30px rgba(var(--primary-color-rgb), 0.2);
}

.random-album-art i {
    filter: drop-shadow(0 3px 5px rgba(0,0,0,0.2));
}

.random-song-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 0;  /* 移除額外padding */
}

.random-song-title {
    font-size: 1.3rem;  /* 縮小標題字體 */
    font-weight: 700;
    margin-bottom: 0.3rem;  /* 減少標題下方間距 */
    color: var(--text-color);
    line-height: 1.2;
}

.random-song-artist {
    font-size: 1rem;  /* 縮小藝術家字體 */
    margin-bottom: 0.5rem;  /* 減少下方間距 */
    color: var(--light-text);
    line-height: 1.4;
}

.random-song-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;  /* 縮減標籤間距 */
    font-size: 0.8rem;  /* 縮小元數據字體 */
    color: var(--light-text);
}

.random-song-meta div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.random-song-meta i {
    opacity: 0.7;
}

/* 隨機按鈕區 */
.random-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 1.2rem 1rem;  /* 縮減內邊距 */
}

/* 移動裝置適配 */
@media (max-width: 768px) {
    .random-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    .random-album-art {
        width: 70px;
        height: 70px;
    }
    
    .random-song-title {
        font-size: 1.2rem;
    }
    
    /* 確保在小螢幕上內容依然水平排列以節省空間 */
    .random-content {
        flex-direction: row;
        align-items: center;
        text-align: left;
    }
    
    .random-song-meta {
        justify-content: flex-start;
    }
}

/* Mobile specific fixes */
@media (max-width: 768px) {
    .random-song-container {
        /* Prevent content from overflowing on mobile */
        overflow: hidden;
        /* Use a solid background color on mobile */
        background-color: var(--card-bg);
    }
    
    /* Ensure smooth animation on mobile */
    @keyframes fadeInScale {
        0% {
            opacity: 0;
            transform: scale(0.98) translateY(-8px);
            border-radius: 15px;
        }
        100% {
            opacity: 1;
            transform: scale(1) translateY(0);
            border-radius: 15px;
        }
    }
    
    /* Add specific fix for iOS devices */
    @supports (-webkit-touch-callout: none) {
        .random-song-container {
            /* Hardware acceleration for iOS */
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
        }
        
        .random-song-container .song-card {
            /* Disable backdrop-filter on iOS to prevent rendering artifacts */
            -webkit-backdrop-filter: none;
            backdrop-filter: none;
            background-color: var(--card-bg);
        }
    }
}

/* Styling for song mood tags */
.song-mood {
    margin-left: 8px;
    color: var(--accent-color);
    font-size: 0.8rem;
}

.grid-view .song-details .song-mood {
    margin-left: 5px;
    font-size: 0.7rem;
}

/* Update this selector to target mood in song-meta-bottom instead of top */
.list-view .song-meta-bottom .song-mood {
    margin-left: 8px;
    font-weight: 500;
}

/* Random song mood styling */
.random-song-mood {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
}

.random-song-mood i {
    opacity: 0.8;
}