@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

/* ============================================
   UNIFIED THEME SYSTEM
   Single source of truth for all pages
   ============================================ */

:root {
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-elevated: #ffffff;
    --bg-hover: #f1f3f5;

    /* Surfaces */
    --surface: #ffffff;
    --surface-secondary: #f8f9fa;
    --surface-glass: rgba(255, 255, 255, 0.8);

    /* Text */
    --text-primary: #18181b;
    --text-secondary: #71717a;
    --text-tertiary: #a1a1aa;

    /* Accent (primary action color) */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.1);
    --accent-warn: #f59e0b;
    --accent-warn-hover: #d97706;

    /* Borders */
    --border: rgba(0, 0, 0, 0.06);
    --border-hover: rgba(0, 0, 0, 0.12);

    /* Semantic */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);

    /* Player */
    --player-bg: rgba(255, 255, 255, 0.95);
    --player-border: rgba(0, 0, 0, 0.08);

    /* Layout */
    --layout-max-width: 1400px;
    --layout-gutter: clamp(16px, 2.5vw, 24px);
    --page-bottom-space: 48px;
    --nav-control-height: 44px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #09090b;
        --bg-secondary: #18181b;
        --bg-elevated: #27272a;
        --bg-hover: #3f3f46;

        --surface: #18181b;
        --surface-secondary: #27272a;
        --surface-glass: rgba(24, 24, 27, 0.8);

        --text-primary: #fafafa;
        --text-secondary: #a1a1aa;
        --text-tertiary: #71717a;

        --accent: #60a5fa;
        --accent-hover: #93c5fd;
        --accent-soft: rgba(96, 165, 250, 0.1);

        --border: rgba(255, 255, 255, 0.08);
        --border-hover: rgba(255, 255, 255, 0.12);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.5);

        --player-bg: rgba(24, 24, 27, 0.95);
        --player-border: rgba(255, 255, 255, 0.1);
    }
}

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

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Base */
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.container {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 0 var(--layout-gutter);
}

/* Modern Header */
header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    margin-bottom: 16px;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Brand with Icon */
header h1 {
    margin: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--nav-control-height);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand:hover {
    transform: translateY(-1px);
}

.brand-icon {
    color: var(--accent);
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.brand-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* Navigation */
header nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    height: var(--nav-control-height);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

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

.nav-link.is-active {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-menu-button {
    width: var(--nav-control-height);
    height: var(--nav-control-height);
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.user-menu-button svg {
    width: 18px;
    height: 18px;
}

.user-menu-button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.user-menu-button[aria-expanded="true"] {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

@media (prefers-color-scheme: dark) {
    .user-menu-dropdown {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
}

.user-menu-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 12px 16px;
}

.user-menu-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.user-menu-item:first-of-type {
    border-radius: 0 0 12px 12px;
}

.user-menu-item:hover {
    background: var(--bg-secondary);
}

.user-menu-item svg {
    color: var(--text-secondary);
}

/* Main content */
main {
    padding-bottom: var(--page-bottom-space);
}

h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    color: var(--text-primary);
}

h3 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 40px 0 20px;
    color: var(--text-primary);
}

/* Downloads Page */
.downloads-page {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.download-form-section {
    margin-bottom: 16px;
}

.download-form {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
}

.download-form .form-group input,
.download-form .form-group select {
    background: var(--bg-primary);
}

.download-form .form-group input:focus,
.download-form .form-group select:focus {
    background: var(--bg-primary);
}

.download-form .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.download-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.playlist-prompt-inline {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    flex: 1;
    min-width: 0;
}

.playlist-prompt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

.playlist-prompt-header {
    font-weight: 700;
    color: var(--text-primary);
}

.playlist-prompt-actions {
    display: flex;
    gap: 8px;
}

.playlist-btn.btn-primary {
    background: var(--accent-warn);
    border-color: var(--accent-warn);
}

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

.playlist-btn.active {
    outline: 2px solid var(--accent-warn);
}

.downloads-list-section {
    margin-top: 8px;
}

.history-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 0 64px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.history-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
}

.history-actions {
    display: flex;
    gap: 12px;
}

.history-menu {
    position: relative;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.history-menu-dropdown {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 160px;
    padding: 8px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    display: none;
    z-index: 10;
}

.history-menu-dropdown.open {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-menu-item {
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
}

.history-menu-item:hover {
    background: var(--bg-secondary);
}

.history-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.history-search input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    font-size: 14px;
}

.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    font-size: 13px;
}

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

.chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
}

.chip.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.history-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.history-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-row {
    display: grid;
    grid-template-columns: 72px minmax(220px, 2fr) 110px 120px 90px 160px minmax(200px, 1.5fr) 44px;
    gap: 12px;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    font-size: 13px;
}

.history-header-row {
    background: transparent;
    border: none;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 4px 12px;
}

.history-artwork {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-primary);
}

.history-artwork-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.history-title-text {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.history-subtext {
    color: var(--text-secondary);
    font-size: 12px;
}

.history-mono {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.history-source {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-source a {
    color: var(--accent);
    word-break: break-all;
    line-height: 1.3;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-row-actions {
    display: flex;
    justify-content: flex-end;
}

.status-chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
}

.status-chip.completed {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.status-chip.failed {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.history-row-menu {
    position: relative;
}

.history-row-menu-button {
    width: 36px;
    height: 36px;
}

.history-row-menu-dropdown {
    position: absolute;
    right: 0;
    top: 44px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 180px;
    padding: 8px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    display: none;
    z-index: 10;
}

.history-row-menu-dropdown.open {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-menu-item {
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
}

.history-menu-item:hover {
    background: var(--bg-secondary);
}

.history-menu-item.disabled {
    color: var(--text-secondary);
    cursor: default;
}

.history-menu-item.danger {
    color: #dc2626;
}

@media (max-width: 1100px) {
    .history-row {
        grid-template-columns: 64px minmax(180px, 2fr) 100px 100px 80px 140px minmax(180px, 1.3fr) 40px;
    }
}

@media (max-width: 900px) {
    .history-row {
        grid-template-columns: 64px 1fr 40px;
        grid-auto-rows: auto;
    }
    .history-row > div:nth-child(5),
    .history-row > div:nth-child(6),
    .history-row > div:nth-child(7),
    .history-row > div:nth-child(8) {
        grid-column: 2 / -1;
    }
    .history-header-row {
        display: none;
    }
}

.playlist-prompt {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
}

.playlist-prompt-header {
    font-weight: 700;
    margin-bottom: 8px;
}

.playlist-prompt-body {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.playlist-prompt-actions {
    display: flex;
    gap: 12px;
}

.playlist-prompt-actions .active {
    outline: 2px solid var(--accent);
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-message {
    margin-top: 12px;
    color: var(--text-secondary);
}

.text-muted {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 48px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group select {
    appearance: none;
    cursor: pointer;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2371717a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
    border-radius: 8px;
}

.btn-cancel,
.btn-delete {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-cancel:hover,
.btn-delete:hover {
    background: var(--error);
    color: white;
    transform: translateY(-1px);
}

/* Login */
.login-container {
    max-width: 400px;
    margin: 64px auto;
    padding: 32px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 32px;
}

.error-message {
    padding: 12px;
    margin-bottom: 20px;
    background: var(--error);
    color: white;
    border-radius: 8px;
    text-align: center;
}

/* Download cards */
.download-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 8px;
    background: transparent;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-card:hover {
    background: var(--bg-secondary);
}

.download-artwork {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.download-artwork-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.download-artwork-placeholder svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    opacity: 0.5;
}

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

.download-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.download-artist,
.download-album {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.download-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin-top: 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-queued {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.status-downloading {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

.status-downloading::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.status-processing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.download-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Library grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.track-card {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.track-artist,
.track-album {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px dashed var(--border);
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.empty-state .btn {
    margin-top: 20px;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

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

.toast.success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.toast.error {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Library Page */
.library-container {
    padding-bottom: 120px; /* Space for player */
}

.library-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.library-search {
    flex: 1;
    min-width: 200px;
}

.library-search input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.library-controls {
    display: flex;
    gap: 8px;
}

.view-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.view-toggle button {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    min-height: 36px;
}

.view-toggle button.active {
    background: var(--accent);
    color: white;
    border-radius: 6px;
}

.sort-control select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

/* Album Grid View */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.album-card {
    cursor: pointer;
    transition: transform 0.2s;
}

.album-card:hover {
    transform: scale(1.05);
}

.album-artwork {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.album-info {
    margin-top: 8px;
}

.album-title {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Songs List View */
.songs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.song-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.song-item:hover {
    background: var(--border);
}

.song-item.playing {
    background: var(--accent);
    color: white;
}

.song-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 12px;
    background: var(--bg-primary);
}

.song-details {
    flex: 1;
    min-width: 0;
}

.song-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.song-item.playing .song-meta {
    color: rgba(255, 255, 255, 0.8);
}

.song-duration {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 12px;
}

.song-item.playing .song-duration {
    color: rgba(255, 255, 255, 0.8);
}

/* Artists Grid View */
.artists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.artist-card {
    text-align: center;
    cursor: pointer;
}

.artist-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto;
    background: var(--bg-secondary);
}

.artist-name {
    margin-top: 12px;
    font-weight: 500;
    font-size: 14px;
}

.artist-track-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Audio Player */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    z-index: 100;
}

.player-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 16px;
    align-items: center;
}

.player-track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.player-artwork {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-primary);
}

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

.player-title {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.player-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.player-button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.player-button:hover {
    background: var(--border);
}

.player-button.play-pause {
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: white;
    font-size: 20px;
}

.player-button.play-pause:hover {
    background: var(--accent-hover);
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-time {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 40px;
}

.progress-slider {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 999px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    position: relative;
    background-image: linear-gradient(var(--accent), var(--accent));
    background-size: var(--progress, 0%) 100%;
    background-repeat: no-repeat;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.progress-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.progress-slider::-moz-range-track {
    height: 4px;
    background: transparent;
}

.player-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

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

.volume-slider {
    width: 80px;
}

.queue-button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.queue-button:hover {
    background: var(--border);
}

/* Queue Panel */
.queue-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    z-index: 200;
    transition: right 0.3s;
    overflow-y: auto;
}

.queue-panel.open {
    right: 0;
}

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

.queue-header h3 {
    margin: 0;
    font-size: 18px;
}

.queue-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
}

.queue-close:hover {
    background: var(--border);
}

.queue-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.queue-actions button {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.queue-actions button:hover {
    background: var(--border);
}

.queue-list {
    padding: 8px;
}

.queue-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
}

.queue-item:hover {
    background: var(--bg-secondary);
}

.queue-item.current {
    background: var(--accent);
    color: white;
}

.queue-item-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 12px;
    background: var(--bg-secondary);
}

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

.queue-item-title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.queue-item.current .queue-item-artist {
    color: rgba(255, 255, 255, 0.8);
}

/* Mobile responsive */
@media (max-width: 600px) {
    header .container {
        flex-wrap: wrap;
        gap: 8px;
    }

    header nav {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-link {
        height: 40px;
        padding: 8px 10px;
        font-size: 14px;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .download-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .download-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .library-header {
        flex-direction: column;
        align-items: stretch;
    }

    .library-controls {
        flex-wrap: wrap;
    }

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

    .player-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .player-track-info {
        order: 1;
    }

    .player-controls {
        order: 2;
    }

    .player-right {
        order: 3;
        justify-content: space-between;
    }

    .volume-control {
        display: none;
    }

    .queue-panel {
        width: 100vw;
        right: -100vw;
    }
}
