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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f13;
    color: #e0e0e0;
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 1.5rem;
    color: #fff;
}

.logout-btn { color: #888; }
.logout-btn:hover { color: #f88; }

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 0;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: #ccc; }
.tab.active { color: #fff; border-bottom-color: #1db954; }

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

.card {
    background: #1a1a24;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: #fff;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.form-row input:focus {
    outline: none;
    border-color: #1db954;
}

.download-options {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.download-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #aaa;
}

.download-opt select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.85rem;
}

.download-opt select:focus {
    outline: none;
    border-color: #1db954;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn.primary {
    background: #1db954;
    color: #fff;
}

.btn.primary:hover { background: #1ed760; }

.full-width { width: 100%; }

.btn-sm {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    background: #333;
    color: #ccc;
}

.btn-sm.danger { background: #5c2020; color: #f88; }
.btn-sm.danger:hover { background: #7a2a2a; }

.message { margin-top: 8px; font-size: 0.85rem; min-height: 20px; }
.message.success { color: #1db954; }
.message.error { color: #e74c3c; }

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.filters select, .filters input {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.9rem;
}

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

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #2a2a35;
    font-size: 0.9rem;
}

th { color: #888; font-weight: 500; }

tr:hover { background: #1f1f2e; }

a { color: #1db954; text-decoration: none; }
a:hover { text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge.pending { background: #2a2a35; color: #f0ad4e; }
.badge.downloading { background: #1a3a5c; color: #5dade2; }
.badge.done { background: #1a3c1a; color: #1db954; }
.badge.error { background: #3c1a1a; color: #e74c3c; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: #aaa;
}

.form-grid input, .form-grid select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.form-grid input:focus, .form-grid select:focus {
    outline: none;
    border-color: #1db954;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card {
    background: #1a1a24;
    border-radius: 12px;
    padding: 32px;
    width: 360px;
    text-align: center;
}

.login-card h1 {
    margin-bottom: 24px;
    font-size: 1.3rem;
    color: #fff;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 14px;
}

.login-card input {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.login-card input:focus {
    outline: none;
    border-color: #1db954;
}

.login-card .btn {
    margin-top: 6px;
}

.progress-info { display: flex; flex-direction: column; gap: 8px; }

.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: #2a2a35;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #1db954;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: #ccc;
}

.progress-track {
    font-size: 0.9rem;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #888;
}

#progress-errors { color: #e74c3c; }

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #2a2a35;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.queue-item a {
    flex: 1;
    min-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-title {
    color: #e0e0e0;
    font-weight: 500;
    white-space: nowrap;
}

.queue-time {
    color: #666;
    font-size: 0.8rem;
    white-space: nowrap;
}

.queue-error {
    color: #e74c3c;
    font-size: 0.8rem;
    cursor: help;
    text-decoration: underline dotted;
}

.queue-empty {
    color: #555;
    font-size: 0.9rem;
    padding: 10px 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.card-header h2 {
    margin-bottom: 0;
}

.lib-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}

.lib-search {
    flex: 1;
}

.lib-search input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.lib-search input:focus {
    outline: none;
    border-color: #1db954;
}

.lib-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lib-nav select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #12121a;
    color: #e0e0e0;
    font-size: 0.85rem;
}

.breadcrumb {
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.bc-link {
    color: #1db954;
    cursor: pointer;
}

.bc-link:hover {
    text-decoration: underline;
}

.bc-sep {
    color: #555;
    margin: 0 4px;
}

.bc-current {
    color: #ccc;
}

.lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.lib-card {
    background: #12121a;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.lib-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.lib-card.artist-card {
    text-align: center;
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border: 1px solid #1f1f35;
}

.lib-card.artist-card:hover {
    box-shadow: 0 6px 24px rgba(29,185,84,0.15);
    border-color: #1db954;
}

.lib-cover {
    width: 100%;
    aspect-ratio: 1;
    background: #1a1a24;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lib-card.artist-card .lib-cover {
    padding: 16px;
    position: relative;
}

.lib-card.artist-card .lib-cover-inner {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.lib-card.artist-card .lib-cover-inner::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid rgba(29,185,84,0.3);
    pointer-events: none;
}

.lib-card.artist-card:hover .lib-cover-inner::after {
    border-color: rgba(29,185,84,0.7);
    box-shadow: 0 0 20px rgba(29,185,84,0.2);
}

.lib-card.artist-card .cover-refresh-btn {
    bottom: 22px;
    right: 22px;
}

.lib-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lib-no-cover {
    font-size: 3rem;
    opacity: 0.3;
}

.lib-card.artist-card .lib-no-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1db954 0%, #134e2a 100%);
    font-size: 2.5rem;
    opacity: 0.6;
}

.lib-card.album-card .lib-cover {
    border-radius: 8px 8px 0 0;
}

.lib-card.album-card .lib-cover img {
    border-radius: 8px 8px 0 0;
}

.lib-info {
    padding: 10px 12px;
}

.lib-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-meta {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.lib-loading {
    color: #888;
    padding: 30px 0;
    text-align: center;
}

.lib-empty {
    color: #555;
    padding: 30px 0;
    text-align: center;
}

.lib-section-title {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 0 4px;
    border-bottom: 1px solid #2a2a35;
    margin-bottom: 4px;
}

.lib-tracks {
    width: 100%;
    border-collapse: collapse;
}

.lib-tracks th {
    padding: 8px 12px;
    text-align: left;
    color: #888;
    font-weight: 500;
    font-size: 0.85rem;
    border-bottom: 1px solid #2a2a35;
}

.lib-tracks td {
    padding: 8px 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid #1f1f2e;
}

.lib-tracks tr:hover {
    background: #1f1f2e;
}

.track-num {
    width: 40px;
    color: #666;
}

.track-dur {
    width: 60px;
    color: #888;
}

.track-fmt {
    width: 60px;
    color: #666;
    font-size: 0.8rem;
}

.album-actions {
    grid-column: 1 / -1;
    margin-bottom: 8px;
}

.album-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a2a35;
    text-align: center;
}

.album-header-cover {
    width: 200px;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    position: relative;
}

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

.lib-no-cover-lg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1db954 0%, #134e2a 100%);
    font-size: 3rem;
}

.album-header-info {
    max-width: 100%;
}

.album-header-artist {
    font-size: 0.9rem;
    color: #1db954;
    margin-bottom: 4px;
}

.album-header-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    word-break: break-word;
}

.album-header-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #888;
    justify-content: center;
    flex-wrap: wrap;
}

.album-header-actions {
    display: flex;
    gap: 8px;
}

.cover-refresh-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.7);
    color: #ccc;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    z-index: 2;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-refresh-btn:hover {
    background: rgba(29,185,84,0.9);
    color: #fff;
}

.fetch-cover-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(29,185,84,0.9);
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 2;
    transition: background 0.2s;
}

.fetch-cover-btn:hover {
    background: rgba(29,185,84,1);
}

.lib-cover {
    position: relative;
}

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .login-card { width: 90%; }
    .lib-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .lib-toolbar { flex-direction: column; }
}
