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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #121212;
    color: #e0e0e0;
    min-height: 100vh;
    width: 100%;
}

body, .container, .main-content, .allsongs-table-wrap, .allsongs-table {
    box-sizing: border-box;
}

header {
    background: #1e1e1e;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

header h1 span {
    color: #ffd700;
}

.search-box {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 76px 10px 40px;
    border: 1px solid #444;
    border-radius: 20px;
    background: #2a2a2a;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: #ffd700;
}

.search-box .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 16px;
}

.search-box .clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    display: none;
    transition: color 0.15s;
}

.search-box .clear-btn:hover {
    color: #ffd700;
}

.search-box .search-go-btn {
    position: absolute;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    display: none;
    transition: color 0.15s;
}

.search-box .search-go-btn:hover {
    color: #ffd700;
}

.header-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.header-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.15s;
}

.header-btn:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #ffd700;
}

.header-btn-accent {
    background: #2a2a2a;
    border-color: #ffd700;
    color: #ffd700;
}

.header-btn-accent:hover {
    background: #ffd700;
    color: #000;
}

.header-btn.active {
    background: #2a2a2a;
    border-color: #ffd700;
    color: #ffd700;
}

.header-btn.active:hover {
    background: #ffd700;
    color: #000;
}

.header-scan-date {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    color-scheme: dark;
}

.header-scan-date:focus {
    border-color: #ffd700;
}

.header-buttons .scan-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.15s;
}

.header-buttons .scan-btn:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #ffd700;
}

.header-buttons .scan-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.header-buttons .scan-progress {
    display: none;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-buttons .scan-progress-bar {
    width: 60px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    overflow: hidden;
}

.header-buttons .scan-progress-fill {
    height: 100%;
    background: #ffd700;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

.header-buttons .scan-progress-text {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 16px auto;
    border: 3px solid #333;
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.error {
    text-align: center;
    padding: 40px 20px;
    color: #f44336;
}

.container {
    display: flex;
    height: calc(100vh - 61px);
    width: 100%;
}

.sidebar {
    width: 360px;
    min-width: 360px;
    background: #181818;
    border-right: 1px solid #333;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    padding: 8px 20px 4px;
}

.album-list {
    list-style: none;
}

.album-item {
    padding: 8px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.15s;
    user-select: none;
}

.album-item:hover {
    background: #282828;
}

.album-item.active {
    background: #333;
    color: #ffd700;
}

.album-item .folder-icon {
    font-size: 18px;
    color: #ffd700;
}

.album-item .count {
    margin-left: auto;
    font-size: 12px;
    color: #666;
}

.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px;
}

.track-name {
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.allsongs-table td.as-title .track-name {
    font-size: 14px;
    color: #fff;
}

.allsongs-table td.as-title {
    min-width: 120px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

.empty-state .big-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* --- Player Wrapper --- */

#playerWrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
}

/* --- Visualization Container --- */

.vis-container {
    background: #111;
    border-top: 1px solid #333;
    padding: 8px 24px 0;
    user-select: none;
}

.vis-row {
    display: flex;
    gap: 12px;
    height: 250px;
    min-height: 60px;
}

.vis-panel {
    flex: 1;
    position: relative;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 4px;
    overflow: hidden;
}

.vis-label {
    position: absolute;
    top: 4px;
    left: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #555;
    z-index: 2;
    pointer-events: none;
}

.vis-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.vis-spectrum-inner {
    display: flex;
    width: 100%;
    height: 100%;
}

.vis-waveform-strip {
    display: block;
    width: 50%;
    height: 100%;
    border-right: 1px solid #222;
    flex-shrink: 0;
}

.vis-waveform-strip + .vis-canvas {
    width: 50%;
    height: 100%;
    flex-shrink: 0;
}

.vis-resize-handle {
    height: 6px;
    cursor: ns-resize;
    background: #222;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    margin: 4px 0;
    position: relative;
    transition: background 0.15s;
}

.vis-resize-handle:hover {
    background: #ffd700;
}

.vis-resize-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 2px;
    background: #555;
    border-radius: 1px;
    box-shadow: 0 -4px 0 #555, 0 4px 0 #555;
}

.vis-info {
    display: flex;
    justify-content: space-between;
    padding: 4px 4px 0;
    font-size: 11px;
    color: #666;
    font-family: 'Consolas', monospace;
}

.vis-info span {
    min-width: 100px;
}

#visDb {
    text-align: right;
}

/* --- Now Playing Bar --- */

.now-playing-bar {
    background: #1e1e1e;
    border-top: 1px solid #333;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.now-playing-bar .np-info {
    min-width: 180px;
    max-width: 300px;
}

.now-playing-bar .np-name {
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-bar .np-album {
    font-size: 12px;
    color: #888;
}

.now-playing-bar .np-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.now-playing-bar .np-controls button {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
    line-height: 1;
}

.now-playing-bar .np-controls button:hover {
    color: #fff;
}

.now-playing-bar .np-controls button.play-pause {
    font-size: 28px;
    color: #fff;
    width: 32px;
    text-align: center;
}

.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-container .time {
    font-size: 12px;
    color: #888;
    min-width: 40px;
    font-family: 'Consolas', monospace;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: height 0.1s;
}

.progress-bar:hover {
    height: 8px;
}

.progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffaa00);
    border-radius: 3px;
    width: 0%;
    position: relative;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: #ffd700;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
    z-index: 3;
}

.progress-bar:hover .progress-thumb {
    opacity: 1;
}

.progress-hover {
    position: absolute;
    bottom: 16px;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
    z-index: 4;
}

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

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.volume-control .volume-icon {
    color: #888;
    font-size: 18px;
    cursor: pointer;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: #444;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.volume-slider .volume-fill {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 70%;
}

.volume-slider:hover .volume-fill {
    background: #ffd700;
}

body.has-player .container {
    padding-bottom: 260px;
}

/* --- Library Table --- */
.library-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.library-wrap h2 {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.library-table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid #222;
    border-radius: 4px;
}

.library-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.library-table th {
    position: sticky;
    top: 0;
    background: #1a1a1a;
    color: #888;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #333;
    z-index: 2;
    cursor: pointer;
    user-select: none;
}

.library-table th:hover {
    color: #ffd700;
}

/* --- All Songs Table --- */
.allsongs-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.allsongs-title {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.sync-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    vertical-align: middle;
    transition: all 0.15s;
}
.sync-btn:hover { background: #3a3a3a; color: #ffd700; border-color: #ffd700; }
.sync-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.allsongs-table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid #222;
    border-radius: 4px;
}

.allsongs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.allsongs-table th {
    position: sticky;
    top: 0;
    background: #1a1a1a;
    color: #888;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #333;
    z-index: 2;
    cursor: pointer;
    user-select: none;
}

.allsongs-table th:hover {
    color: #ffd700;
}

.allsongs-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #1a1a1a;
    vertical-align: middle;
}

.allsongs-table tr {
    cursor: pointer;
    transition: background 0.1s;
}

.allsongs-table tr:hover {
    background: #282828;
}

.allsongs-table tr.playing {
    background: #2a2a2a;
}

.allsongs-table tr.playing td {
    color: #ffd700;
}

.allsongs-table tr.playing .track-name {
    color: #ffd700;
}

.allsongs-table .as-play {
    width: 36px;
    text-align: center;
}

.allsongs-table .as-num {
    width: 36px;
    text-align: right;
    color: #666;
}

.allsongs-table .as-title {
    min-width: 120px;
}

.allsongs-table .as-album {
    min-width: 100px;
}

.allsongs-table .as-dur,
.allsongs-table .as-br,
.allsongs-table .as-sr,
.allsongs-table .as-size,
.allsongs-table .as-date {
    width: 70px;
    text-align: right;
    color: #888;
    font-size: 12px;
}

.allsongs-table .as-yt,
.allsongs-table .as-yt-set {
    width: 36px;
    text-align: center;
}

.allsongs-table th.as-yt {
    font-size: 11px;
    font-weight: normal;
    color: #888;
    letter-spacing: 0.5px;
}

.yt-link-btn {
    display: inline-block;
    color: #ff0000;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.15s;
    line-height: 1;
}

.yt-link-btn:hover {
    color: #fff;
}

.yt-set-btn {
    display: inline-block;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.15s;
    user-select: none;
    line-height: 1;
    color: #555;
    font-weight: bold;
}

.yt-set-btn:hover {
    color: #ffd700;
    background: #333;
}

/* --- Album Cover --- */
.album-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.album-cover-wrap {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #333;
    cursor: pointer;
}

.album-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.album-title {
    flex: 1;
    min-width: 0;
}

.album-title h2 {
    color: #ffd700;
    font-size: 18px;
    margin: 4px 0 0;
}

/* --- Scan Bar --- */
.scan-date {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
.scan-date:focus { border-color: #ffd700; }
.scan-date::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}
.scan-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    white-space: nowrap;
}
.scan-btn:hover { background: #3a3a3a; color: #fff; border-color: #ffd700; }
.scan-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.scan-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 120px;
}
.scan-progress-bar {
    flex: 1;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}
.scan-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffd700;
    border-radius: 3px;
    transition: width 0.3s;
}
.scan-progress-text {
    font-size: 12px;
    color: #888;
    min-width: 50px;
    text-align: right;
    font-family: 'Consolas', monospace;
}
/* --- Track extra info --- */
.track-extra-text {
    font-size: 11px;
    color: #666;
    margin-top: 1px;
    display: none;
}
body.show-extra-tags .track-extra-text {
    display: block;
}

/* --- Settings modal --- */
.settings-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9998;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-modal {
    background: #1e1e1e;
    border-radius: 8px;
    width: 420px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #333;
}
.settings-header h3 {
    font-size: 16px;
    color: #ffd700;
}
.settings-close {
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.settings-close:hover { color: #fff; }
.settings-body {
    padding: 16px 20px;
}
.settings-section {
    margin-bottom: 20px;
}
.settings-section h4 {
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.settings-row {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.settings-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #ccc;
}
.settings-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ffd700;
}

/* --- Cover lightbox --- */
.cover-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.cover-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}
.cover-lightbox-close {
    position: fixed;
    top: 16px;
    right: 24px;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    line-height: 1;
}
.cover-lightbox-close:hover { opacity: 1; }

@media (max-width: 768px) {
    .container {
        display: block;
        height: auto;
        width: 100%;
    }
    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #333;
    }
    .main-content {
        width: 100%;
        padding: 12px;
    }
    .allsongs-table-wrap,
    .allsongs-table,
    .allsongs-wrap {
        width: 100%;
    }
    .allsongs-table td.as-title {
        min-width: 0;
    }
    .header-btn {
        font-size: 11px;
        padding: 6px 8px;
    }
    .now-playing-bar {
        flex-wrap: wrap;
    }
    .now-playing-bar .np-info {
        min-width: 120px;
    }
    .volume-control {
        display: none;
    }
    .vis-row {
        flex-direction: column;
    }
    .vis-canvas {
        height: 80px;
    }
    body.has-player .container {
        padding-bottom: 340px;
    }
    .allsongs-table .as-dur,
    .allsongs-table .as-br,
    .allsongs-table .as-sr {
        display: none;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .vis-row {
        height: 120px;
    }
    .vis-canvas {
        height: 120px;
    }
    body.has-player .container {
        padding-bottom: 120px;
    }
    header {
        padding: 8px 12px;
        gap: 8px;
    }
    header h1 {
        font-size: 14px;
    }
    .header-btn {
        font-size: 10px;
        padding: 4px 6px;
    }
    .search-box input {
        padding: 6px 60px 6px 32px;
        font-size: 12px;
    }
    .sidebar {
        max-height: 100px;
    }
}
