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

:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1f1f1f;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --text-muted: #888;
    --accent: #1DB954;
    --accent-hover: #1ed760;
    --accent-dim: rgba(29, 185, 84, 0.1);
    --danger: #ff4444;
    --warning: #f0a500;
    --radius: 16px;
    --radius-sm: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

/* Header */
.header {
    text-align: center;
    padding: 1rem 0 2rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.35rem;
    font-weight: 400;
}

/* Auth area */
.auth-area {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-btn, .logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s ease;
    text-decoration: none;
}

.login-btn {
    background: var(--accent);
    color: #000;
    box-shadow: 0 4px 15px rgba(29, 185, 84, 0.3);
}

.login-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(29, 185, 84, 0.4);
}

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

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent);
}

#userName {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.logout-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    border-radius: 50px;
    margin-left: 0.75rem;
}

.logout-btn:hover {
    border-color: #555;
    color: var(--text);
    background: var(--surface-hover);
}

.logout-btn:active {
    background: var(--surface);
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
}

.upload-prompt p {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* Button */
.btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 1.25rem auto 0;
    padding: 0.9rem 2rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s ease;
    text-align: center;
}

.btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(29, 185, 84, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    background: var(--surface);
    color: #555;
    cursor: not-allowed;
    border: 1px solid var(--border);
}

/* Loading */
.loading {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 0.75rem;
}

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

/* Error */
.error {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 68, 68, 0.08);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.shake { animation: shake 0.35s ease-in-out; }

/* Results */
.results {
    margin-top: 1.5rem;
}

.results h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-align: center;
}

.confidence {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.5rem 0 1.25rem;
}

/* Track list */
.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.track-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    border: 1px solid transparent;
}

.track-list li:hover {
    background: var(--surface);
    border-color: var(--border);
}

.track-list .track-num {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

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

.track-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-spotify {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.8;
}

.track-spotify:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Save area */
.save-area {
    text-align: center;
    margin: 1.5rem 0 0;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border);
}

.save-btn {
    margin-top: 0;
}

.save-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.save-status.success { color: var(--accent); }
.save-status.error { color: var(--danger); }
.save-status.warning { color: var(--warning); }

.save-status a {
    color: var(--accent);
    text-decoration: underline;
}

.save-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.save-hint a {
    color: var(--accent);
    text-decoration: underline;
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s;
    font-weight: 400;
}

.footer a:hover {
    color: var(--accent);
}

.footer-dot {
    color: var(--border);
    font-size: 0.85rem;
    user-select: none;
}

/* Terms modal */
.terms-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.terms-modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    color: var(--text);
}

.terms-modal-content h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
}

.terms-modal-content p {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.terms-links {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.terms-links a {
    color: var(--accent);
    text-decoration: none;
}

.terms-links a:hover {
    text-decoration: underline;
}

.terms-links .dot {
    color: var(--border);
    user-select: none;
}

.terms-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}

.terms-checkbox input {
    margin-top: 0.2rem;
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.terms-actions .btn {
    max-width: none;
    margin-top: 0;
    flex: 1;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: #555;
}

/* Legal pages (standalone) */
.legal-content {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
    color: var(--text);
}

.legal-content h1 {
    color: var(--text);
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    background: none;
    -webkit-text-fill-color: initial;
}

.legal-content h2 {
    color: var(--text);
    font-size: 1.1rem;
    margin-top: 2rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.legal-content p {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.legal-content a {
    color: var(--accent);
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

/* Mobile */
@media (max-width: 480px) {
    .container { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.8rem; }
    .upload-area { min-height: 160px; padding: 2rem 1rem; }
    .track-list li { padding: 0.6rem 0.4rem; }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .spinner, .shake { animation: none; }
    .btn, .login-btn { transition: none; }
}
