/* Theme Variables */
:root {
    /* Dark theme (default) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eee;
    --text-secondary: #888;
    --text-tertiary: #666;
    --accent-primary: #e94560;
    --accent-hover: #d63750;
    --border-color: #333;
    --border-hover: #444;
    --error-bg: #3d1f2b;
    --error-text: #ff6b8a;
}

/* Light theme */
.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-tertiary: #999;
    --accent-primary: #e94560;
    --accent-hover: #d63750;
    --border-color: #ddd;
    --border-hover: #ccc;
    --error-bg: #ffe8ec;
    --error-text: #c92a2a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0.5rem;
    overflow-x: hidden;
}

header {
    position: relative;
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 3.5rem;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header-title {
    display: flex;
    flex-direction: column;
}

header h1 {
    font-size: 2.5rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

header h1 .version {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    vertical-align: middle;
}

header p {
    color: var(--text-secondary);
}

/* Header controls container */
.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

/* Format selector */
.format-selector {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.format-selector:hover {
    border-color: var(--accent-primary);
}

.format-selector:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-form input {
    flex: 1;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: center;
    width: 100%;
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: 50%;
    transition: all 0.2s;
    display: none;
    opacity: 0.6;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    color: var(--text-primary);
    opacity: 1;
    background: transparent;
}

.search-clear-btn.visible {
    display: flex;
}

.search-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.search-form button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.search-form button:hover {
    background: var(--accent-hover);
}

.search-disabled input,
.search-disabled button {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.status {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.status.info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.status.error {
    background: var(--error-bg);
    border: 1px solid var(--accent-primary);
    color: var(--error-text);
}

/* Tabs */
.search-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

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

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* Back to Albums button (shown when viewing album tracks) */
.back-to-albums-btn {
    display: none;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.back-to-albums-btn::before {
    content: '\2190';
    margin-right: 0.5rem;
}

.back-to-albums-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.results {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.results.active {
    display: flex;
}

.track {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 0.75rem;
}

.track:hover {
    border-color: var(--border-hover);
}

.track-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.track-cover {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.track-info {
    flex: 1;
    min-width: 0;
}

.track-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    word-break: break-word;
}

.track-artist {
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    word-break: break-word;
}

.track-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.track-duration {
    color: var(--text-tertiary);
}

.track-views {
    color: var(--text-tertiary);
}

/* Track actions container */
.track-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* Play button */
.play-btn {
    padding: 0;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-indent: 2px;
}

.play-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

.play-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.copy-url-btn {
    padding: 0;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.copy-url-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

.copy-url-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.download-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    min-height: 44px;
    min-width: 100px;
    flex-shrink: 0;
}

.download-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}

.download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Save to Computer button variant */
.download-btn.save-btn {
    background: var(--accent-primary);
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.download-btn.save-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Albums Grid */
.albums-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.albums-grid.active {
    display: grid;
}

.album-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.album-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.album-cover {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.album-info {
    padding: 1rem;
    flex: 1;
}

.album-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.album-artist {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.album-actions {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.view-album-btn,
.download-album-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-album-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.view-album-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}

.download-album-btn {
    background: var(--accent-primary);
    color: white;
}

.download-album-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.view-album-btn:disabled,
.download-album-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design - Mobile First */

/* Very small screens (< 480px) */
@media (max-width: 480px) {
    header {
        padding-top: 2.5rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .github-star {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        min-height: 36px;
    }

    .format-selector {
        flex: 1;
    }

    .search-form {
        flex-direction: column;
    }

    .search-input-wrapper {
        width: 100%;
    }

    .search-form > button[type="submit"] {
        width: 100%;
    }

    /* Fix tab overflow on mobile */
    .search-tabs {
        gap: 0;
    }

    .tab-btn {
        flex: 1;
        padding: 0.75rem 0.25rem;
        font-size: 0.8rem;
        min-width: 0;
    }
}

/* Small screens (< 640px) */
@media (max-width: 640px) {
    /* Fix tab overflow on mobile */
    .search-tabs {
        gap: 0;
    }

    .tab-btn {
        flex: 1;
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
        min-width: 0;
    }

    .albums-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .track {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .track-main {
        margin-bottom: 0.75rem;
    }

    .track-cover {
        width: 60px;
        height: 60px;
    }

    .track-actions {
        width: 100%;
        flex-direction: row;
        justify-content: stretch;
    }

    .play-btn, .copy-url-btn {
        flex: 0 0 auto;
    }

    .download-btn {
        flex: 1;
        min-width: unset;
    }

    /* Chart tracks: override column layout to keep rank on same row as track-main */
    .chart-track.track {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .chart-track .track-main {
        flex: 1 1 0;
        min-width: 0;
        margin-bottom: 0;
    }
    .chart-track .track-actions {
        flex-basis: 100%;
    }
}

/* Small to medium screens (480px - 640px) */
@media (min-width: 480px) and (max-width: 640px) {
    header {
        padding-top: 3rem;
    }
}

/* Tablet (640px - 1024px) */
@media (min-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .track {
        padding: 1.25rem;
    }

    header h1 {
        font-size: 2.5rem;
    }
}

/* Desktop (> 1024px) */
@media (min-width: 1024px) {
    body {
        padding: 2rem;
    }
}

/* Desktop - single line for cleaner look */
@media (min-width: 1024px) {
    .track-title,
    .track-artist {
        white-space: nowrap;
        text-overflow: ellipsis;
        -webkit-line-clamp: 1;
    }
}

/* GitHub Star Button - positioned at top right */
.github-star {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 2px solid var(--border-color);
    min-height: 44px;
    z-index: 10;
}

.github-star:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

/* Queue Section */
.queue-section {
    margin: 2rem 0;
    display: none;
}

.queue-section.show {
    display: block;
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.queue-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.clear-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 36px;
}

.clear-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.queue-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Job Cards */
.job-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: border-color 0.3s;
}

.job-card.queued {
    border-color: #3498db;
}

.job-card.downloading {
    border-color: #f39c12;
}

.job-card.completed {
    border-color: #2ecc71;
}

.job-card.failed {
    border-color: #e74c3c;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-artist {
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-queued {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

.status-downloading {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.status-completed {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.status-failed {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

/* Progress Bar */
.progress-bar {
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin: 0.75rem 0;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-hover));
    transition: width 0.3s ease;
    border-radius: 6px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    z-index: 1;
}

/* Job Error */
.job-error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    word-break: break-word;
}

/* Job Actions */
.download-file-btn,
.clear-job-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
    margin-right: 0.5rem;
    border: none;
    min-height: 36px;
}

.download-file-btn {
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
    display: inline-block;
}

.download-file-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.clear-job-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.clear-job-btn:hover {
    background: var(--accent-primary);
    color: white;
}

/* Mobile Queue Adjustments */
@media (max-width: 640px) {
    .queue-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .queue-header h2 {
        font-size: 1.25rem;
    }

    .clear-btn {
        width: 100%;
    }

    .job-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .job-status {
        align-self: flex-start;
    }

    .progress-text {
        font-size: 0.75rem;
    }

    .queue-list .download-file-btn,
    .queue-list .clear-job-btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.25rem;
    }
}

/* Settings button - matches theme toggle style */
.icon-btn {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
}

/* Settings */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

.settings-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.settings-description a {
    color: var(--accent-primary);
    text-decoration: none;
}

.settings-description a:hover {
    text-decoration: underline;
}

.cookie-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.status-success {
    background: #22c55e;
}

.status-indicator.status-warning {
    background: #f59e0b;
}

.status-indicator.status-error {
    background: #ef4444;
}

.status-indicator.status-none {
    background: var(--text-tertiary);
}

.status-text {
    font-size: 0.95rem;
}

.cookie-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

/* --- Explore Tab --- */

.explore-section {
    display: none;
    overflow-x: hidden;
    max-width: 100%;
}
.explore-section.active {
    display: block;
}

.explore-loading, .explore-error {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}
.explore-error {
    color: var(--error-text);
}

/* Section headers */
.explore-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.explore-section-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.explore-section-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Country selector */
.country-selector {
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

/* Download All button */
.download-all-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    min-height: 44px;
    min-width: 100px;
}
.download-all-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}
.download-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Charts section */
.explore-charts-section {
    margin-bottom: 2rem;
}
.explore-charts-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}
.chart-tracks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.5rem 0;
}

.pagination-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--hover);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Chart track: extends .track with rank number and trend indicator */
.chart-track .chart-rank {
    font-size: 1rem;
    font-weight: 700;
    min-width: 2rem;
    text-align: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.chart-trend {
    font-size: 0.85rem;
    min-width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}
.chart-trend.trend-up { color: #22c55e; }
.chart-trend.trend-down { color: #ef4444; }
.chart-trend.trend-neutral { color: var(--text-secondary); }

/* Cron config button */
.cron-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 44px;
}
.cron-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}
.cron-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.cron-btn.cron-copied {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}
/* Inline variant for breadcrumb rows */
.cron-btn-inline {
    margin-left: auto;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    min-height: 32px;
}

/* UGC badge for non-official content */
.ugc-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* Moods & Genres section */
/* New Releases section */
.explore-new-releases-section {
    margin-bottom: 2rem;
}
.new-releases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.new-release-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.new-release-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}
.new-release-cover {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg-tertiary);
}
.new-release-info {
    padding: 0.75rem;
    flex: 1;
}
.new-release-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.new-release-artist {
    color: var(--text-secondary);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.new-release-meta {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    gap: 0.5rem;
}
.new-release-actions {
    padding: 0 0.75rem 0.75rem;
    display: flex;
    gap: 0.5rem;
}
.new-release-actions button {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.new-release-actions button:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}
.explicit-badge {
    display: inline-block;
    background: var(--text-tertiary);
    color: var(--bg-primary);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.explore-moods-section {
    margin-top: 1.5rem;
}
.mood-section {
    margin-bottom: 1.5rem;
}
.mood-section h2 {
    font-size: 1.15rem;
    margin: 0 0 0.75rem 0;
}
.mood-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}
.mood-category-card {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s;
    overflow-wrap: anywhere;
    min-width: 0;
}
.mood-category-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

/* Mood playlists grid */
.mood-playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.mood-playlist-card {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow: hidden;
}
.mood-playlist-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}
.mood-playlist-info {
    padding: 0.75rem;
}
.mood-playlist-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.mood-playlist-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.mood-playlist-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.75rem 0.75rem;
}
.mood-playlist-actions button {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
}
.mood-playlist-actions button:hover {
    border-color: var(--accent-primary);
}
.mood-playlist-actions .download-playlist-btn {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* Breadcrumb navigation */
.explore-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.breadcrumb-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    padding: 0;
    font-size: inherit;
}
.breadcrumb-link:hover {
    text-decoration: underline;
}
.breadcrumb-sep {
    color: var(--text-secondary);
}
.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* Playlist tracks header */
.explore-playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.explore-playlist-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.explore-track-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.explore-tracks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Responsive - Explore tab mobile fixes */
@media (max-width: 600px) {
    .mood-categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    .mood-playlists-grid {
        grid-template-columns: 1fr;
    }

    /* Stack the section header vertically */
    .explore-section-header {
        flex-direction: column;
        align-items: stretch;
    }

    /* Allow section actions to wrap and fill width */
    .explore-section-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    .explore-section-actions .country-selector {
        flex: 1 1 auto;
        min-width: 0;
    }
    .explore-section-actions .download-all-btn {
        flex: 1 1 auto;
        min-width: 0;
    }
    .explore-section-actions .cron-btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Chart track rank/trend adjustments for very small screens */
    .chart-track .chart-rank {
        min-width: 1.5rem;
        font-size: 0.9rem;
    }
    .chart-track .chart-trend {
        min-width: 1rem;
        font-size: 0.75rem;
    }

    /* Breadcrumb: allow wrapping so cron button stays visible */
    .explore-breadcrumb {
        flex-wrap: wrap;
    }
    .cron-btn-inline {
        margin-left: 0;
        flex: 0 0 auto;
    }

    /* Playlist header: wrap on mobile */
    .explore-playlist-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .explore-playlist-header .explore-section-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    .explore-playlist-header .explore-section-actions .download-all-btn,
    .explore-playlist-header .explore-section-actions .cron-btn {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* --- Downloads Tab --- */

.downloads-section {
    display: none;
}
.downloads-section.active {
    display: block;
}

.downloads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.downloads-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.downloads-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.downloads-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.downloads-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Missing file indicator */
.track.track-missing {
    border-style: dashed;
    opacity: 0.6;
}
.track-missing-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #ef4444;
    white-space: nowrap;
}

/* Remove button */
.remove-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 36px;
    flex-shrink: 0;
}
.remove-btn:hover:not(:disabled) {
    background: #ef4444;
    color: white;
}
.remove-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile adjustments for downloads */
@media (max-width: 640px) {
    .downloads-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .downloads-list .track-actions .download-file-btn {
        flex: 0 0 auto;
        width: auto;
        text-align: center;
        margin: 0;
    }
    .downloads-list .track-actions .remove-btn {
        flex: 1 1 0;
        min-width: 0;
    }
}
