/* Melon Lite Style - Elegant Dark & Green Theme */

:root {
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --accent-color: #00CD3C; /* Melon Green */
    --accent-hover: #00B334;
    --text-primary: #ffffff;
    --text-secondary: #a7a7a7;
    --text-muted: #6e6e6e;
    --border-color: #2a2a2a;
    --sidebar-width: 250px;
    --player-height: 90px;
    --font-sans: 'Inter', 'Noto Sans KR', sans-serif;
    --font-title: 'Outfit', sans-serif;
    --player-bg: #181818;
    --player-surface: #1a1a1a;
    --player-elevated: #121212;
    --player-text: #ffffff;
    --player-muted: #a7a7a7;
    --player-border: #2a2a2a;
    --player-progress-bg: #242424;
    --player-button-bg: #ffffff;
    --player-button-text: #000000;
}

/* 22차 모바일/PWA 플레이어 최종 보정 */
@media (max-width: 767px) {
    .player-bar {
        box-sizing: border-box;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        min-height: calc(84px + env(safe-area-inset-bottom));
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom)) !important;
        overflow: hidden;
    }

    .content-body,
    .app-main,
    .main-content {
        padding-bottom: calc(132px + env(safe-area-inset-bottom)) !important;
    }

    .player-song-info,
    .player-song-details {
        min-width: 0;
    }

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

    .progress-bar-wrapper {
        min-height: 18px;
    }

    .expand-player-container {
        width: 100%;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        border-radius: 0 !important;
        padding-bottom: calc(22px + env(safe-area-inset-bottom)) !important;
    }

    .melon-lite-toast,
    .pwa-install-banner {
        max-width: calc(100vw - 20px);
    }
}

/* 17차: smart organize and tag management */
.tag-cloud,
.song-tags-box,
.tag-suggestion-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tag-badge,
.tag-suggestion-btn {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.2;
    text-decoration: none;
    word-break: keep-all;
}

.tag-badge:hover,
.tag-suggestion-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.tag-empty {
    color: var(--text-muted);
    font-size: 14px;
}

.tag-remove-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
}

.tag-remove-btn:hover {
    color: var(--danger-color, #ff4d4f);
    border-color: var(--danger-color, #ff4d4f);
}

.tag-editor-card,
.smart-organize-page,
.tag-manage-page,
.name-merge-page,
.metadata-quality-page {
    min-width: 0;
}

.song-tag-form,
.tag-admin-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.song-tag-form input,
.tag-admin-form input,
.tag-admin-form select,
.merge-candidate-header input {
    min-width: 180px;
    flex: 1 1 220px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tag-admin-form.compact {
    margin-top: 10px;
}

.smart-card-grid,
.tag-admin-grid,
.merge-candidate-list,
.metadata-quality-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.smart-summary-card,
.tag-admin-card,
.merge-candidate-card,
.metadata-quality-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.smart-summary-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.smart-summary-card span,
.metadata-quality-card p,
.merge-source-list small {
    color: var(--text-secondary);
}

.smart-summary-card strong {
    color: var(--accent-color);
    font-size: 24px;
}

.merge-candidate-card,
.metadata-quality-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.merge-candidate-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.merge-source-list {
    display: grid;
    gap: 8px;
}

.merge-source-list label,
.merge-manual-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 34px;
}

.metadata-suggestion-box {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    word-break: break-word;
}

.metadata-suggestion-box strong {
    color: var(--text-primary);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tab {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
}

.filter-tab.active,
.filter-tab:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

@media (max-width: 767px) {
    .smart-card-grid,
    .tag-admin-grid,
    .merge-candidate-list,
    .metadata-quality-list {
        grid-template-columns: 1fr;
    }

    .song-tag-form input,
    .tag-admin-form input,
    .tag-admin-form select,
    .tag-admin-form button,
    .merge-candidate-header input {
        width: 100%;
        flex-basis: 100%;
    }

    .smart-summary-card {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* 18차: lyrics, notes and ratings */
.song-title-stack,
.listening-note-main {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.song-list-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.song-rating-badge,
.song-note-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    font-size: 12px;
    text-decoration: none;
}

.recommend-reason-badge {
    max-width: 100%;
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 10%, var(--card-bg));
}

.song-rating-badge i,
.rating-star.active {
    color: #f5b301;
}

.rating-panel,
.note-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.rating-stars {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.rating-star,
.rating-clear-btn {
    min-width: 34px;
    min-height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}

.rating-stars:not(.rating-stars-editable) .rating-star {
    min-width: auto;
    min-height: auto;
    border: 0;
    background: transparent;
    cursor: default;
}

.rating-clear-btn {
    padding: 0 10px;
    width: auto;
}

.note-text-block,
.lyrics-text-block {
    max-height: 320px;
    overflow: auto;
    padding: 14px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    line-height: 1.8;
    word-break: break-word;
}

.song-note-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.song-note-form textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.listening-note-list {
    display: grid;
    gap: 12px;
}

.listening-note-row {
    display: grid;
    grid-template-columns: 42px 56px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
}

.listening-note-rating {
    justify-self: end;
}

.search-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    min-height: 38px;
}

@media (max-width: 767px) {
    .listening-note-row {
        grid-template-columns: 40px 48px minmax(0, 1fr);
        align-items: start;
    }

    .listening-note-rating {
        grid-column: 3 / -1;
        justify-self: start;
    }

    .rating-star,
    .rating-clear-btn {
        min-width: 38px;
        min-height: 38px;
    }
}

.search-page-form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

.search-page-form input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-color);
    font-size: 15px;
}

mark {
    background: rgba(0, 205, 60, 0.22);
    color: var(--text-color);
    border-radius: 4px;
    padding: 0 3px;
}

.explore-card-grid,
.auto-playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.explore-card,
.auto-playlist-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
}

.explore-card strong,
.auto-playlist-card strong {
    font-size: 15px;
    word-break: break-word;
}

.explore-card span,
.auto-playlist-card span,
.auto-playlist-card small {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.auto-playlist-card i {
    color: var(--accent-color);
    font-size: 22px;
}

.auto-playlist-action-panel {
    display: grid;
    gap: 14px;
}

.auto-playlist-actions,
.auto-save-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.auto-save-form {
    display: grid;
    gap: 8px;
    max-width: 680px;
}

.auto-save-form label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
}

.auto-save-row .form-control {
    flex: 1 1 260px;
    min-width: 0;
}

.metadata-tools {
    margin-bottom: 18px;
}

.metadata-error {
    display: block;
    margin-top: 6px;
    color: var(--danger-color, #ff6b6b);
    word-break: break-word;
}

.inline-action-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

@media (max-width: 768px) {
    .search-page-form {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .search-page-form input {
        flex-basis: calc(100% - 32px);
    }

    .search-page-form .btn {
        width: 100%;
        justify-content: center;
    }

    .explore-card-grid,
    .auto-playlist-grid {
        grid-template-columns: 1fr;
    }
}

.pwa-install-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    z-index: 1010;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 16px 40px rgba(0,0,0,0.22);
}

.pwa-install-banner[hidden] {
    display: none;
}

.pwa-install-banner div {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pwa-install-banner span {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.35;
}

.pwa-install-banner .pwa-install-copy {
    flex: 1 1 auto;
}

.pwa-install-banner .pwa-install-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.pwa-ios-steps {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.45;
}

.pwa-ios-steps[hidden] {
    display: none;
}

html.is-standalone body,
body.is-standalone {
    min-height: 100dvh;
}

body.is-standalone .top-bar {
    padding-top: max(16px, env(safe-area-inset-top));
}

body.is-standalone .sidebar {
    padding-top: env(safe-area-inset-top);
}

body.is-standalone .player-bar {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

body.is-standalone .content-body {
    padding-bottom: calc(var(--player-height) + 42px + env(safe-area-inset-bottom));
}

body.is-offline .player-bar::before {
    content: '오프라인';
    position: absolute;
    top: -24px;
    right: 12px;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
    background: #ef4444;
    font-size: 11px;
    font-weight: 700;
}

.offline-page {
    min-height: 55vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.offline-card {
    width: min(520px, 100%);
    padding: 28px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    text-align: center;
}

.offline-card i {
    color: var(--accent-color);
    font-size: 38px;
    margin-bottom: 14px;
}

.offline-card h1 {
    font-size: 24px;
    margin-bottom: 12px;
}

.offline-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.list-cover,
.compact-cover,
.entity-cover,
.album-card-cover,
.queue-item-thumb img,
.player-album-art img,
.expand-album-art img {
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

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

@media (max-width: 767px) {
    .content-body {
        padding-bottom: calc(122px + env(safe-area-inset-bottom));
    }

    .player-bar {
        min-height: 86px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        gap: 8px;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .player-song-info {
        min-width: 0;
        gap: 8px;
    }

    .player-album-art,
    .player-album-art img {
        width: 46px;
        height: 46px;
        flex: 0 0 46px;
    }

    .player-song-details {
        min-width: 0;
    }

    .player-controls {
        min-width: 0;
        width: auto;
    }

    .control-buttons {
        gap: 6px;
    }

    .control-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    #btn-shuffle,
    #btn-repeat,
    .player-utils .volume-icon,
    .volume-slider-wrapper {
        display: none;
    }

    .player-utils {
        gap: 4px;
    }

    .progress-container {
        max-width: 100%;
        gap: 6px;
    }

    .time-label {
        font-size: 11px;
        min-width: 36px;
    }

    .pwa-install-banner {
        left: 10px;
        right: 10px;
        bottom: calc(96px + env(safe-area-inset-bottom));
        align-items: stretch;
        flex-direction: column;
    }

    .pwa-install-banner .pwa-install-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .pwa-install-banner .pwa-install-actions .btn {
        flex: 1 1 120px;
        min-height: 38px;
    }

    .pwa-install-banner .modal-close-btn {
        min-width: 38px;
        min-height: 38px;
    }
}

/* 14th update: theme-aware player surfaces */
.player-bar {
    background-color: var(--player-bg) !important;
    border-top-color: var(--player-border) !important;
    color: var(--player-text);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.10);
}

.player-song-title,
.queue-item-title,
.expand-song-meta h2 {
    color: var(--player-text) !important;
}

.player-song-artist,
.time-label,
.volume-icon,
.queue-item-artist,
.queue-item-duration,
.expand-lyrics-full-text {
    color: var(--player-muted) !important;
}

.player-album-art,
.queue-item-thumb,
.expand-tab-section {
    background-color: var(--player-surface) !important;
    border-color: var(--player-border) !important;
}

.control-btn {
    color: var(--player-muted);
}

.control-btn:hover {
    color: var(--player-text);
}

.play-btn,
.expand-control-buttons-row .play-btn {
    background-color: var(--player-button-bg) !important;
    color: var(--player-button-text) !important;
}

.progress-bar-wrapper,
.volume-slider-wrapper,
.expand-player-controls .progress-bar-wrapper {
    background-color: var(--player-progress-bg) !important;
}

.progress-bar,
.volume-slider {
    background-color: var(--accent-color);
}

.progress-handle,
.expand-player-controls .progress-handle {
    background-color: var(--player-button-bg) !important;
}

.queue-panel {
    background-color: var(--player-elevated) !important;
    border-color: var(--player-border) !important;
}

.queue-header,
.expand-tab-headers {
    background-color: var(--player-surface) !important;
    border-color: var(--player-border) !important;
}

.queue-header h3 {
    color: var(--player-text) !important;
}

.queue-item {
    border-bottom-color: var(--player-border) !important;
}

.queue-item:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, transparent);
}

.expand-player-overlay {
    background-color: color-mix(in srgb, var(--player-elevated) 96%, transparent) !important;
}

.expand-close,
.tab-header-btn:hover {
    color: var(--player-text) !important;
}

.expand-tab-content,
.expand-player-container {
    color: var(--player-text);
}

.player-bar .resume-ready {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 24%, transparent);
}

.daily-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.daily-summary-grid div {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    background: var(--bg-secondary);
}

.daily-summary-grid span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.daily-summary-grid strong {
    color: var(--accent-color);
    font-size: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.stats-card-wide {
    grid-column: span 2;
}

.mini-bar-chart {
    display: grid;
    gap: 10px;
}

.mini-bar-row {
    display: grid;
    grid-template-columns: minmax(70px, 120px) 1fr minmax(32px, auto);
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mini-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.mini-bar-track {
    height: 9px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: inherit;
}

@media (max-width: 767px) {
    .stats-grid,
    .daily-summary-grid {
        grid-template-columns: 1fr;
    }

    .stats-card-wide {
        grid-column: auto;
    }

    .mini-bar-row {
        grid-template-columns: minmax(64px, 92px) 1fr minmax(28px, auto);
    }
}

body.theme-light {
    --bg-primary: #f6f7f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef0f2;
    --accent-color: #00a832;
    --accent-hover: #008f2b;
    --text-primary: #1f2328;
    --text-secondary: #59636e;
    --text-muted: #7d8790;
    --border-color: #d8dee4;
    --player-bg: #ffffff;
    --player-surface: #f6f7f8;
    --player-elevated: #ffffff;
    --player-text: #1f2328;
    --player-muted: #59636e;
    --player-border: #d8dee4;
    --player-progress-bg: #d8dee4;
    --player-button-bg: #1f2328;
    --player-button-text: #ffffff;
}

body.theme-dark,
body.theme-system {
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --accent-color: #2f81f7;
    --accent-hover: #1f6feb;
    --text-primary: #ffffff;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --player-bg: #181818;
    --player-surface: #1a1a1a;
    --player-elevated: #121212;
    --player-text: #ffffff;
    --player-muted: #c9d1d9;
    --player-border: #30363d;
    --player-progress-bg: #242424;
    --player-button-bg: #ffffff;
    --player-button-text: #000000;
}

body.theme-melon {
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --accent-color: #00CD3C;
    --accent-hover: #00B334;
    --text-primary: #ffffff;
    --text-secondary: #a7a7a7;
    --text-muted: #6e6e6e;
    --border-color: #2a2a2a;
}

body.theme-black {
    --bg-primary: #050505;
    --bg-secondary: #0d0d0d;
    --bg-tertiary: #171717;
    --accent-color: #f2f2f2;
    --accent-hover: #d8d8d8;
    --text-primary: #f7f7f7;
    --text-secondary: #b8b8b8;
    --text-muted: #777777;
    --border-color: #242424;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden; /* App layout uses custom scrolls */
    height: 100vh;
}

/* 5th update: library exploration */
.library-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    width: 100%;
    margin: 18px 0 24px;
}

.library-stat-card,
.home-section,
.entity-card,
.genre-card,
.metadata-edit-form {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.library-stat-card {
    padding: 16px;
}

.library-stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 6px;
}

.library-stat-value {
    display: block;
    color: var(--text-primary);
    font-size: 22px;
}

.home-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.home-quick-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.home-quick-links i {
    color: var(--accent-color);
}

.home-section-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.home-section {
    padding: 18px;
    min-width: 0;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-title {
    font-size: 18px;
    margin: 0;
}

.section-more-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.compact-song-grid {
    display: grid;
    gap: 10px;
}

.compact-song-card {
    display: grid;
    grid-template-columns: 34px 44px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.compact-cover {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.compact-play {
    width: 34px;
    height: 34px;
}

.compact-song-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.recommend-reason {
    display: block;
    max-width: 100%;
    color: var(--accent-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-title {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.library-toolbar input,
.library-toolbar select,
.metadata-edit-form input {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    min-height: 40px;
    padding: 0 12px;
}

.library-toolbar input {
    min-width: min(320px, 100%);
    flex: 1;
}

.entity-grid,
.genre-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.entity-grid.small {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.entity-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    color: var(--text-primary);
    text-decoration: none;
    min-width: 0;
}

.entity-cover,
.detail-cover {
    background: var(--bg-tertiary);
    object-fit: cover;
    flex-shrink: 0;
}

.entity-cover {
    width: 72px;
    height: 72px;
    border-radius: 6px;
}

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

.entity-info h2,
.genre-card h2 {
    font-size: 16px;
    margin: 0 0 6px;
    overflow-wrap: anywhere;
}

.entity-info p,
.entity-info span,
.genre-card p,
.genre-card span {
    color: var(--text-secondary);
    font-size: 13px;
}

.genre-card {
    display: block;
    padding: 18px;
    color: var(--text-primary);
    text-decoration: none;
}

.detail-hero {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
}

.detail-cover {
    width: 190px;
    height: 190px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.detail-kicker {
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 700;
}

.metadata-edit-form {
    display: grid;
    gap: 14px;
    max-width: 720px;
    padding: 22px;
}

.metadata-edit-form label {
    display: grid;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.metadata-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.metadata-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 999px;
    background: rgba(255, 193, 7, 0.14);
    color: #ffd166;
    font-size: 12px;
    font-weight: 700;
}

.stats-card-link {
    color: inherit;
    text-decoration: none;
}

.queue-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.error-log-console {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    color: #ff8882;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    max-height: 260px;
    overflow-y: auto;
}

.list-play-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.song-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.list-cover {
    width: 38px;
    height: 38px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.song-title-link {
    color: var(--text-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.file-ext-badge {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.song-action-group {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.empty-list-cell {
    padding: 42px 18px;
}

.empty-list-state i {
    display: block;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 40px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-width: 0;
}

.settings-card h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.settings-card label {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.settings-card input[type="text"],
.settings-card input[type="number"],
.settings-card input[type="color"],
.settings-card input[type="file"],
.settings-card select {
    width: 100%;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0 12px;
}

.settings-card input[type="color"] {
    padding: 4px;
}

.check-row {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 10px !important;
}

.check-row input {
    width: 18px;
    height: 18px;
}

.settings-submit-row {
    grid-column: 1 / -1;
}

.settings-warning {
    color: #ffd166;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.28);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.settings-muted {
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.inline-action-form,
.maintenance-actions {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.maintenance-actions .btn,
.inline-action-form .btn {
    justify-content: center;
}

.backup-list {
    display: grid;
    gap: 10px;
}

.backup-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
}

.backup-row small {
    color: var(--text-secondary);
}

.backup-row .btn {
    grid-row: span 2;
}

.settings-log-list {
    display: grid;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
}

.settings-log-row {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
}

.settings-log-row strong,
.settings-log-row span,
.settings-log-row p {
    display: block;
}

.settings-log-row span {
    color: var(--text-secondary);
    font-size: 12px;
    margin: 4px 0;
}

.settings-log-row p {
    color: var(--text-primary);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.btn-danger {
    background: #d1242f;
    border-color: #d1242f;
    color: #fff;
}

body.theme-light .brand-name {
    -webkit-text-fill-color: initial;
    background: none;
    color: var(--text-primary);
}

body.theme-light .song-title-link,
body.theme-light .compact-title {
    color: var(--text-primary);
}

@media (max-width: 640px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-card {
        padding: 16px;
    }

    .backup-row {
        grid-template-columns: 1fr;
    }

    .backup-row .btn {
        grid-row: auto;
        width: 100%;
    }

    body.player-mobile-compact {
        --player-height: 72px;
    }

    body.player-mobile-compact .player-utils,
    body.player-mobile-compact .progress-container {
        display: none;
    }

    body.player-mobile-compact .player-bar {
        min-height: 72px;
    }
}

@media (max-width: 900px) {
    .home-section-grid {
        grid-template-columns: 1fr;
    }

    .detail-hero {
        grid-template-columns: 1fr;
    }

    .detail-cover {
        width: min(220px, 100%);
        height: auto;
        aspect-ratio: 1;
    }
}

@media (max-width: 640px) {
    .content-body {
        padding: 18px 14px 120px;
    }

    .library-toolbar,
    .list-filter-section,
    .filter-sort-form {
        align-items: stretch;
    }

    .library-toolbar input,
    .library-toolbar select,
    .library-toolbar .btn,
    .filter-sort-form select {
        width: 100%;
    }

    .entity-grid,
    .genre-card-grid {
        grid-template-columns: 1fr;
    }

    .entity-card {
        align-items: center;
    }

    .compact-song-card {
        grid-template-columns: 34px 42px minmax(0, 1fr);
    }
}

/* App Container Layout */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr var(--player-height);
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    grid-row: 1 / 2;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
    padding-left: 8px;
}

.brand-icon {
    font-size: 28px;
    color: var(--accent-color);
    animation: spin 8s linear infinite;
    animation-play-state: paused;
}

.brand-name {
    font-family: var(--font-title);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.nav-item.active {
    color: var(--text-primary);
    background-color: var(--accent-color);
}

.nav-item.active .nav-icon {
    color: var(--text-primary);
}

.nav-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    color: var(--text-muted);
    padding-left: 16px;
}

/* Main Content Area */
.main-content {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-primary) 300px);
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background-color: color-mix(in srgb, var(--bg-primary) 85%, transparent);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-container {
    width: 350px;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-form input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 10px 16px 10px 42px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.search-form input:focus {
    border-color: var(--accent-color);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 8px rgba(0, 205, 60, 0.2);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.user-profile:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
}

.profile-icon {
    font-size: 18px;
}

/* Content Body */
.content-body {
    padding: 24px 32px 48px 32px;
}

/* Page Headers */
.page-title-section {
    margin-bottom: 28px;
}

.page-main-title {
    font-family: var(--font-title);
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Dashboard & Cards (Admin Scan Page) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
    border-color: #3a3a3a;
}

.card-icon {
    background-color: rgba(0, 205, 60, 0.1);
    color: var(--accent-color);
    font-size: 28px;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.card-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 20px;
    font-weight: 700;
}

.path-value {
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--accent-color);
    color: #000;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: scale(1.02);
}

.btn-primary:disabled, .btn-primary.loading {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.scan-action-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
}

.scan-status-summary h3 {
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.scan-status-summary .scan-msg {
    color: var(--text-secondary);
    font-size: 14px;
}

.scan-button-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.scan-countdown-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Alert Boxes */
.alert-box {
    display: flex;
    gap: 16px;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.alert-icon {
    font-size: 24px;
}

.alert-content h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.alert-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ff6b76;
}

.alert-info {
    background-color: rgba(13, 110, 253, 0.1);
    border: 1px solid rgba(13, 110, 253, 0.3);
    color: #6ea8fe;
}

.current-path-info {
    margin-top: 8px;
}

.current-path-info span {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #fff;
}

/* Tables & Lists */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 600;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr.playing {
    background-color: rgba(0, 205, 60, 0.05);
}

.data-table tbody tr.playing td {
    color: var(--accent-color);
}

.text-center {
    text-align: center;
}

.text-success { color: var(--accent-color); }
.text-info { color: #0d6efd; }
.text-warning { color: #ffc107; }

.log-message-td {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* List controls (Index page list styling) */
.list-filter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-left {
    display: flex;
    gap: 12px;
}

.filter-tab {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.filter-tab:hover, .filter-tab.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.filter-tab.active {
    border-bottom: 2px solid var(--accent-color);
    border-radius: 4px 4px 0 0;
}

.sort-select-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sort-select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

/* Music play button styling */
.play-row-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.play-row-btn:hover {
    color: var(--accent-color);
    background-color: rgba(0, 205, 60, 0.1);
    transform: scale(1.1);
}

tr.playing .play-row-btn {
    color: var(--accent-color);
    background-color: rgba(0, 205, 60, 0.1);
}

/* Bottom Player Bar */
.player-bar {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    background-color: #181818;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
}

/* Left part: Song info */
.player-song-info {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 30%;
    min-width: 180px;
}

.player-album-art {
    width: 56px;
    height: 56px;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.player-album-art.playing {
    border-color: var(--accent-color);
    animation: pulse 2s infinite;
}

.player-song-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.player-song-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.player-song-artist {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Center part: Controls & Progress */
.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 40%;
    max-width: 600px;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 24px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    color: var(--text-primary);
}

.play-btn {
    width: 36px;
    height: 36px;
    background-color: #fff;
    color: #000;
    border-radius: 50%;
    font-size: 14px;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

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

/* Progress bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.time-label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 35px;
    text-align: center;
}

.progress-bar-wrapper {
    flex: 1;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.progress-bar-wrapper:hover .progress-bar {
    background-color: var(--accent-color);
}

.progress-bar-wrapper:hover .progress-handle {
    opacity: 1;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--text-primary);
    border-radius: 2px;
    position: relative;
    transition: background-color 0.1s ease;
}

.progress-handle {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.1s ease;
}

/* Right part: Utils & Volume */
.player-utils {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 30%;
    justify-content: flex-end;
}

.volume-icon {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    width: 18px;
    text-align: center;
}

.volume-icon:hover {
    color: var(--text-primary);
}

.volume-slider-wrapper {
    width: 100px;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
}

.volume-slider {
    height: 100%;
    width: 100%; /* Default volume 100% */
    background-color: var(--text-secondary);
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

.volume-slider-wrapper:hover .volume-slider {
    background-color: var(--accent-color);
}

/* Keyframes & Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 205, 60, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(0, 205, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 205, 60, 0); }
}

.spinner-icon {
    animation: spin 1s linear infinite;
}

/* Responsive design */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none; /* Hide sidebar on small mobile, can implement slide later */
    }
    
    .main-content {
        grid-column: 1 / 2;
    }
    
    .player-bar {
        padding: 0 16px;
    }
    
    .player-song-info {
        width: 35%;
    }
    
    .player-controls {
        width: 45%;
    }
    
    .player-utils {
        width: 20%;
    }
    
    .volume-slider-wrapper {
        width: 60px;
    }
}

@media (max-width: 600px) {
    .player-song-info {
        width: 50%;
    }
    .player-controls {
        width: 50%;
    }
    .player-utils {
        display: none; /* Hide volume on extra small screens */
    }
    .top-bar {
        padding: 12px 16px;
    }
    .content-body {
        padding: 16px;
    }
    .search-container {
        width: 200px;
    }
}

/* 2차 업데이트 추가 스타일 */

/* 셔플, 반복 재생 활성화 상태 스타일 */
.control-btn.active {
    color: var(--accent-color) !important;
}

/* 좋아요 하트 버튼 */
.like-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.like-btn:hover {
    color: #ff3b30; /* Red on hover */
    background-color: rgba(255, 59, 48, 0.1);
    transform: scale(1.1);
}

.like-btn.liked {
    color: #ff3b30;
}

/* 플레이리스트 추가 버튼 */
.add-playlist-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-playlist-btn:hover {
    color: var(--accent-color);
    background-color: rgba(0, 205, 60, 0.1);
    transform: scale(1.1);
}

/* 모달 팝업 스타일 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 20px;
    max-height: 350px;
    overflow-y: auto;
}

/* 모달 내 플레이리스트 옵션 리스트 */
.playlist-selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.playlist-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.playlist-option-item:hover {
    border-color: var(--accent-color);
    background-color: rgba(0, 205, 60, 0.05);
}

.playlist-option-name {
    font-size: 14px;
    font-weight: 500;
}

.playlist-option-count {
    font-size: 12px;
    color: var(--text-muted);
}

.loading-text, .empty-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 20px 0;
}

/* 추가적인 버튼 스타일 */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 16px;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background-color: #ff3b30;
    color: #fff;
}

.btn-danger:hover {
    background-color: #e03126;
    transform: scale(1.02);
}

/* 입력 필드 공통 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    border-color: var(--accent-color);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* 모바일/반응형 높이 보정 */
.content-body {
    padding-bottom: 140px; /* 푸터 플레이어 바가 본문을 덮지 않도록 하단 스페이싱 넉넉히 확보 */
}

/* 3차 반응형 UI 업데이트 */

/* 햄버거 버튼 기본값 (데스크톱 및 태블릿에서는 미노출) */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    transition: color 0.2s ease;
}

.mobile-menu-btn:hover {
    color: var(--accent-color);
}

/* 사이드바 오버레이 기본값 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

/* 플레이어 앨범아트 이미지 스타일링 */
.player-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==========================================================================
   반응형 미디어 쿼리 구간 정의 (모바일: ~767px / 태블릿: 768~1023px / PC: 1024px~)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 모바일 (360px ~ 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    /* 레이아웃 구조 해제 */
    .app-container {
        grid-template-columns: 1fr; /* 사이드바를 그리드에서 배제 */
    }
    
    /* 사이드바를 슬라이드 오버 Drawer 메뉴로 강제 전환 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        grid-column: 1 / 2;
    }
    
    /* 상단 바 내 햄버거 버튼 노출 */
    .mobile-menu-btn {
        display: block;
    }
    
    .top-bar {
        padding: 12px 16px;
        justify-content: flex-start;
        gap: 8px;
    }
    
    .search-container {
        flex: 1;
        width: auto;
    }
    
    .user-profile {
        padding: 6px;
        border: none;
    }
    
    .user-profile span {
        display: none; /* 모바일 프로필 텍스트 감춤 */
    }
    
    .content-body {
        padding: 16px;
    }
    
    /* 대시보드 그리드 1열 고정 */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* ---------------------------------------------------------
       ★ 중요: 음악 목록 테이블 -> 모바일 전용 카드 뷰 전환
       --------------------------------------------------------- */
    .table-container {
        border: none;
        background: none;
    }
    
    .data-table, 
    .data-table thead, 
    .data-table tbody, 
    .data-table tr, 
    .data-table td {
        display: block;
    }
    
    .data-table thead {
        display: none; /* 테이블 헤더 헤드 숨김 */
    }
    
    .data-table tbody tr.song-item {
        background-color: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 12px;
        display: flex;
        align-items: center;
        position: relative;
        gap: 12px;
        transition: transform 0.2s ease, border-color 0.2s ease;
    }
    
    .data-table tbody tr.song-item:hover {
        border-color: #3a3a3a;
        transform: translateY(-2px);
    }
    
    .data-table tbody tr.song-item.playing {
        border-color: var(--accent-color);
        background-color: rgba(0, 205, 60, 0.03);
    }
    
    /* 개별 셀 레이아웃 개편 */
    .data-table td {
        padding: 0 !important;
        border-bottom: none;
        white-space: normal;
    }
    
    /* 순위 표시 숨김 혹은 위치조정 */
    .data-table td:nth-child(1) {
        /* 첫 셀이 순위(show_rank)일 때 혹은 재생 버튼일 때 */
    }
    
    /* 1. 재생 버튼 영역 */
    .data-table tr.song-item td:has(.play-row-btn) {
        order: 1;
        display: flex;
        align-items: center;
    }
    
    /* 2. 곡명 및 상세 정보 복합 배치 */
    .data-table tr.song-item td:nth-child(2),
    .data-table tr.song-item td:nth-child(3) {
        /* 이 구조에서는 공통 템플릿의 td 인덱스를 사용하므로 다음과 같이 정렬 */
    }
    
    /* 곡 카드 레이아웃을 위한 커스텀 구조화 */
    .data-table tr.song-item {
        flex-direction: row;
        justify-content: flex-start;
    }
    
    /* 첫 번째 열: 순위 혹은 재생 버튼 */
    .data-table tr.song-item td.text-center:first-child {
        order: 1;
        font-size: 16px;
        font-weight: 700;
        min-width: 24px;
    }
    
    /* 재생 버튼 */
    .data-table tr.song-item td:has(.play-row-btn) {
        order: 2;
    }
    
    /* 곡 정보 영역 (제목 + 아티스트) */
    .data-table tr.song-item td:nth-of-type(3) { /* 곡명 */
        order: 3;
        flex: 1;
        font-size: 14px;
        font-weight: 600;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .data-table tr.song-item td:nth-of-type(4) { /* 아티스트 */
        order: 4;
        font-size: 13px;
        color: var(--text-secondary);
        margin-right: auto;
        padding-left: 8px !important;
    }
    
    /* 모바일에서 앨범, 장르, 확장자 등 덜 중요한 열은 화면 공간을 위해 과감히 감춤 */
    .data-table tr.song-item td:nth-of-type(5), /* 앨범 */
    .data-table tr.song-item td:nth-of-type(6), /* 장르 */
    .data-table tr.song-item td:nth-of-type(8)  /* 포맷 */ {
        display: none !important;
    }
    
    /* 재생시간 */
    .data-table tr.song-item td:nth-of-type(7) {
        order: 5;
        font-size: 12px;
        color: var(--text-muted);
        margin-left: 8px;
    }
    
    /* 재생 횟수 */
    .data-table tr.song-item td.play-count-td {
        display: none !important; /* 모바일 목록에서는 재생 횟수 제외 */
    }
    
    /* 관리 버튼 영역 (좋아요, 추가, 제거) */
    .data-table tr.song-item td:last-child {
        order: 6;
        margin-left: auto;
        display: flex;
        gap: 4px;
    }
    
    .data-table tr.song-item .like-btn,
    .data-table tr.song-item .add-playlist-btn,
    .data-table tr.song-item .remove-playlist-song-btn {
        width: 36px;
        height: 36px; /* 모바일 터치 대응 크기 상향 */
        font-size: 16px;
    }
    
    /* ---------------------------------------------------------
       하단 고정 플레이어 모바일 최적화
       --------------------------------------------------------- */
    .player-bar {
        padding: 0 16px;
        height: 80px;
        gap: 12px;
    }
    
    .player-song-info {
        width: 45%;
        min-width: 0;
        gap: 10px;
    }
    
    .player-album-art {
        width: 44px;
        height: 44px;
    }
    
    .player-song-title {
        font-size: 13px;
    }
    
    .player-song-artist {
        font-size: 11px;
    }
    
    .player-controls {
        width: 55%;
        gap: 4px;
    }
    
    .control-buttons {
        gap: 12px;
    }
    
    /* 모바일에서는 랜덤/반복을 컨트롤러에서 숨겨 오작동 터치 방지 */
    #btn-shuffle,
    #btn-repeat {
        display: none !important;
    }
    
    .progress-container {
        width: 100%;
        gap: 6px;
    }
    
    .time-label {
        font-size: 9px;
        min-width: auto;
    }
    
    .player-utils {
        display: none !important; /* 모바일 볼륨 컨트롤러 제외 */
    }
    
    /* 관리자 스캔 대시보드 스캔 액션 섹션 */
    .scan-action-section {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    
    .scan-button-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }
    
    .scan-countdown-info {
        text-align: center;
    }
    
    /* 플레이리스트 목록 1열 정렬 */
    .playlists-page .data-table tr {
        background-color: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .playlists-page .data-table tr td {
        display: block;
        padding: 0 !important;
        text-align: left;
    }
    
    .playlists-page .data-table tr td.text-center {
        text-align: left;
    }
    
    /* 모달 팝업 너비 보정 */
    .modal-box {
        width: 95%;
        margin: 0 10px;
    }
}

/* ----------------------------------------------------------
   2. 태블릿 (768px ~ 1023px)
   ---------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1023px) {
    /* 태블릿 미니멀 사이드바 변환 */
    :root {
        --sidebar-width: 80px;
    }
    
    .sidebar {
        padding: 20px 8px;
    }
    
    .brand-name, 
    .nav-item span, 
    .sidebar-footer {
        display: none; /* 사이드바 아이콘만 노출 */
    }
    
    .brand {
        justify-content: center;
        padding-left: 0;
        margin-bottom: 24px;
    }
    
    .brand-icon {
        font-size: 24px;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .nav-icon {
        font-size: 20px;
    }
    
    .top-bar {
        padding: 16px 20px;
    }
    
    .content-body {
        padding: 20px;
    }
    
    /* 태블릿용 플레이어 바 여백 */
    .player-bar {
        padding: 0 20px;
    }
    
    .player-song-info {
        width: 25%;
    }
    
    .player-controls {
        width: 50%;
    }
    
    .player-utils {
        width: 25%;
    }
    
    .volume-slider-wrapper {
        width: 80px;
    }
}

/* ----------------------------------------------------------
   3. 데스크톱 (1024px 이상)
   ---------------------------------------------------------- */
@media (min-width: 1024px) {
    /* 1차, 2차의 기본 고사양 레이아웃 유지 */
    .app-container {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
}

/* 4차 대기열 및 확장 플레이어 스타일 추가 */

/* 1. 재생 대기열(Queue) 사이드 패널 */
.queue-panel {
    position: fixed;
    right: 0;
    bottom: 90px;
    width: 400px;
    height: 580px;
    background-color: #121212;
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    border-top-left-radius: 16px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: #1a1a1a;
}

.queue-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

/* 대기열 리스트 곡 아이템 */
.queue-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background-color 0.2s ease;
    gap: 12px;
}

.queue-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.queue-item.active {
    background-color: rgba(0, 205, 60, 0.08);
}

.queue-item-thumb {
    width: 38px;
    height: 38px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.queue-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.queue-item-meta {
    flex: 1;
    min-width: 0;
}

.queue-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.queue-item.active .queue-item-title {
    color: var(--accent-color);
}

.queue-item-artist {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-duration {
    font-size: 11px;
    color: var(--text-muted);
}

.queue-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 6px;
    transition: color 0.2s ease;
}

.queue-item-remove:hover {
    color: #ff3b30;
}

/* 대기열 비어있을 때 */
.queue-empty-text {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 60px 20px;
    font-size: 13px;
}


/* 2. 전체 화면 확장 플레이어 모달 */
.expand-player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 10, 10, 0.96);
    backdrop-filter: blur(20px);
    z-index: 1005;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInExpand 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.expand-player-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    padding: 40px;
    position: relative;
}

.expand-close {
    position: absolute;
    top: 24px;
    left: 40px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
}

.expand-close:hover {
    transform: translateY(2px);
    color: var(--accent-color);
}

/* 플레이어 본체 */
.expand-player-main {
    flex: 1;
    display: flex;
    gap: 48px;
    margin-top: 30px;
    align-items: center;
    min-height: 0; /* flex 자식 스크롤 영역을 위해 중요 */
}

/* 좌측: 대형 앨범아트 색션 */
.expand-art-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.expand-album-art {
    width: 280px;
    height: 280px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 24px;
}

.expand-album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.expand-song-meta h2 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
    line-height: 1.3;
}

.expand-song-meta p {
    font-size: 15px;
    color: var(--accent-color);
    margin: 0;
}

/* 우측: 멀티 탭 영역 (대기열/가사) */
.expand-tab-section {
    flex: 1;
    height: 100%;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.expand-tab-headers {
    display: flex;
    background-color: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border-color);
}

.tab-header-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.tab-header-btn:hover {
    color: #fff;
}

.tab-header-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    background-color: rgba(255,255,255,0.01);
}

.expand-tab-content {
    flex: 1;
    overflow-y: auto;
    display: none;
}

.expand-tab-content.active {
    display: block;
}

/* 대기열 탭 내용 */
#expand-queue-list .queue-item {
    padding: 12px 20px;
}

/* 가사 탭 내용 */
.expand-lyrics-full-text {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    text-align: center;
    color: #ccc;
    font-size: 14px;
    line-height: 2.2;
}

/* 하단 플레이 제어 장치 */
.expand-player-controls {
    margin-top: 30px;
}

.expand-player-controls .progress-container {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto 24px;
}

.expand-player-controls .progress-bar-wrapper {
    flex: 1;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.expand-player-controls .progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 3px;
    position: relative;
    width: 0%;
}

.expand-player-controls .progress-handle {
    position: absolute;
    right: -6px;
    top: -4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    display: none;
}

.expand-player-controls .progress-bar-wrapper:hover .progress-handle {
    display: block;
}

.expand-control-buttons-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
    margin-bottom: 24px;
}

.expand-control-buttons-row .play-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #fff;
    color: #000;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
}

.expand-control-buttons-row .play-btn:hover {
    transform: scale(1.05);
}

.expand-actions-row {
    display: flex;
    justify-content: center;
    gap: 12px;
}


/* ==========================================================================
   애니메이션 효과
   ========================================================================== */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes fadeInExpand {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* ==========================================================================
   반응형 추가 보완 (모바일 환경에서의 확장 플레이어 전체화면)
   ========================================================================== */
@media (max-width: 767px) {
    /* 모바일에서는 대기열 패널을 하단바 위가 아닌 전체화면 모달로 변환 */
    .queue-panel {
        bottom: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        z-index: 1006;
    }
    
    /* 모바일 확장 플레이어 최적화 */
    .expand-player-overlay {
        z-index: 1007; /* 대기열 위에 올라와야 함 */
    }
    
    .expand-player-container {
        padding: 20px;
        max-height: 100%;
        justify-content: space-between;
    }
    
    .expand-close {
        top: 20px;
        left: 20px;
    }
    
    .expand-player-main {
        flex-direction: column;
        gap: 20px;
        margin-top: 40px;
        overflow-y: auto;
    }
    
    .expand-art-section {
        width: 100%;
    }
    
    .expand-album-art {
        width: 200px;
        height: 200px;
        margin-bottom: 16px;
    }
    
    .expand-song-meta h2 {
        font-size: 18px;
    }
    
    .expand-song-meta p {
        font-size: 13px;
    }
    
    .expand-tab-section {
        width: 100%;
        height: 240px;
        min-height: 200px;
    }
    
    .expand-control-buttons-row {
        gap: 16px;
        margin-bottom: 16px;
    }
    
    .expand-control-buttons-row .play-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
    
    .expand-actions-row {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==========================================================================
   9차: 그룹형 사이드바, 모바일 메뉴, 관리 대시보드
   ========================================================================== */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 96px;
    scrollbar-width: thin;
}

.sidebar-search-form {
    display: grid;
    grid-template-columns: 18px 1fr 32px;
    align-items: center;
    gap: 8px;
    margin: 4px 0 14px;
    padding: 8px 8px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-secondary);
}

.sidebar-search-form input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-color);
    font-size: 13px;
}

.sidebar-search-form button {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 7px;
    background: var(--accent-color);
    color: #fff;
    cursor: pointer;
}

.sidebar-single-menu,
.menu-group-items {
    display: grid;
    gap: 3px;
}

.menu-group {
    margin-top: 12px;
}

.menu-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    cursor: pointer;
}

.menu-group-toggle i {
    transition: transform 0.18s ease;
    font-size: 11px;
}

.menu-group.collapsed .menu-group-toggle i {
    transform: rotate(-90deg);
}

.menu-group.collapsed .menu-group-items {
    display: none;
}

.nav-item {
    min-height: 40px;
    border-radius: 8px;
    gap: 10px;
}

.nav-item .nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item.active {
    background: color-mix(in srgb, var(--accent-color) 16%, transparent);
    color: var(--accent-color);
    font-weight: 800;
}

.nav-item.active .nav-icon {
    color: var(--accent-color);
}

.sidebar-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.sidebar-quick-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}

.sidebar-quick-actions a:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.sidebar-compact {
    --sidebar-width: 92px;
}

.sidebar-compact .brand-name,
.sidebar-compact .sidebar-search-form,
.sidebar-compact .menu-group-toggle span,
.sidebar-compact .nav-label,
.sidebar-compact .sidebar-footer,
.sidebar-compact .sidebar-quick-actions span {
    display: none;
}

.sidebar-compact .sidebar-scroll {
    padding-left: 8px;
    padding-right: 8px;
}

.sidebar-compact .nav-item {
    justify-content: center;
    padding: 12px;
}

.sidebar-compact .menu-group-toggle {
    justify-content: center;
}

.sidebar-compact .sidebar-quick-actions {
    grid-template-columns: 1fr;
}

.dashboard-quick-actions,
.admin-card-grid,
.missing-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.missing-file-grid {
    display: none;
}

.quick-action-card,
.admin-hub-card,
.missing-file-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    min-width: 0;
}

.quick-action-card:hover,
.admin-hub-card:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.quick-action-card i,
.admin-hub-card i {
    font-size: 20px;
}

.quick-action-card strong,
.admin-hub-card strong,
.missing-file-card strong {
    overflow-wrap: anywhere;
}

.admin-alert-list,
.admin-log-list {
    display: grid;
    gap: 10px;
}

.admin-log-row,
.admin-alert-row {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.admin-alert-row strong,
.admin-log-row strong {
    display: block;
    margin-bottom: 4px;
}

.status-badge-missing {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 59, 48, 0.12);
    color: #ff6b61;
    font-size: 12px;
    font-weight: 800;
}

.metadata-bulk-actions {
    display: flex;
    justify-content: flex-end;
    margin: 12px 0;
}

.metadata-card-list {
    display: none;
}

.metadata-mobile-card,
.metadata-status-panel {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
}

.metadata-mobile-card {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metadata-status-panel {
    display: grid;
    gap: 8px;
    padding: 14px;
    margin: 12px 0;
}

.metadata-error {
    color: #ff6b61;
    overflow-wrap: anywhere;
}

.metadata-badge {
    display: inline-flex;
    margin: 2px;
    padding: 3px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 14%, transparent);
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 800;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.song-title-link,
.compact-title,
.player-song-title,
.player-song-artist {
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-cover,
.compact-cover,
.player-album-art,
.album-art-large,
.album-art-large img {
    aspect-ratio: 1 / 1;
}

@media (max-width: 1023px) and (min-width: 768px) {
    body:not(.sidebar-compact) {
        --sidebar-width: 220px;
    }

    .sidebar-search-form {
        grid-template-columns: 1fr 32px;
    }

    .sidebar-search-form > i {
        display: none;
    }
}

@media (max-width: 767px) {
    .sidebar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: min(86vw, 340px);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-104%);
        transition: transform 0.22s ease;
        z-index: 1004;
        padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-scroll {
        padding-bottom: calc(118px + env(safe-area-inset-bottom));
    }

    .sidebar-footer {
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .menu-group:not(.has-active) {
        margin-top: 8px;
    }

    .nav-item {
        min-height: 44px;
    }

    .top-bar {
        gap: 10px;
    }

    .search-container {
        min-width: 0;
    }

    .dashboard-quick-actions,
    .admin-card-grid,
    .missing-file-grid {
        grid-template-columns: 1fr;
    }

    .missing-file-grid {
        display: grid;
    }

    .missing-files-page .metadata-table {
        display: none;
    }

    .metadata-table-container {
        display: none;
    }

    .metadata-bulk-actions {
        display: none;
    }

    .metadata-card-list {
        display: grid;
        gap: 12px;
    }

    .metadata-edit-form,
    .settings-grid,
    .maintenance-actions,
    .filter-sort-form,
    .list-filter-section {
        max-width: 100%;
    }

    .metadata-edit-form label,
    .settings-card label {
        min-width: 0;
    }

    .song-action-group,
    .maintenance-actions,
    .form-actions {
        flex-wrap: wrap;
    }

    .player-bar {
        min-width: 0;
        gap: 8px;
    }

    .player-song-info {
        min-width: 0;
        flex: 1 1 auto;
    }

    .player-song-details {
        min-width: 0;
    }

    .player-utils .volume-icon,
    .player-utils .volume-slider-wrapper,
    #btn-shuffle,
    #btn-repeat {
        display: none;
    }

    .content-body {
        padding-bottom: calc(120px + env(safe-area-inset-bottom));
    }
}

.auth-page {
    min-height: calc(100vh - 140px);
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 440px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow-sm, 0 8px 24px rgba(0, 0, 0, 0.08));
}

.auth-heading {
    display: grid;
    gap: 8px;
    margin-bottom: 22px;
    text-align: center;
}

.auth-heading i {
    color: var(--accent-color);
    font-size: 34px;
}

.auth-heading h1 {
    margin: 0;
    color: var(--text-color);
}

.auth-heading p,
.auth-card p {
    color: var(--muted-text, #6b7280);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    color: var(--text-color);
}

.auth-form input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    background: var(--input-bg, var(--card-bg));
    color: var(--text-color);
}

.auth-submit {
    min-height: 46px;
    justify-content: center;
}

.admin-session-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.no-player-page .content-body {
    padding-bottom: 32px;
}

@media (max-width: 767px) {
    .auth-page {
        min-height: auto;
        padding: 12px 0 32px;
        place-items: start stretch;
    }

    .auth-card {
        padding: 20px;
    }

    .admin-session-card {
        align-items: stretch;
        flex-direction: column;
    }
}
/* Admin diagnostics and logs */
.diagnostics-page,
.logs-page,
.performance-page,
.alerts-page {
    min-width: 0;
}

.diagnostic-grid,
.alert-grid,
.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.diagnostic-card,
.alert-card,
.performance-card,
.log-detail-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 16px;
    min-width: 0;
}

.diagnostic-card h3,
.alert-card h3,
.performance-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.diagnostic-card p,
.alert-card p,
.performance-card p,
.log-detail-card p {
    overflow-wrap: anywhere;
}

.diagnostic-badge,
.log-level {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-ok,
.level-info {
    background: rgba(0, 199, 60, 0.12);
    color: #047831;
}

.status-warning,
.level-warning {
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.status-error,
.level-error,
.level-critical {
    background: rgba(239, 68, 68, 0.14);
    color: #b91c1c;
}

.status-unknown {
    background: rgba(107, 114, 128, 0.14);
    color: #4b5563;
}

.log-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 16px;
}

.log-filter-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.log-message-cell {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-card-list {
    display: none;
}

.log-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
}

.log-card p {
    overflow-wrap: anywhere;
}

.log-context,
.log-detail-pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: rgba(127, 127, 127, 0.08);
    border-radius: 8px;
    padding: 12px;
    max-width: 100%;
    overflow-x: auto;
}

@media (max-width: 767px) {
    .log-filter-form,
    .maintenance-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .log-filter-form label,
    .log-filter-form .btn,
    .maintenance-actions .btn {
        width: 100%;
    }

    .log-table {
        display: none;
    }

    .log-card-list {
        display: block;
    }

    .diagnostic-grid,
    .alert-grid,
    .performance-grid {
        grid-template-columns: 1fr;
    }
}

/* 14차: player surfaces must follow the active theme even when older rules appear earlier. */
.player-bar,
.queue-panel,
.expand-player-container,
.expand-tab-section,
.lyrics-panel,
.modal-content {
    background: var(--player-bg, var(--card-bg, #fff)) !important;
    color: var(--player-text, var(--text-color, #222)) !important;
    border-color: var(--player-border, var(--border-color, #ddd)) !important;
}

.player-bar .player-title,
.player-bar .player-artist,
.player-bar .time-current,
.player-bar .time-total,
.queue-panel,
.queue-item,
.queue-item-title,
.queue-item-artist,
.expand-player-container,
.expand-player-title,
.expand-player-artist,
.expand-player-album,
.lyrics-line,
.mini-lyrics-line {
    color: var(--player-text, var(--text-color, #222)) !important;
}

.player-bar button,
.queue-panel button,
.expand-player-container button,
.player-control-btn,
.expand-control-btn {
    color: var(--player-text, var(--text-color, #222)) !important;
}

.player-bar button:hover,
.queue-panel button:hover,
.expand-player-container button:hover,
.queue-item:hover {
    background: var(--player-hover-bg, rgba(0, 0, 0, 0.06)) !important;
}

.progress-bar,
.expand-player-controls .progress-bar,
.volume-bar {
    background: var(--accent-color, var(--primary-color, #00c73c)) !important;
}

.progress-container,
.expand-player-controls .progress-bar-wrapper,
.volume-wrapper {
    background: var(--player-progress-bg, rgba(0, 0, 0, 0.14)) !important;
}

.melon-lite-toast {
    position: fixed;
    left: 50%;
    bottom: calc(104px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px);
    z-index: 1200;
    max-width: min(420px, calc(100vw - 28px));
    padding: 11px 14px;
    border-radius: 8px;
    background: var(--player-elevated, var(--card-bg));
    color: var(--player-text, var(--text-color));
    border: 1px solid var(--player-border, var(--border-color));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    font-size: 14px;
}

.melon-lite-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.melon-lite-toast[data-type="error"] {
    border-color: color-mix(in srgb, #ef4444 52%, var(--player-border, #ddd));
}

.expand-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

@supports (padding: max(0px)) {
    .player-bar {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 767px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .app-main,
    .content-body,
    .admin-dashboard,
    .settings-page {
        padding-bottom: calc(132px + env(safe-area-inset-bottom)) !important;
    }

    .player-bar {
        width: 100%;
        max-width: 100vw;
        min-height: calc(84px + env(safe-area-inset-bottom));
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom)) !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        overflow: hidden;
    }

    .player-song-info {
        min-width: 0;
        gap: 9px;
    }

    .player-song-details,
    .player-song-title,
    .player-song-artist {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .player-album-art {
        width: 46px;
        height: 46px;
        flex: 0 0 46px;
    }

    .player-controls {
        min-width: 0;
    }

    .control-buttons {
        gap: 4px;
    }

    .control-btn {
        min-width: 40px;
        min-height: 40px;
        touch-action: manipulation;
    }

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

    .progress-container {
        width: 100%;
        min-width: 0;
        gap: 6px;
    }

    .progress-bar-wrapper,
    .expand-player-controls .progress-bar-wrapper {
        min-height: 18px;
        display: flex;
        align-items: center;
    }

    .player-utils {
        display: none;
    }

    .queue-panel {
        height: calc(100dvh - env(safe-area-inset-top));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .expand-player-overlay {
        align-items: stretch;
        padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    }

    .expand-player-container {
        width: 100%;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 0;
        padding: 18px 14px calc(22px + env(safe-area-inset-bottom)) !important;
    }

    .expand-close {
        position: sticky;
        top: 8px;
        z-index: 2;
        align-self: flex-start;
    }

    .expand-tab-headers {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .expand-tab-headers::-webkit-scrollbar {
        display: none;
    }

    .expand-control-buttons-row {
        gap: 8px;
        justify-content: center;
    }

    .expand-secondary-actions .btn {
        min-height: 38px;
    }

    .pwa-install-banner {
        left: 10px;
        right: 10px;
        bottom: calc(94px + env(safe-area-inset-bottom));
        max-width: none;
    }

    .melon-lite-toast {
        bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

body.pjax-loading .content-body {
    position: relative;
}

body.pjax-loading .content-body::before {
    content: "";
    position: sticky;
    top: 0;
    display: block;
    height: 3px;
    width: 100%;
    z-index: 30;
    background: linear-gradient(90deg, transparent, var(--accent-color, #00c73c), transparent);
    animation: pjaxLoadingBar 1s infinite linear;
}

@keyframes pjaxLoadingBar {
    from { transform: translateX(-60%); }
    to { transform: translateX(60%); }
}

/* 15차: playlist polish */
.playlist-polish-page {
    max-width: 1180px;
    margin: 0 auto;
    padding-bottom: 120px;
}

.playlist-hero,
.playlist-detail-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.playlist-create-card,
.playlist-card,
.playlist-song-item,
.playlist-toolbar,
.playlist-detail-hero {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
}

.playlist-create-card {
    padding: 16px;
    margin-bottom: 18px;
}

.playlist-create-card h2 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.playlist-inline-form,
.playlist-filter-form,
.playlist-action-row,
.playlist-card-actions,
.playlist-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.playlist-inline-form input {
    min-width: 200px;
    flex: 1 1 220px;
}

.playlist-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.playlist-card {
    overflow: hidden;
    min-width: 0;
}

.playlist-card-cover {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    aspect-ratio: 1 / 1;
    background: var(--player-progress-bg, rgba(0, 0, 0, 0.08));
}

.playlist-card-cover img,
.playlist-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-width: 0;
}

.playlist-card-cover img:only-child {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
}

.playlist-card-body {
    padding: 14px;
    min-width: 0;
}

.playlist-card-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-color, #222);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-card-body p {
    min-height: 42px;
    margin: 8px 0;
    color: var(--text-secondary, #666);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.playlist-card-meta,
.playlist-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-muted, #777);
    font-size: 0.86rem;
}

.playlist-card-actions form {
    margin: 0;
}

.playlist-detail-hero {
    padding: 18px;
    align-items: stretch;
}

.playlist-detail-cover {
    width: 180px;
    min-width: 180px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: var(--player-progress-bg, rgba(0, 0, 0, 0.08));
}

.playlist-detail-cover img:only-child {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
}

.playlist-detail-meta {
    min-width: 0;
    flex: 1;
}

.breadcrumb-link {
    display: inline-flex;
    gap: 6px;
    color: var(--accent-color, #00c73c);
    text-decoration: none;
    margin-bottom: 8px;
    font-weight: 700;
}

.playlist-action-row {
    margin-top: 14px;
}

.playlist-toolbar {
    justify-content: space-between;
    padding: 12px;
    margin-bottom: 12px;
}

.playlist-filter-form {
    flex: 1 1 360px;
}

.playlist-filter-form .form-control {
    flex: 1 1 220px;
}

.playlist-song-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.playlist-song-item {
    display: grid;
    grid-template-columns: 70px 44px 52px minmax(0, 1.5fr) minmax(130px, 0.8fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    min-width: 0;
}

.playlist-song-item.playing {
    border-color: var(--accent-color, #00c73c);
    box-shadow: 0 0 0 1px var(--accent-color, #00c73c);
}

.playlist-song-item.is-missing {
    opacity: 0.72;
}

.playlist-song-order {
    display: flex;
    align-items: center;
    gap: 8px;
}

.playlist-order-number {
    width: 28px;
    text-align: right;
    font-weight: 800;
    color: var(--text-muted, #777);
}

.playlist-order-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.playlist-move-btn {
    width: 28px;
    min-width: 28px;
    height: 24px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: transparent;
    color: var(--text-color, #222);
    cursor: pointer;
}

.playlist-row-play {
    width: 40px;
    height: 40px;
}

.playlist-song-main,
.playlist-song-sub {
    min-width: 0;
}

.playlist-song-main .song-title-link,
.playlist-song-main span,
.playlist-song-sub span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-song-main span,
.playlist-song-sub {
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
}

.playlist-song-sub {
    display: grid;
    gap: 2px;
}

.playlist-song-actions {
    justify-content: flex-end;
}

.playlist-save-order-btn.is-dirty {
    border-color: var(--accent-color, #00c73c);
    color: var(--accent-color, #00c73c);
}

.missing-badge {
    display: inline-flex;
    width: max-content;
    margin-top: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    font-size: 0.75rem;
    font-weight: 700;
}

@media (max-width: 1023px) {
    .playlist-song-item {
        grid-template-columns: 58px 40px 52px minmax(0, 1fr) auto;
    }

    .playlist-song-sub {
        grid-column: 4 / -1;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 767px) {
    .playlist-hero,
    .playlist-detail-hero {
        flex-direction: column;
    }

    .playlist-detail-cover {
        width: 100%;
        min-width: 0;
        max-width: 220px;
    }

    .playlist-inline-form,
    .playlist-filter-form,
    .playlist-action-row,
    .playlist-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .playlist-inline-form input,
    .playlist-filter-form .form-control,
    .playlist-toolbar .btn,
    .playlist-action-row .btn {
        width: 100%;
    }

    .playlist-card-grid {
        grid-template-columns: 1fr;
    }

    .playlist-song-item {
        grid-template-columns: 46px 42px 48px minmax(0, 1fr);
        align-items: start;
    }

    .playlist-song-sub,
    .playlist-song-actions {
        grid-column: 4 / -1;
    }

    .playlist-song-actions {
        justify-content: flex-start;
    }

    .playlist-order-buttons {
        flex-direction: row;
    }

    .playlist-move-btn {
        width: 26px;
        height: 30px;
    }
}

/* Backup center */
.backup-center-page {
    max-width: 1180px;
}

.backup-summary-grid,
.backup-two-column,
.backup-table-counts,
.form-grid {
    display: grid;
    gap: 14px;
}

.backup-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-bottom: 18px;
}

.backup-two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 18px;
}

.backup-summary-card,
.check-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.backup-summary-card {
    padding: 16px;
    min-width: 0;
}

.backup-summary-card span,
.backup-summary-card small,
.backup-file-main small,
.backup-file-status small {
    color: var(--text-muted);
}

.backup-summary-card strong {
    display: block;
    margin: 6px 0;
    color: var(--text-color);
    font-size: 1.35rem;
}

.backup-form {
    display: grid;
    gap: 12px;
}

.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.check-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px;
    min-height: 44px;
}

.check-card input {
    width: 18px;
    height: 18px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    width: max-content;
    max-width: 100%;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    background: var(--surface-color);
    color: var(--text-color);
}

.status-badge.ok,
.notice-success {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.status-badge.info {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}

.status-badge.danger,
.notice-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.danger-zone {
    border-color: rgba(239, 68, 68, 0.24);
}

.backup-table-counts {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.backup-table-counts div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-color);
    min-width: 0;
}

.backup-table-counts span,
.backup-file-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.backup-file-list {
    display: grid;
    gap: 12px;
}

.backup-file-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.backup-file-main,
.backup-file-status,
.backup-file-actions {
    min-width: 0;
}

.backup-file-main,
.backup-file-status {
    display: grid;
    gap: 5px;
}

.backup-file-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.backup-file-actions form {
    margin: 0;
}

.backup-table-wrap {
    overflow-x: auto;
    max-width: 100%;
}

.backup-table {
    width: 100%;
    border-collapse: collapse;
}

.backup-table th,
.backup-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.backup-message-list {
    margin: 0 0 14px;
    padding-left: 20px;
}

.backup-message-list.muted {
    color: var(--text-muted);
}

.danger-confirm-input {
    min-width: 150px;
    border-color: rgba(239, 68, 68, 0.45) !important;
    background: color-mix(in srgb, var(--card-bg) 92%, rgba(239, 68, 68, 0.12)) !important;
}

@media (max-width: 767px) {
    .backup-two-column,
    .backup-file-card {
        grid-template-columns: 1fr;
    }

    .backup-file-actions {
        justify-content: stretch;
    }

    .backup-file-actions .btn,
    .backup-file-actions form,
    .backup-form .btn {
        width: 100%;
    }

    .backup-table-counts {
        grid-template-columns: 1fr;
    }
}

/* Enhanced search */
.enhanced-search-page {
    max-width: 1180px;
}

.enhanced-search-form,
.sidebar-search-form,
.quick-search-form {
    position: relative;
}

.quick-suggest-box {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: min(420px, 70vh);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.quick-suggest-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "type title play"
        "type sub play";
    gap: 2px 10px;
    align-items: center;
    padding: 9px;
    border-radius: 8px;
    cursor: pointer;
}

.quick-suggest-item:hover {
    background: var(--surface-color);
}

.quick-suggest-item .suggest-type {
    grid-area: type;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 800;
}

.quick-suggest-item strong {
    grid-area: title;
    min-width: 0;
    overflow: hidden;
    color: var(--text-color);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-suggest-item small {
    grid-area: sub;
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggest-play-btn {
    grid-area: play;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: var(--accent-color);
    color: #fff;
    cursor: pointer;
}

.search-recent-panel,
.advanced-filter-panel {
    margin: 16px 0;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.advanced-filter-panel summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 800;
}

.advanced-filter-form {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.filter-grid label,
.filter-check-row label {
    display: grid;
    gap: 6px;
    min-width: 0;
    color: var(--text-color);
    font-weight: 700;
}

.filter-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.filter-check-row label {
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 36px;
}

.filter-check-row input {
    width: 18px;
    height: 18px;
}

.filter-actions,
.active-filter-badges,
.recent-search-list,
.search-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-badge,
.recent-search-chip,
.pager-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-color);
    text-decoration: none;
    max-width: 100%;
}

.filter-badge span,
.recent-search-chip small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.pager-link.active {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: #fff;
}

.search-category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.media-explore-card {
    grid-template-columns: 48px minmax(0, 1fr);
}

.media-explore-card img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    grid-row: span 2;
}

@media (max-width: 767px) {
    .search-category-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .enhanced-search-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .enhanced-search-form .btn,
    .filter-actions .btn {
        width: 100%;
    }

    .quick-suggest-box {
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        bottom: calc(var(--player-height, 92px) + 14px);
        max-height: 55vh;
    }

    .quick-suggest-item {
        grid-template-columns: auto minmax(0, 1fr) 34px;
    }
}

/* 22차 모바일/PWA 플레이어 final pass */
@media (max-width: 767px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .player-bar {
        box-sizing: border-box;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        min-height: calc(84px + env(safe-area-inset-bottom));
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom)) !important;
        overflow: hidden;
    }

    .content-body,
    .app-main,
    .main-content {
        padding-bottom: calc(132px + env(safe-area-inset-bottom)) !important;
    }

    .player-song-info,
    .player-song-details {
        min-width: 0;
    }

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

    .progress-bar-wrapper {
        min-height: 18px;
    }

    .expand-player-container {
        width: 100%;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        border-radius: 0 !important;
        padding-bottom: calc(22px + env(safe-area-inset-bottom)) !important;
    }

    .melon-lite-toast,
    .pwa-install-banner {
        max-width: calc(100vw - 20px);
    }
}
/* 23차 자동 플레이리스트/추천 모바일 보정 */
@media (max-width: 767px) {
    .auto-playlist-actions,
    .auto-save-row {
        align-items: stretch;
    }

    .auto-playlist-actions .btn,
    .auto-save-row .btn,
    .auto-save-row .form-control {
        width: 100%;
    }

    .recommend-reason-badge {
        white-space: normal;
        text-align: left;
    }
}
/* 25차 PWA 설치 안내/플레이어 레이어 최종 정리 */
:root {
    --z-sidebar-overlay: 900;
    --z-sidebar: 1000;
    --z-player: 1300;
    --z-install-banner: 1320;
    --z-toast: 1340;
    --z-queue: 1350;
    --z-expanded-player: 1500;
    --z-modal: 1600;
}

.player-bar {
    z-index: var(--z-player) !important;
}

.queue-panel {
    z-index: var(--z-queue) !important;
}

.expand-player-overlay {
    z-index: var(--z-expanded-player) !important;
}

.modal-overlay,
.pwa-guide-modal {
    z-index: var(--z-modal) !important;
}

.melon-lite-toast,
.guest-preview-prompt {
    z-index: var(--z-toast) !important;
}

.pwa-install-banner {
    left: auto !important;
    right: 18px !important;
    bottom: calc(var(--player-height) + 18px + env(safe-area-inset-bottom)) !important;
    width: min(390px, calc(100vw - var(--sidebar-width) - 52px)) !important;
    max-width: calc(100vw - 32px) !important;
    z-index: var(--z-install-banner) !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    border-radius: 999px !important;
}

.pwa-install-banner .pwa-install-copy {
    min-width: 0;
    gap: 0 !important;
}

.pwa-install-banner .pwa-install-copy strong {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-install-banner .pwa-install-copy span {
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-install-banner .pwa-install-actions {
    flex: 0 0 auto !important;
    flex-direction: row !important;
    gap: 6px !important;
}

.pwa-install-banner .btn {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
    border-radius: 999px;
}

.pwa-install-banner .modal-close-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 999px;
}

.pwa-guide-modal[hidden] {
    display: none;
}

.pwa-guide-modal {
    position: fixed;
    inset: 0;
}

.pwa-guide-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.46);
}

.pwa-guide-card {
    position: absolute;
    left: 50%;
    bottom: calc(var(--player-height) + 24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(420px, calc(100vw - 28px));
    max-height: min(70dvh, 460px);
    overflow-y: auto;
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.pwa-guide-card h2 {
    margin: 0 40px 12px 0;
    font-size: 18px;
}

.pwa-guide-body {
    color: var(--text-secondary);
    line-height: 1.6;
}

.guest-preview-prompt {
    position: fixed;
    right: 18px;
    bottom: calc(var(--player-height) + 18px + env(safe-area-inset-bottom));
    width: min(390px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

.guest-preview-copy {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 3px;
}

.guest-preview-copy span {
    color: var(--text-secondary);
    font-size: 12px;
}

.guest-preview-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.player-preview-badge {
    display: inline-flex;
    width: fit-content;
    margin-top: 3px;
    padding: 2px 7px;
    border-radius: 999px;
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 12%, transparent);
    font-size: 11px;
    font-weight: 700;
}

body.guest-preview-ended .pwa-install-banner {
    display: none !important;
}

@media (max-width: 1023px) {
    .pwa-install-banner {
        width: min(360px, calc(100vw - 24px)) !important;
        right: 12px !important;
    }
}

@media (max-width: 767px) {
    .pwa-install-banner {
        left: 12px !important;
        right: 12px !important;
        bottom: calc(var(--player-height) + 16px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        border-radius: 14px !important;
        align-items: stretch !important;
    }

    .pwa-install-banner .pwa-install-actions {
        justify-content: flex-end;
    }

    .pwa-install-banner .pwa-install-copy span {
        display: none;
    }

    .pwa-guide-card {
        bottom: calc(var(--player-height) + 16px + env(safe-area-inset-bottom));
        width: calc(100vw - 24px);
        max-height: calc(100dvh - var(--player-height) - 58px - env(safe-area-inset-bottom));
    }

    .guest-preview-prompt {
        left: 12px;
        right: 12px;
        bottom: calc(var(--player-height) + 16px + env(safe-area-inset-bottom));
        width: auto;
        align-items: stretch;
        flex-direction: column;
    }

    .guest-preview-actions .btn {
        flex: 1 1 120px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-install-banner,
    .pwa-guide-card,
    .guest-preview-prompt {
        transition: none !important;
        animation: none !important;
    }
}

/* 32차 최종 우선순위 보정: light theme, sidebar expand handle, tablet player */
body.theme-light {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf2f7;
    --surface: #ffffff;
    --surface-soft: #f3f6fa;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --text-color: #111827;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --muted-text: #6b7280;
    --border-color: #d8e1ea;
    --sidebar-bg: #ffffff;
    --player-bg: #ffffff;
    --player-surface: #f6f8fb;
    --player-elevated: #ffffff;
    --player-text: #111827;
    --player-muted: #4b5563;
    --player-border: #d8e1ea;
    --player-progress-bg: #e2e8f0;
    --player-button-bg: #111827;
    --player-button-text: #ffffff;
    --ui-bg: #f6f8fb;
    --ui-surface: #ffffff;
    --ui-card-bg: #ffffff;
    --ui-soft-bg: #f3f7f5;
    --ui-border: #d8e1ea;
}

body.theme-light,
body.theme-light .app-container,
body.theme-light .main-content,
body.theme-light .content-body {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body.theme-light .top-bar,
body.theme-light .sidebar,
body.theme-light .player-bar,
body.theme-light .expanded-player,
body.theme-light .queue-panel,
body.theme-light .modal-box,
body.theme-light .pwa-install-card,
body.theme-light .pwa-guide-card,
body.theme-light .guest-preview-card,
body.theme-light .melon-lite-toast,
body.theme-light .stats-card,
body.theme-light .library-stat-card,
body.theme-light .entity-card,
body.theme-light .genre-card,
body.theme-light .explore-card,
body.theme-light .auto-playlist-card,
body.theme-light .playlist-card,
body.theme-light .quick-action-card,
body.theme-light .admin-card,
body.theme-light .form-card,
body.theme-light .panel,
body.theme-light .section-card {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light .top-bar {
    background: color-mix(in srgb, var(--surface) 92%, transparent) !important;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea,
body.theme-light .search-input,
body.theme-light .filter-input {
    background: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light input::placeholder,
body.theme-light textarea::placeholder,
body.theme-light .search-input::placeholder {
    color: #8a96a8 !important;
}

body.theme-light table,
body.theme-light .data-table,
body.theme-light .song-list-table,
body.theme-light .admin-table {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light th,
body.theme-light thead,
body.theme-light .table-header {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
}

body.theme-light .nav-item,
body.theme-light .menu-group-toggle,
body.theme-light .brand,
body.theme-light .card-title,
body.theme-light .player-track-title,
body.theme-light .expanded-title {
    color: var(--text-primary) !important;
}

body.theme-light .nav-item.active,
body.theme-light .menu-group.has-active > .menu-group-toggle {
    background: color-mix(in srgb, var(--accent-color) 14%, #ffffff) !important;
    color: #14532d !important;
    border-color: color-mix(in srgb, var(--accent-color) 34%, var(--border-color)) !important;
}

body.theme-light .muted,
body.theme-light .subtitle,
body.theme-light .nav-meta,
body.theme-light .card-meta,
body.theme-light .player-track-artist,
body.theme-light .expanded-artist,
body.theme-light .empty-text,
body.theme-light .loading-text {
    color: var(--text-secondary) !important;
}

body.theme-light .btn-secondary,
body.theme-light .btn-ghost,
body.theme-light .icon-btn,
body.theme-light .player-icon-btn,
body.theme-light .player-utility-btn {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light .play-btn,
body.theme-light .main-play-btn,
body.theme-light .player-play-btn,
body.theme-light .expanded-play-btn,
body.theme-light #btn-play-pause,
body.theme-light #expand-btn-play-pause {
    background: var(--player-button-bg) !important;
    color: var(--player-button-text) !important;
    border-color: var(--player-button-bg) !important;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.24) !important;
}

@media (min-width: 768px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        padding: 16px 10px 18px !important;
        overflow: visible !important;
    }

    body.sidebar-collapsed .brand {
        display: grid !important;
        grid-template-columns: 1fr !important;
        justify-items: center !important;
        gap: 10px !important;
        min-height: 100px !important;
        padding: 0 !important;
        margin-bottom: 16px !important;
    }

    body.sidebar-collapsed .brand-icon {
        width: 44px !important;
        height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        position: static !important;
        display: inline-flex !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        z-index: 45 !important;
        border-radius: 14px !important;
        background: var(--surface-soft) !important;
        color: var(--text-primary) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12) !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --player-height: 104px;
        --sidebar-width: 230px;
        --sidebar-collapsed-width: 76px;
    }

    .app-container {
        grid-template-rows: minmax(0, 1fr) auto !important;
    }

    .player-bar {
        height: auto !important;
        min-height: calc(var(--player-height) + var(--safe-bottom)) !important;
        grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.35fr) auto !important;
        gap: 12px !important;
        padding: 10px 14px calc(10px + var(--safe-bottom)) !important;
        overflow: visible !important;
    }

    .player-song-info,
    .player-track-meta,
    .player-controls,
    .player-utils {
        min-width: 0 !important;
    }

    .control-buttons,
    .player-utils {
        gap: 8px !important;
    }

    .player-utils {
        justify-content: flex-end !important;
    }

    .player-utils .volume-icon,
    .player-utils .volume-slider-wrapper {
        display: none !important;
    }

    .content-body {
        padding-bottom: calc(var(--player-height) + 36px + var(--safe-bottom)) !important;
    }
}

/* 33차 EOF 운영 안정화: 최종 우선순위 */
html,
body {
    overflow-x: hidden;
}

.content-body {
    padding-bottom: max(140px, calc(var(--player-height) + 42px + var(--safe-bottom))) !important;
}

.no-player-page .content-body {
    padding-bottom: 40px !important;
}

.pwa-install-banner.pwa-install-modal,
.guest-preview-prompt.preview-premium-modal,
.modal-overlay,
.pwa-guide-modal {
    max-width: 100vw;
    max-height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
}

.pwa-install-card,
.guest-preview-card,
.pwa-guide-card,
.modal-box {
    max-width: min(560px, calc(100vw - 32px)) !important;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 48px);
    overflow: auto;
}

body.guest-preview-ended .pwa-install-banner,
body.guest-preview-ended .pwa-guide-modal {
    display: none !important;
}

.melon-lite-toast {
    bottom: calc(var(--player-height) + 18px + var(--safe-bottom)) !important;
    max-width: min(420px, calc(100vw - 32px)) !important;
}

body.pwa-install-open .melon-lite-toast,
body.guest-preview-ended .melon-lite-toast {
    bottom: calc(var(--player-height) + 24px + var(--safe-bottom)) !important;
}

.table-responsive,
.table-wrapper,
.song-table-wrapper,
.admin-table-wrapper,
.backup-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.theme-light .table-responsive,
body.theme-light .table-wrapper,
body.theme-light .song-table-wrapper,
body.theme-light .admin-table-wrapper,
body.theme-light .backup-table-wrapper {
    background: var(--surface);
    border-color: var(--border-color);
}

body.theme-light .alert-box,
body.theme-light .empty-state,
body.theme-light .empty-list-state,
body.theme-light .loading-text {
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light .alert-danger,
body.theme-light .alert-error {
    background: rgba(239, 68, 68, 0.10) !important;
    color: #7f1d1d !important;
}

body.theme-light .alert-warning {
    background: rgba(245, 158, 11, 0.12) !important;
    color: #78350f !important;
}

body.theme-light .alert-success {
    background: color-mix(in srgb, var(--accent-color) 11%, #ffffff) !important;
    color: #14532d !important;
}

body.theme-dark .stats-card,
body.theme-dark .library-stat-card,
body.theme-dark .entity-card,
body.theme-dark .genre-card,
body.theme-dark .explore-card,
body.theme-dark .auto-playlist-card,
body.theme-dark .playlist-card,
body.theme-dark .quick-action-card,
body.theme-dark .admin-card,
body.theme-dark .form-card,
body.theme-dark .panel,
body.theme-dark .section-card {
    border-color: color-mix(in srgb, var(--border-color, #2f3a35) 78%, #ffffff 8%);
}

@media (min-width: 768px) {
    body.sidebar-collapsed .main-content {
        min-width: 0;
    }

    body.sidebar-collapsed .content-body {
        max-width: min(1760px, 100%) !important;
    }

    body.sidebar-collapsed .sidebar-collapse-btn:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--accent-color) 42%, transparent);
        outline-offset: 3px;
    }
}

@media (max-width: 767px) {
    .content-body {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-bottom: calc(var(--player-height) + 42px + var(--safe-bottom)) !important;
    }

    .player-bar {
        max-width: 100vw !important;
        overflow: visible !important;
    }

    .pwa-install-card,
    .guest-preview-card,
    .pwa-guide-card,
    .modal-box {
        width: calc(100vw - 32px) !important;
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - var(--player-height) - 24px);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .content-body {
        padding-bottom: calc(var(--player-height) + 46px + var(--safe-bottom)) !important;
    }

    .player-bar {
        align-items: center !important;
    }
}

/* 33차 운영 안정화: 레이어, 반응형, 테마 회귀 방지 */
html,
body {
    overflow-x: hidden;
}

.content-body {
    padding-bottom: max(140px, calc(var(--player-height) + 42px + var(--safe-bottom))) !important;
}

.no-player-page .content-body {
    padding-bottom: 40px !important;
}

.pwa-install-banner.pwa-install-modal,
.guest-preview-prompt.preview-premium-modal,
.modal-overlay,
.pwa-guide-modal {
    max-width: 100vw;
    max-height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
}

.pwa-install-card,
.guest-preview-card,
.pwa-guide-card,
.modal-box {
    max-width: min(560px, calc(100vw - 32px)) !important;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 48px);
    overflow: auto;
}

body.guest-preview-ended .pwa-install-banner,
body.guest-preview-ended .pwa-guide-modal {
    display: none !important;
}

body.pwa-install-open .guest-preview-prompt.preview-premium-modal {
    z-index: calc(var(--z-modal, 1400) + 8) !important;
}

.melon-lite-toast {
    bottom: calc(var(--player-height) + 18px + var(--safe-bottom)) !important;
    max-width: min(420px, calc(100vw - 32px)) !important;
}

body.pwa-install-open .melon-lite-toast,
body.guest-preview-ended .melon-lite-toast {
    bottom: calc(var(--player-height) + 24px + var(--safe-bottom)) !important;
}

.table-responsive,
.table-wrapper,
.song-table-wrapper,
.admin-table-wrapper,
.backup-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

img[src=""],
img:not([src]) {
    visibility: hidden;
}

body.theme-light .table-responsive,
body.theme-light .table-wrapper,
body.theme-light .song-table-wrapper,
body.theme-light .admin-table-wrapper,
body.theme-light .backup-table-wrapper {
    background: var(--surface);
    border-color: var(--border-color);
}

body.theme-light .alert-box,
body.theme-light .empty-state,
body.theme-light .empty-list-state,
body.theme-light .loading-text {
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light .alert-danger,
body.theme-light .alert-error {
    background: rgba(239, 68, 68, 0.10) !important;
    color: #7f1d1d !important;
}

body.theme-light .alert-warning {
    background: rgba(245, 158, 11, 0.12) !important;
    color: #78350f !important;
}

body.theme-light .alert-success {
    background: color-mix(in srgb, var(--accent-color) 11%, #ffffff) !important;
    color: #14532d !important;
}

body.theme-dark .stats-card,
body.theme-dark .library-stat-card,
body.theme-dark .entity-card,
body.theme-dark .genre-card,
body.theme-dark .explore-card,
body.theme-dark .auto-playlist-card,
body.theme-dark .playlist-card,
body.theme-dark .quick-action-card,
body.theme-dark .admin-card,
body.theme-dark .form-card,
body.theme-dark .panel,
body.theme-dark .section-card {
    border-color: color-mix(in srgb, var(--border-color, #2f3a35) 78%, #ffffff 8%);
}

@media (min-width: 768px) {
    body.sidebar-collapsed .main-content {
        min-width: 0;
    }

    body.sidebar-collapsed .content-body {
        max-width: min(1760px, 100%) !important;
    }

    body.sidebar-collapsed .sidebar-collapse-btn:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--accent-color) 42%, transparent);
        outline-offset: 3px;
    }
}

@media (max-width: 767px) {
    .content-body {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-bottom: calc(var(--player-height) + 42px + var(--safe-bottom)) !important;
    }

    .player-bar {
        max-width: 100vw !important;
        overflow: visible !important;
    }

    .pwa-install-card,
    .guest-preview-card,
    .pwa-guide-card,
    .modal-box {
        width: calc(100vw - 32px) !important;
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - var(--player-height) - 24px);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .content-body {
        padding-bottom: calc(var(--player-height) + 46px + var(--safe-bottom)) !important;
    }

    .player-bar {
        align-items: center !important;
    }
}

/* 32차 업데이트: 라이트모드 전역 보정, 사이드바 재펼침, 태블릿 플레이어 짤림 방지 */
body.theme-light {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf2f7;
    --surface: #ffffff;
    --surface-soft: #f3f6fa;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --text-color: #111827;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --muted-text: #6b7280;
    --border-color: #d8e1ea;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #eef7f0;
    --shadow: 0 14px 34px rgba(15, 23, 42, 0.10);
    --player-bg: #ffffff;
    --player-surface: #f6f8fb;
    --player-elevated: #ffffff;
    --player-text: #111827;
    --player-muted: #4b5563;
    --player-border: #d8e1ea;
    --player-progress-bg: #e2e8f0;
    --player-button-bg: #111827;
    --player-button-text: #ffffff;
    --ui-bg: #f6f8fb;
    --ui-surface: #ffffff;
    --ui-card-bg: #ffffff;
    --ui-soft-bg: #f3f7f5;
    --ui-border: #d8e1ea;
}

body.theme-light,
body.theme-light .app-container,
body.theme-light .main-content,
body.theme-light .content-body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

body.theme-light .top-bar,
body.theme-light .sidebar,
body.theme-light .player-bar,
body.theme-light .expanded-player,
body.theme-light .queue-panel,
body.theme-light .modal-box,
body.theme-light .pwa-install-card,
body.theme-light .pwa-guide-card,
body.theme-light .guest-preview-card,
body.theme-light .melon-lite-toast {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light .top-bar {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

body.theme-light .sidebar {
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.05);
}

body.theme-light .brand,
body.theme-light .sidebar-section-title,
body.theme-light .nav-item,
body.theme-light .menu-group-toggle,
body.theme-light .player-track-title,
body.theme-light .expanded-title,
body.theme-light .card-title {
    color: var(--text-primary);
}

body.theme-light .muted,
body.theme-light .subtitle,
body.theme-light .nav-meta,
body.theme-light .player-track-artist,
body.theme-light .expanded-artist,
body.theme-light .card-meta,
body.theme-light .empty-text,
body.theme-light .loading-text {
    color: var(--text-secondary);
}

body.theme-light .nav-item:hover,
body.theme-light .menu-group-toggle:hover,
body.theme-light .sidebar-collapse-btn:hover,
body.theme-light .mobile-hamburger:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

body.theme-light .nav-item.active,
body.theme-light .menu-group.has-active > .menu-group-toggle {
    background: color-mix(in srgb, var(--accent-color) 14%, #ffffff);
    color: #14532d;
    border-color: color-mix(in srgb, var(--accent-color) 34%, var(--border-color));
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea,
body.theme-light .search-input,
body.theme-light .filter-input {
    background: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light input::placeholder,
body.theme-light textarea::placeholder,
body.theme-light .search-input::placeholder {
    color: #8a96a8;
}

body.theme-light table,
body.theme-light .data-table,
body.theme-light .song-list-table,
body.theme-light .admin-table {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light th,
body.theme-light .table-header,
body.theme-light thead {
    background: var(--surface-soft);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light td,
body.theme-light tr,
body.theme-light .table-row {
    border-color: var(--border-color);
}

body.theme-light .btn-secondary,
body.theme-light .btn-ghost,
body.theme-light .icon-btn,
body.theme-light .player-icon-btn,
body.theme-light .player-utility-btn {
    background: var(--surface-soft);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light .btn-secondary:hover,
body.theme-light .btn-ghost:hover,
body.theme-light .icon-btn:hover,
body.theme-light .player-icon-btn:hover,
body.theme-light .player-utility-btn:hover {
    background: #e8f2ec;
    border-color: color-mix(in srgb, var(--accent-color) 38%, var(--border-color));
    color: #14532d;
}

body.theme-light .play-btn,
body.theme-light .main-play-btn,
body.theme-light .player-play-btn,
body.theme-light .expanded-play-btn {
    background: var(--player-button-bg) !important;
    color: var(--player-button-text) !important;
    border-color: color-mix(in srgb, var(--player-button-bg) 88%, #ffffff) !important;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.22);
}

body.theme-light .play-btn:hover,
body.theme-light .main-play-btn:hover,
body.theme-light .player-play-btn:hover,
body.theme-light .expanded-play-btn:hover,
body.theme-light .play-btn:focus-visible,
body.theme-light .main-play-btn:focus-visible,
body.theme-light .player-play-btn:focus-visible,
body.theme-light .expanded-play-btn:focus-visible {
    background: #0f172a !important;
    color: #ffffff !important;
    box-shadow: 0 14px 34px rgba(17, 24, 39, 0.30);
}

body.theme-light .modal-overlay,
body.theme-light .pwa-install-banner.pwa-install-modal,
body.theme-light .guest-preview-prompt.preview-premium-modal {
    background: rgba(15, 23, 42, 0.24);
}

@media (min-width: 768px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        padding: 16px 10px 18px !important;
        overflow: visible;
    }

    body.sidebar-collapsed .brand {
        display: grid !important;
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 10px;
        min-height: 100px;
        padding: 0;
        margin-bottom: 16px;
    }

    body.sidebar-collapsed .brand-icon {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        position: static !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        z-index: 45;
        border-radius: 14px;
        background: var(--surface-soft);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    }

    body.sidebar-collapsed .sidebar-scroll {
        overflow-x: visible;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --player-height: 104px;
        --sidebar-width: 230px;
        --sidebar-collapsed-width: 76px;
    }

    .app-container {
        grid-template-rows: minmax(0, 1fr) auto !important;
    }

    .player-bar {
        height: auto !important;
        min-height: calc(var(--player-height) + var(--safe-bottom));
        grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.35fr) auto !important;
        gap: 12px;
        padding: 10px 14px calc(10px + var(--safe-bottom)) !important;
        overflow: visible !important;
    }

    .player-song-info,
    .player-track-meta,
    .player-controls,
    .player-utils {
        min-width: 0;
    }

    .control-buttons {
        gap: 8px;
    }

    .player-utils {
        justify-content: flex-end;
        gap: 8px;
    }

    .player-utils .volume-icon,
    .player-utils .volume-slider-wrapper {
        display: none !important;
    }

    .content-body {
        padding-bottom: calc(var(--player-height) + 36px + var(--safe-bottom)) !important;
    }
}

/* 27차 비로그인 미리듣기 종료 premium UI */
:root {
    --z-preview-modal: 1420;
}

.guest-preview-prompt.preview-premium-sheet {
    right: 18px;
    bottom: calc(var(--player-height) + 20px + env(safe-area-inset-bottom)) !important;
    width: min(430px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas:
        "media copy"
        "actions actions";
    gap: 12px 14px;
    align-items: center;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, var(--border-color));
    border-radius: 16px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 12%, transparent), transparent 42%),
        var(--card-bg, var(--bg-secondary));
    color: var(--text-color, var(--text-primary));
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.34);
    z-index: var(--z-preview-modal) !important;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.guest-preview-prompt.preview-premium-sheet.show {
    opacity: 1;
    transform: translateY(0);
}

.guest-preview-media {
    grid-area: media;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-tertiary);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.guest-preview-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.guest-preview-prompt .guest-preview-copy {
    grid-area: copy;
    min-width: 0;
    display: grid;
    gap: 4px;
    padding-right: 28px;
}

.guest-preview-prompt .guest-preview-badge {
    width: fit-content;
    padding: 3px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 16%, transparent);
    color: var(--accent-color);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
}

.guest-preview-prompt .guest-preview-copy strong {
    font-size: 16px;
    line-height: 1.25;
}

.guest-preview-prompt .guest-preview-copy span,
.guest-preview-prompt .guest-preview-track {
    min-width: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.35;
}

.guest-preview-prompt .guest-preview-track {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: normal;
}

.guest-preview-prompt .guest-preview-actions {
    grid-area: actions;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.guest-preview-prompt .guest-preview-login {
    min-width: 126px;
    justify-content: center;
    font-weight: 800;
}

.guest-preview-dismiss {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.guest-preview-dismiss:hover,
.guest-preview-dismiss:focus-visible {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.guest-preview-ended .melon-lite-toast {
    bottom: calc(var(--player-height) + 18px + env(safe-area-inset-bottom));
}

body.expand-player-open .guest-preview-prompt.preview-premium-sheet {
    z-index: calc(var(--z-expanded-player) + 1) !important;
}

@media (max-width: 767px) {
    .guest-preview-prompt.preview-premium-sheet {
        left: 12px;
        right: 12px;
        bottom: calc(var(--player-height) + 14px + env(safe-area-inset-bottom)) !important;
        width: auto;
        max-width: calc(100vw - 24px);
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 10px 12px;
        padding: 14px;
        border-radius: 18px;
    }

    .guest-preview-media {
        width: 48px;
        height: 48px;
        border-radius: 10px;
    }

    .guest-preview-prompt .guest-preview-actions {
        justify-content: stretch;
    }

    .guest-preview-prompt .guest-preview-actions .btn {
        flex: 1 1 0;
        min-height: 42px;
    }
}

/* 28차 미리듣기 종료 중앙 모달 + 플레이어 버튼 시인성 보강 */
:root {
    --z-preview-modal: 1460;
    --preview-backdrop: rgba(0, 0, 0, 0.42);
    --player-control-surface: color-mix(in srgb, var(--player-text) 10%, transparent);
    --player-control-surface-hover: color-mix(in srgb, var(--accent-color) 18%, transparent);
    --player-control-border: color-mix(in srgb, var(--player-text) 18%, transparent);
    --player-control-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

body.theme-light {
    --preview-backdrop: rgba(15, 23, 42, 0.28);
    --player-control-surface: #ffffff;
    --player-control-surface-hover: #eef7f0;
    --player-control-border: #cfd8dc;
    --player-control-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.guest-preview-prompt.preview-premium-modal {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-bottom: calc(var(--player-height) + 28px + env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--accent-color) 14%, transparent), transparent 34%),
        var(--preview-backdrop);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-preview-modal) !important;
    opacity: 0;
    transform: none;
    transition: opacity 180ms ease;
}

.guest-preview-prompt.preview-premium-modal.show {
    opacity: 1;
    transform: none;
}

.guest-preview-card {
    position: relative;
    width: min(540px, calc(100vw - 36px));
    max-height: calc(100dvh - var(--player-height) - 72px - env(safe-area-inset-bottom));
    overflow-y: auto;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-areas:
        "media copy"
        "actions actions";
    gap: 18px 20px;
    align-items: center;
    padding: 28px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--border-color));
    border-radius: 22px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--accent-color) 13%, transparent), transparent 48%),
        var(--card-bg, var(--bg-secondary));
    color: var(--text-color, var(--text-primary));
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.guest-preview-card .guest-preview-media {
    grid-area: media;
    width: 88px;
    height: 88px;
    border-radius: 18px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--border-color);
}

.guest-preview-card .guest-preview-copy {
    grid-area: copy;
    padding-right: 34px;
    gap: 8px;
}

.guest-preview-card .guest-preview-badge {
    padding: 5px 10px;
    font-size: 12px;
}

.guest-preview-card .guest-preview-copy strong {
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: 0;
}

.guest-preview-card .guest-preview-copy span {
    font-size: 15px;
    line-height: 1.55;
}

.guest-preview-card .guest-preview-track {
    max-width: 100%;
    padding-top: 2px;
    font-size: 13px;
}

.guest-preview-card .guest-preview-actions {
    grid-area: actions;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.guest-preview-card .guest-preview-actions .btn {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 14px;
}

.guest-preview-card .guest-preview-login {
    min-width: 168px;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--accent-color) 30%, transparent);
}

.guest-preview-card .guest-preview-dismiss {
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
}

body.guest-preview-ended .pwa-install-banner {
    display: none !important;
}

body.expand-player-open .guest-preview-prompt.preview-premium-modal {
    z-index: calc(var(--z-expanded-player) + 1) !important;
}

.player-bar .control-btn,
.expand-player-container .control-btn {
    border: 1px solid transparent;
    color: var(--player-text) !important;
    background: transparent;
}

.player-bar .control-btn:not(.play-btn),
.expand-player-container .control-btn:not(.play-btn) {
    background: var(--player-control-surface);
    border-color: var(--player-control-border);
}

.player-bar .control-btn:not(.play-btn):hover,
.player-bar .control-btn:not(.play-btn):focus-visible,
.expand-player-container .control-btn:not(.play-btn):hover,
.expand-player-container .control-btn:not(.play-btn):focus-visible {
    background: var(--player-control-surface-hover);
    border-color: color-mix(in srgb, var(--accent-color) 42%, var(--player-control-border));
    color: var(--accent-color) !important;
}

.player-bar .control-btn.play-btn,
.expand-player-container .control-btn.play-btn,
#btn-play-pause,
#expand-btn-play-pause {
    min-width: 46px;
    min-height: 46px;
    background: var(--player-button-bg) !important;
    color: var(--player-button-text) !important;
    border: 1px solid color-mix(in srgb, var(--player-button-bg) 70%, var(--player-control-border)) !important;
    box-shadow: var(--player-control-shadow);
}

.player-bar .control-btn.play-btn:hover,
.player-bar .control-btn.play-btn:focus-visible,
.expand-player-container .control-btn.play-btn:hover,
.expand-player-container .control-btn.play-btn:focus-visible,
#btn-play-pause:hover,
#btn-play-pause:focus-visible,
#expand-btn-play-pause:hover,
#expand-btn-play-pause:focus-visible {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--accent-color) 26%, rgba(0, 0, 0, 0.18));
}

.player-bar .control-btn.active,
.expand-player-container .control-btn.active {
    color: var(--accent-color) !important;
    border-color: color-mix(in srgb, var(--accent-color) 48%, var(--player-control-border));
    background: color-mix(in srgb, var(--accent-color) 16%, transparent);
}

body.theme-light .player-bar .control-btn,
body.theme-light .expand-player-container .control-btn {
    color: #23313d !important;
}

body.theme-light .player-bar .control-btn.play-btn,
body.theme-light .expand-player-container .control-btn.play-btn,
body.theme-light #btn-play-pause,
body.theme-light #expand-btn-play-pause {
    background: #111827 !important;
    color: #ffffff !important;
    border-color: #111827 !important;
}

body.theme-light .player-bar .control-btn.active,
body.theme-light .expand-player-container .control-btn.active {
    color: #087a2f !important;
    background: #dff8e7;
    border-color: #86d39c;
}

@media (max-width: 767px) {
    .guest-preview-prompt.preview-premium-modal {
        padding: 16px;
        padding-bottom: calc(var(--player-height) + 22px + env(safe-area-inset-bottom));
        align-items: center;
    }

    .guest-preview-card {
        width: min(540px, calc(100vw - 32px));
        max-height: calc(100dvh - var(--player-height) - 48px - env(safe-area-inset-bottom));
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 14px;
        padding: 22px 18px 18px;
        border-radius: 20px;
    }

    .guest-preview-card .guest-preview-media {
        width: 64px;
        height: 64px;
        border-radius: 14px;
    }

    .guest-preview-card .guest-preview-copy {
        padding-right: 30px;
    }

    .guest-preview-card .guest-preview-copy strong {
        font-size: 20px;
    }

    .guest-preview-card .guest-preview-actions {
        flex-direction: column;
    }

    .guest-preview-card .guest-preview-actions .btn {
        width: 100%;
        min-height: 46px;
    }

    .player-bar .control-btn.play-btn,
    #btn-play-pause {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .guest-preview-prompt.preview-premium-modal,
    .guest-preview-card,
    .player-bar .control-btn,
    .expand-player-container .control-btn {
        transition: none !important;
    }
}

/* 29차 PWA 설치 중앙 프리미엄 모달 */
:root {
    --z-pwa-install-modal: 1440;
    --pwa-install-backdrop: rgba(0, 0, 0, 0.34);
}

body.theme-light {
    --pwa-install-backdrop: rgba(15, 23, 42, 0.24);
}

.pwa-install-banner.pwa-install-modal[hidden] {
    display: none !important;
}

.pwa-install-banner.pwa-install-modal {
    position: fixed !important;
    inset: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    min-height: 100dvh;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
    padding-bottom: calc(var(--player-height) + 28px + env(safe-area-inset-bottom)) !important;
    border: 0 !important;
    border-radius: 0 !important;
    background:
        radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent-color) 13%, transparent), transparent 36%),
        var(--pwa-install-backdrop) !important;
    color: var(--text-color, var(--text-primary));
    box-shadow: none !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-pwa-install-modal) !important;
}

.pwa-install-card {
    position: relative;
    width: min(540px, calc(100vw - 36px));
    max-height: calc(100dvh - var(--player-height) - 72px - env(safe-area-inset-bottom));
    overflow-y: auto;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-areas:
        "hero copy"
        "steps steps"
        "actions actions";
    gap: 18px 20px;
    align-items: center;
    padding: 28px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--border-color));
    border-radius: 22px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--accent-color) 13%, transparent), transparent 48%),
        var(--card-bg, var(--bg-secondary));
    color: var(--text-color, var(--text-primary));
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.pwa-install-hero {
    grid-area: hero;
    width: 88px;
    height: 88px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 24%, transparent), transparent),
        var(--bg-tertiary);
    color: var(--accent-color);
    font-size: 32px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22), inset 0 0 0 1px var(--border-color);
}

.pwa-install-card .pwa-install-copy {
    grid-area: copy;
    min-width: 0;
    display: grid;
    gap: 8px !important;
    padding-right: 34px;
}

.pwa-install-card .pwa-install-badge {
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 16%, transparent);
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
}

.pwa-install-card .pwa-install-copy strong {
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: 0;
    white-space: normal;
}

.pwa-install-card .pwa-install-copy span:not(.pwa-install-badge) {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.55;
    white-space: normal;
}

.pwa-install-steps {
    grid-area: steps;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 18%, var(--border-color));
    border-radius: 16px;
    background: color-mix(in srgb, var(--accent-color) 8%, transparent);
    color: var(--text-secondary);
    line-height: 1.6;
}

.pwa-install-steps[hidden] {
    display: none !important;
}

.pwa-install-steps strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.pwa-install-steps ol {
    margin: 0;
    padding-left: 20px;
}

.pwa-install-steps li + li {
    margin-top: 4px;
}

.pwa-install-card .pwa-install-actions {
    grid-area: actions;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-end;
    gap: 10px !important;
    flex-wrap: wrap;
    padding-top: 4px;
}

.pwa-install-card .pwa-install-actions .btn {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 14px;
}

.pwa-install-card #pwa-install-btn {
    min-width: 152px;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--accent-color) 30%, transparent);
}

.pwa-install-card .pwa-install-x {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 999px;
}

body.guest-preview-ended .pwa-install-banner.pwa-install-modal,
body.expand-player-open .pwa-install-banner.pwa-install-modal {
    display: none !important;
}

body.pwa-install-open .melon-lite-toast {
    bottom: calc(var(--player-height) + 18px + env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
    .pwa-install-banner.pwa-install-modal {
        padding: 16px !important;
        padding-bottom: calc(var(--player-height) + 22px + env(safe-area-inset-bottom)) !important;
    }

    .pwa-install-card {
        width: min(540px, calc(100vw - 32px));
        max-height: calc(100dvh - var(--player-height) - 48px - env(safe-area-inset-bottom));
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 14px;
        padding: 22px 18px 18px;
        border-radius: 20px;
    }

    .pwa-install-hero {
        width: 64px;
        height: 64px;
        border-radius: 16px;
        font-size: 24px;
    }

    .pwa-install-card .pwa-install-copy {
        padding-right: 30px;
    }

    .pwa-install-card .pwa-install-copy strong {
        font-size: 20px;
    }

    .pwa-install-card .pwa-install-actions {
        flex-direction: column !important;
    }

    .pwa-install-card .pwa-install-actions .btn {
        width: 100%;
        min-height: 46px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-install-banner.pwa-install-modal,
    .pwa-install-card {
        transition: none !important;
        animation: none !important;
    }
}

/* 30차 로그인/반응형/사이드바 접기 최종 보강 */
:root {
    --sidebar-collapsed-width: 76px;
    --z-mobile-hamburger: 1310;
}

.brand {
    min-width: 0;
}

.brand-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-collapse-btn {
    margin-left: auto;
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus-visible {
    border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color));
    background: color-mix(in srgb, var(--accent-color) 12%, var(--card-bg));
    color: var(--accent-color);
}

body.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar {
    padding: 20px 10px;
}

body.sidebar-collapsed .brand {
    justify-content: center;
    padding-left: 0;
    margin-bottom: 24px;
}

body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .sidebar-search-form,
body.sidebar-collapsed .menu-group-toggle span,
body.sidebar-collapsed .menu-group-toggle > i,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-quick-actions span {
    display: none !important;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute;
    top: 18px;
    right: 8px;
    width: 32px;
    height: 32px;
    min-width: 32px;
}

body.sidebar-collapsed .sidebar-scroll {
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 8px;
}

body.sidebar-collapsed .nav-icon {
    width: 24px;
    font-size: 18px;
}

body.sidebar-collapsed .menu-group {
    margin-top: 8px;
}

body.sidebar-collapsed .menu-group-toggle {
    justify-content: center;
    min-height: 16px;
    padding: 4px 0;
    pointer-events: auto;
}

body.sidebar-collapsed .menu-group-toggle::before {
    content: "";
    width: 26px;
    height: 1px;
    border-radius: 999px;
    background: var(--border-color);
}

body.sidebar-collapsed .sidebar-quick-actions {
    grid-template-columns: 1fr;
}

body.sidebar-collapsed .sidebar-quick-actions a {
    min-height: 42px;
    padding: 8px;
}

body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .sidebar-quick-actions a {
    position: relative;
}

body.sidebar-collapsed .nav-item::after,
body.sidebar-collapsed .sidebar-quick-actions a::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    max-width: 220px;
    padding: 6px 9px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
    z-index: calc(var(--z-sidebar, 1000) + 3);
}

body.sidebar-collapsed .nav-item:hover::after,
body.sidebar-collapsed .nav-item:focus-visible::after,
body.sidebar-collapsed .sidebar-quick-actions a:hover::after,
body.sidebar-collapsed .sidebar-quick-actions a:focus-visible::after {
    opacity: 1;
}

body.sidebar-collapsed .content-body {
    max-width: min(1680px, 100%);
}

.mobile-menu-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--text-primary) 16%, var(--border-color));
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
    color: var(--text-primary);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
    z-index: var(--z-mobile-hamburger);
}

body.theme-light .mobile-menu-btn {
    background: #ffffff;
    color: #111827;
    border-color: #d6dee3;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus-visible,
.mobile-menu-btn:active {
    color: var(--accent-color);
    border-color: color-mix(in srgb, var(--accent-color) 48%, var(--border-color));
    background: color-mix(in srgb, var(--accent-color) 12%, var(--bg-secondary));
}

body.theme-light .mobile-menu-btn:hover,
body.theme-light .mobile-menu-btn:focus-visible,
body.theme-light .mobile-menu-btn:active {
    background: #eef7f0;
}

.top-bar {
    z-index: calc(var(--z-sidebar, 1000) + 5);
}

.auth-layout .auth-page {
    min-height: calc(100dvh - var(--player-height) - 120px - env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .app-container {
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
        transition: grid-template-columns 180ms ease;
    }

    .sidebar {
        width: var(--sidebar-width);
        transition: width 180ms ease, padding 180ms ease;
    }

    .main-content {
        min-width: 0;
    }

    .mobile-menu-btn {
        display: none !important;
    }
}

@media (max-width: 767px) {
    body.sidebar-collapsed {
        --sidebar-width: 260px;
    }

    body.sidebar-collapsed .sidebar {
        padding: 24px;
    }

    body.sidebar-collapsed .brand-name,
    body.sidebar-collapsed .sidebar-search-form,
    body.sidebar-collapsed .menu-group-toggle span,
    body.sidebar-collapsed .menu-group-toggle > i,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .sidebar-footer,
    body.sidebar-collapsed .sidebar-quick-actions span {
        display: initial !important;
    }

    body.sidebar-collapsed .sidebar-search-form {
        display: grid !important;
    }

    body.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    body.sidebar-collapsed .menu-group-toggle {
        justify-content: space-between;
        min-height: auto;
        padding: 8px 10px;
    }

    body.sidebar-collapsed .menu-group-toggle::before,
    body.sidebar-collapsed .nav-item::after,
    body.sidebar-collapsed .sidebar-quick-actions a::after {
        display: none !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .mobile-menu-btn {
        display: inline-flex !important;
        margin-right: 4px;
    }

    .top-bar {
        padding-top: calc(10px + env(safe-area-inset-top));
        gap: 10px;
    }

    .auth-layout .auth-page {
        min-height: auto;
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --sidebar-width: 230px;
        --sidebar-collapsed-width: 72px;
    }

    .sidebar {
        padding: 20px 14px;
    }

    .top-bar {
        padding-left: 22px;
        padding-right: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-container,
    .sidebar,
    .sidebar-collapse-btn,
    .mobile-menu-btn {
        transition: none !important;
    }
}

/* 31차 UI/UX 디자인 시스템 polish + PWA standalone safe-area */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --ui-radius-sm: 8px;
    --ui-radius-md: 12px;
    --ui-radius-lg: 18px;
    --ui-radius-xl: 22px;
    --ui-border: var(--border-color);
    --ui-card-bg: var(--card-bg, var(--bg-secondary));
    --ui-soft-bg: color-mix(in srgb, var(--accent-color) 8%, var(--bg-secondary));
    --ui-shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.12);
    --ui-shadow-md: 0 18px 52px rgba(0, 0, 0, 0.28);
    --ui-shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.40);
    --ui-focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent-color) 34%, transparent);
}

body.theme-light {
    --ui-soft-bg: color-mix(in srgb, var(--accent-color) 8%, #ffffff);
    --ui-shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.08);
    --ui-shadow-md: 0 18px 52px rgba(15, 23, 42, 0.16);
    --ui-shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.22);
}

html,
body {
    max-width: 100%;
}

body.is-standalone .app-container {
    padding-top: var(--safe-top);
    height: calc(100dvh - var(--safe-top));
}

body.is-standalone .top-bar {
    top: 0;
    padding-top: 16px !important;
}

body.is-standalone .sidebar {
    padding-top: max(24px, calc(18px + var(--safe-top))) !important;
}

body.is-standalone.sidebar-collapsed .sidebar {
    padding-top: max(20px, calc(16px + var(--safe-top))) !important;
}

body.is-standalone .sidebar-collapse-btn {
    top: max(18px, calc(12px + var(--safe-top)));
}

body.is-standalone .mobile-menu-btn {
    margin-top: 0;
}

body.is-standalone .pwa-install-banner.pwa-install-modal,
body.is-standalone .guest-preview-prompt.preview-premium-modal,
body.is-standalone .modal-overlay,
body.is-standalone .pwa-guide-modal {
    padding-top: calc(18px + var(--safe-top)) !important;
}

body.is-standalone .melon-lite-toast {
    top: auto;
    bottom: calc(var(--player-height) + 18px + var(--safe-bottom));
}

.btn,
button.btn,
a.btn,
.auth-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    max-width: 100%;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0 15px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-primary {
    border-color: color-mix(in srgb, var(--accent-color) 82%, #000);
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--accent-color) 22%, transparent);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: color-mix(in srgb, var(--accent-color) 88%, #ffffff);
    border-color: color-mix(in srgb, var(--accent-color) 72%, #ffffff);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-secondary {
    border-color: var(--ui-border);
    background: color-mix(in srgb, var(--ui-card-bg) 88%, var(--text-primary) 4%);
    color: var(--text-primary);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    border-color: color-mix(in srgb, var(--accent-color) 48%, var(--ui-border));
    background: var(--ui-soft-bg);
    color: var(--accent-color);
}

.btn-danger,
.danger-btn,
.btn-delete {
    border-color: color-mix(in srgb, #ef4444 70%, var(--ui-border));
    background: #ef4444;
    color: #ffffff;
}

.btn:disabled,
.btn.disabled,
button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none !important;
    box-shadow: none !important;
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.control-btn:focus-visible,
.modal-close-btn:focus-visible,
.close-btn:focus-visible {
    outline: 2px solid transparent;
    box-shadow: var(--ui-focus-ring);
}

.stats-card,
.library-stat-card,
.entity-card,
.genre-card,
.explore-card,
.auto-playlist-card,
.playlist-card,
.playlist-create-card,
.settings-card,
.quick-action-card,
.admin-hub-card,
.diagnostic-card,
.alert-card,
.performance-card,
.log-detail-card,
.log-card,
.backup-summary-card,
.backup-file-card,
.check-card,
.media-explore-card,
.auth-card,
.smart-summary-card,
.tag-admin-card,
.merge-candidate-card,
.metadata-quality-card,
.metadata-mobile-card,
.missing-file-card {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius-md) !important;
    background: var(--ui-card-bg) !important;
    box-shadow: var(--ui-shadow-sm);
}

.stats-card:hover,
.library-stat-card:hover,
.entity-card:hover,
.genre-card:hover,
.explore-card:hover,
.auto-playlist-card:hover,
.playlist-card:hover,
.quick-action-card:hover,
.admin-hub-card:hover,
.media-explore-card:hover {
    border-color: color-mix(in srgb, var(--accent-color) 42%, var(--ui-border)) !important;
    box-shadow: var(--ui-shadow-md);
}

.card-title,
.playlist-card-title,
.song-title,
.entity-card strong,
.explore-card strong,
.auto-playlist-card strong,
.compact-song-title,
.track-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.compact-song-title,
.playlist-card-title,
.player-song-title,
.player-song-artist {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-bottom: calc(var(--player-height) + 24px + var(--safe-bottom));
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.modal-box,
.pwa-guide-card,
.guest-preview-card,
.pwa-install-card {
    width: min(560px, calc(100vw - 36px));
    max-height: calc(100dvh - var(--player-height) - 72px - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
    border-radius: var(--ui-radius-xl) !important;
    box-shadow: var(--ui-shadow-lg) !important;
}

.modal-header {
    gap: 12px;
}

.modal-close-btn,
.close-btn,
.guest-preview-dismiss,
.pwa-install-x,
.expand-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-close-btn:hover,
.modal-close-btn:focus-visible,
.close-btn:hover,
.close-btn:focus-visible,
.guest-preview-dismiss:hover,
.guest-preview-dismiss:focus-visible,
.pwa-install-x:hover,
.pwa-install-x:focus-visible,
.expand-close:hover,
.expand-close:focus-visible {
    border-color: color-mix(in srgb, var(--accent-color) 36%, var(--ui-border));
    background: var(--ui-soft-bg);
    color: var(--accent-color);
}

.melon-lite-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
    min-height: 46px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 22%, var(--ui-border));
    border-radius: var(--ui-radius-md);
    background: var(--player-elevated, var(--ui-card-bg));
    color: var(--player-text, var(--text-primary));
    box-shadow: var(--ui-shadow-md);
}

.melon-lite-toast::before {
    content: "i";
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 18%, transparent);
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 900;
    font-family: var(--font-sans);
}

.melon-lite-toast[data-type="success"] {
    border-color: color-mix(in srgb, var(--accent-color) 40%, var(--ui-border));
}

.melon-lite-toast[data-type="warning"] {
    border-color: color-mix(in srgb, #f59e0b 55%, var(--ui-border));
}

.melon-lite-toast[data-type="warning"]::before {
    content: "!";
    background: rgba(245, 158, 11, 0.16);
    color: #f59e0b;
}

.melon-lite-toast[data-type="error"] {
    border-color: color-mix(in srgb, #ef4444 58%, var(--ui-border));
}

.melon-lite-toast[data-type="error"]::before {
    content: "!";
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
}

.loading-text,
.empty-text,
.queue-empty-text,
.tag-empty,
.empty-list-state,
.empty-list-cell {
    color: var(--text-secondary);
    line-height: 1.6;
}

.empty-list-state,
.empty-state,
.queue-empty-text,
.loading-text,
.empty-text {
    border-radius: var(--ui-radius-md);
}

.empty-list-state,
.empty-state {
    padding: 24px;
    border: 1px dashed color-mix(in srgb, var(--accent-color) 24%, var(--ui-border));
    background: color-mix(in srgb, var(--accent-color) 6%, transparent);
}

.loading-text {
    position: relative;
    padding-left: 28px;
}

.loading-text::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.35em;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
    border-top-color: var(--accent-color);
    animation: uiSpin 0.8s linear infinite;
}

@keyframes uiSpin {
    to { transform: rotate(360deg); }
}

.alert-box {
    border-radius: var(--ui-radius-md);
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-sm);
}

.alert-success {
    border-color: color-mix(in srgb, var(--accent-color) 42%, var(--ui-border));
    background: color-mix(in srgb, var(--accent-color) 10%, transparent);
}

.alert-danger,
.alert-error {
    border-color: color-mix(in srgb, #ef4444 50%, var(--ui-border));
    background: rgba(239, 68, 68, 0.10);
}

.alert-warning {
    border-color: color-mix(in srgb, #f59e0b 52%, var(--ui-border));
    background: rgba(245, 158, 11, 0.10);
}

input,
select,
textarea {
    max-width: 100%;
}

@media (min-width: 768px) {
    .content-body {
        max-width: min(1600px, 100%);
    }

    body.sidebar-collapsed .content-body {
        max-width: min(1760px, 100%);
    }
}

@media (max-width: 767px) {
    body.is-standalone .app-container {
        padding-top: var(--safe-top);
        height: calc(100dvh - var(--safe-top));
    }

    body.is-standalone .top-bar {
        padding-top: 12px !important;
    }

    body.is-standalone .sidebar {
        padding-top: calc(18px + var(--safe-top)) !important;
        height: calc(100dvh - var(--safe-top));
    }

    .btn,
    button.btn,
    a.btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 40px;
    }

    .modal-overlay,
    .pwa-install-banner.pwa-install-modal,
    .guest-preview-prompt.preview-premium-modal {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .modal-box,
    .pwa-guide-card,
    .guest-preview-card,
    .pwa-install-card {
        width: calc(100vw - 32px);
        max-height: calc(100dvh - var(--player-height) - 48px - var(--safe-top) - var(--safe-bottom));
    }

    .melon-lite-toast {
        left: 16px;
        right: 16px;
        width: auto;
    }

    .stats-grid,
    .dashboard-quick-actions,
    .admin-card-grid,
    .playlist-card-grid,
    .explore-card-grid,
    .genre-card-grid,
    .smart-card-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .dashboard-quick-actions,
    .admin-card-grid,
    .playlist-card-grid,
    .explore-card-grid,
    .genre-card-grid,
    .smart-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .stats-card,
    .library-stat-card,
    .entity-card,
    .genre-card,
    .explore-card,
    .auto-playlist-card,
    .playlist-card,
    .quick-action-card,
    .modal-box,
    .pwa-guide-card,
    .guest-preview-card,
    .pwa-install-card,
    .melon-lite-toast,
    .loading-text::before {
        transition: none !important;
        animation: none !important;
    }
}

/* 32차 EOF 보정: 마지막 우선순위 */
body.theme-light {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf2f7;
    --surface: #ffffff;
    --surface-soft: #f3f6fa;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --text-color: #111827;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --muted-text: #6b7280;
    --border-color: #d8e1ea;
    --sidebar-bg: #ffffff;
    --player-bg: #ffffff;
    --player-surface: #f6f8fb;
    --player-elevated: #ffffff;
    --player-text: #111827;
    --player-muted: #4b5563;
    --player-border: #d8e1ea;
    --player-progress-bg: #e2e8f0;
    --player-button-bg: #111827;
    --player-button-text: #ffffff;
    --ui-bg: #f6f8fb;
    --ui-surface: #ffffff;
    --ui-card-bg: #ffffff;
    --ui-soft-bg: #f3f7f5;
    --ui-border: #d8e1ea;
}

body.theme-light,
body.theme-light .app-container,
body.theme-light .main-content,
body.theme-light .content-body {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body.theme-light .top-bar,
body.theme-light .sidebar,
body.theme-light .player-bar,
body.theme-light .expanded-player,
body.theme-light .queue-panel,
body.theme-light .modal-box,
body.theme-light .pwa-install-card,
body.theme-light .pwa-guide-card,
body.theme-light .guest-preview-card,
body.theme-light .melon-lite-toast,
body.theme-light .stats-card,
body.theme-light .library-stat-card,
body.theme-light .entity-card,
body.theme-light .genre-card,
body.theme-light .explore-card,
body.theme-light .auto-playlist-card,
body.theme-light .playlist-card,
body.theme-light .quick-action-card,
body.theme-light .admin-card,
body.theme-light .form-card,
body.theme-light .panel,
body.theme-light .section-card {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea,
body.theme-light .search-input,
body.theme-light .filter-input {
    background: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light input::placeholder,
body.theme-light textarea::placeholder,
body.theme-light .search-input::placeholder {
    color: #8a96a8 !important;
}

body.theme-light table,
body.theme-light .data-table,
body.theme-light .song-list-table,
body.theme-light .admin-table {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light th,
body.theme-light thead,
body.theme-light .table-header {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
}

body.theme-light .nav-item,
body.theme-light .menu-group-toggle,
body.theme-light .brand,
body.theme-light .card-title,
body.theme-light .player-track-title,
body.theme-light .expanded-title {
    color: var(--text-primary) !important;
}

body.theme-light .nav-item.active,
body.theme-light .menu-group.has-active > .menu-group-toggle {
    background: color-mix(in srgb, var(--accent-color) 14%, #ffffff) !important;
    color: #14532d !important;
    border-color: color-mix(in srgb, var(--accent-color) 34%, var(--border-color)) !important;
}

body.theme-light .muted,
body.theme-light .subtitle,
body.theme-light .nav-meta,
body.theme-light .card-meta,
body.theme-light .player-track-artist,
body.theme-light .expanded-artist,
body.theme-light .empty-text,
body.theme-light .loading-text {
    color: var(--text-secondary) !important;
}

body.theme-light .btn-secondary,
body.theme-light .btn-ghost,
body.theme-light .icon-btn,
body.theme-light .player-icon-btn,
body.theme-light .player-utility-btn {
    background: var(--surface-soft) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.theme-light .play-btn,
body.theme-light .main-play-btn,
body.theme-light .player-play-btn,
body.theme-light .expanded-play-btn,
body.theme-light #btn-play-pause,
body.theme-light #expand-btn-play-pause {
    background: var(--player-button-bg) !important;
    color: var(--player-button-text) !important;
    border-color: var(--player-button-bg) !important;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.24) !important;
}

@media (min-width: 768px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        padding: 16px 10px 18px !important;
        overflow: visible !important;
    }

    body.sidebar-collapsed .brand {
        display: grid !important;
        grid-template-columns: 1fr !important;
        justify-items: center !important;
        gap: 10px !important;
        min-height: 100px !important;
        padding: 0 !important;
        margin-bottom: 16px !important;
    }

    body.sidebar-collapsed .brand-icon {
        width: 44px !important;
        height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        position: static !important;
        display: inline-flex !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        z-index: 45 !important;
        border-radius: 14px !important;
        background: var(--surface-soft) !important;
        color: var(--text-primary) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12) !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --player-height: 104px;
        --sidebar-width: 230px;
        --sidebar-collapsed-width: 76px;
    }

    .app-container {
        grid-template-rows: minmax(0, 1fr) auto !important;
    }

    .player-bar {
        height: auto !important;
        min-height: calc(var(--player-height) + var(--safe-bottom)) !important;
        grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.35fr) auto !important;
        gap: 12px !important;
        padding: 10px 14px calc(10px + var(--safe-bottom)) !important;
        overflow: visible !important;
    }

    .player-song-info,
    .player-track-meta,
    .player-controls,
    .player-utils {
        min-width: 0 !important;
    }

    .control-buttons,
    .player-utils {
        gap: 8px !important;
    }

    .player-utils {
        justify-content: flex-end !important;
    }

    .player-utils .volume-icon,
    .player-utils .volume-slider-wrapper {
        display: none !important;
    }

    .content-body {
        padding-bottom: calc(var(--player-height) + 36px + var(--safe-bottom)) !important;
    }
}

/* 33차 EOF 운영 안정화: 최종 우선순위 */
html,
body {
    overflow-x: hidden;
}

.content-body {
    padding-bottom: max(140px, calc(var(--player-height) + 42px + var(--safe-bottom))) !important;
}

.no-player-page .content-body {
    padding-bottom: 40px !important;
}

.pwa-install-banner.pwa-install-modal,
.guest-preview-prompt.preview-premium-modal,
.modal-overlay,
.pwa-guide-modal {
    max-width: 100vw;
    max-height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
}

.pwa-install-card,
.guest-preview-card,
.pwa-guide-card,
.modal-box {
    max-width: min(560px, calc(100vw - 32px)) !important;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 48px);
    overflow: auto;
}

body.guest-preview-ended .pwa-install-banner,
body.guest-preview-ended .pwa-guide-modal {
    display: none !important;
}

.melon-lite-toast {
    bottom: calc(var(--player-height) + 18px + var(--safe-bottom)) !important;
    max-width: min(420px, calc(100vw - 32px)) !important;
}

body.pwa-install-open .melon-lite-toast,
body.guest-preview-ended .melon-lite-toast {
    bottom: calc(var(--player-height) + 24px + var(--safe-bottom)) !important;
}

.table-responsive,
.table-wrapper,
.song-table-wrapper,
.admin-table-wrapper,
.backup-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.theme-light .table-responsive,
body.theme-light .table-wrapper,
body.theme-light .song-table-wrapper,
body.theme-light .admin-table-wrapper,
body.theme-light .backup-table-wrapper {
    background: var(--surface);
    border-color: var(--border-color);
}

body.theme-light .alert-box,
body.theme-light .empty-state,
body.theme-light .empty-list-state,
body.theme-light .loading-text {
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.theme-light .alert-danger,
body.theme-light .alert-error {
    background: rgba(239, 68, 68, 0.10) !important;
    color: #7f1d1d !important;
}

body.theme-light .alert-warning {
    background: rgba(245, 158, 11, 0.12) !important;
    color: #78350f !important;
}

body.theme-light .alert-success {
    background: color-mix(in srgb, var(--accent-color) 11%, #ffffff) !important;
    color: #14532d !important;
}

body.theme-dark .stats-card,
body.theme-dark .library-stat-card,
body.theme-dark .entity-card,
body.theme-dark .genre-card,
body.theme-dark .explore-card,
body.theme-dark .auto-playlist-card,
body.theme-dark .playlist-card,
body.theme-dark .quick-action-card,
body.theme-dark .admin-card,
body.theme-dark .form-card,
body.theme-dark .panel,
body.theme-dark .section-card {
    border-color: color-mix(in srgb, var(--border-color, #2f3a35) 78%, #ffffff 8%);
}

@media (min-width: 768px) {
    body.sidebar-collapsed .main-content {
        min-width: 0;
    }

    body.sidebar-collapsed .content-body {
        max-width: min(1760px, 100%) !important;
    }

    body.sidebar-collapsed .sidebar-collapse-btn:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--accent-color) 42%, transparent);
        outline-offset: 3px;
    }
}

@media (max-width: 767px) {
    .content-body {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-bottom: calc(var(--player-height) + 42px + var(--safe-bottom)) !important;
    }

    .player-bar {
        max-width: 100vw !important;
        overflow: visible !important;
    }

    .pwa-install-card,
    .guest-preview-card,
    .pwa-guide-card,
    .modal-box {
        width: calc(100vw - 32px) !important;
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - var(--player-height) - 24px);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .content-body {
        padding-bottom: calc(var(--player-height) + 46px + var(--safe-bottom)) !important;
    }

    .player-bar {
        align-items: center !important;
    }
}
