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

:root {
    --bg-primary: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.3);
    --text-primary: #eee;
    --text-secondary: #999;
    --text-muted: #666;
    --success: #4ecdc4;
    --warning: #f9c74f;
    --border: #2a2a4a;
    --radius: 16px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px;
}

header {
    text-align: center;
    padding: 24px 0 16px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.hidden {
    display: none !important;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 4px;
    border: 1px solid var(--border);
}

.mode-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-tab.active {
    background: var(--accent);
    color: #fff;
}

/* Upload Section */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:active {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.05);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.upload-filename {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    word-break: break-all;
}

/* Record Section */
#record-section {
    text-align: center;
}

.status {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status.recording {
    color: var(--accent);
    animation: pulse-text 1.5s ease-in-out infinite;
}

.timer {
    font-size: 48px;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.record-controls {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 24px;
}

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

.btn-record .btn-icon {
    background: var(--accent);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-record:active:not(:disabled) .btn-icon {
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-record.recording .btn-icon {
    animation: pulse-record 1.5s ease-in-out infinite;
}

.btn-stop .btn-icon {
    background: var(--border);
}

.audio-preview {
    margin-top: 20px;
}

.audio-preview audio {
    width: 100%;
    height: 40px;
    border-radius: 8px;
}

/* Analyze Button */
.btn-analyze {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #c0392b);
    padding: 16px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    gap: 8px;
}

.btn-analyze .btn-icon {
    width: auto;
    height: auto;
    background: none;
    box-shadow: none;
    font-size: 20px;
}

.btn-analyze .btn-label {
    color: var(--text-primary);
    font-size: 16px;
}

/* Loading */
.loader {
    text-align: center;
    padding: 40px 0;
}

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

#loading-message {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    max-width: 240px;
    margin: 0 auto;
}

.step {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.3s;
}

.step.active {
    color: var(--warning);
    background: rgba(249, 199, 79, 0.1);
}

.step.done {
    color: var(--success);
}

/* Results */
.result-card {
    animation: fade-in 0.4s ease-out;
}

.result-card h2 {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.song-meta {
    margin-bottom: 12px;
}

.song-title {
    font-size: 22px;
    font-weight: 700;
}

.song-artist {
    font-size: 16px;
    color: var(--accent);
    margin-top: 4px;
}

.song-description {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Listen Links */
.listen-links {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.listen-heading {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.listen-buttons {
    display: flex;
    gap: 8px;
}

.listen-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    transition: opacity 0.2s;
}

.listen-btn:active {
    opacity: 0.7;
}

.listen-icon {
    font-size: 14px;
}

.listen-youtube {
    background: #FF0000;
}

.listen-spotify {
    background: #1DB954;
}

.listen-apple {
    background: #FA243C;
}

.lyrics-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lyrics-column h3 {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.lyrics-column pre {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

#sheet-display {
    overflow-x: auto;
    padding: 8px 0;
}

#sheet-display svg {
    max-width: 100%;
}

/* Save */
.save-controls {
    margin-bottom: 16px;
}

.btn-save {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    background: var(--success);
    padding: 14px;
    border-radius: var(--radius);
    gap: 8px;
    color: #000;
}

.btn-save .btn-icon {
    width: auto;
    height: auto;
    background: none;
    box-shadow: none;
    font-size: 18px;
}

.btn-save .btn-label {
    color: #000;
    font-size: 15px;
    font-weight: 600;
}

/* Saved List */
.section-title {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.saved-item:active {
    background: var(--bg-card-hover);
}

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

.saved-item-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-item-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.saved-item-arrow {
    color: var(--text-muted);
    font-size: 18px;
    margin-left: 8px;
}

.saved-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
    margin-left: 8px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px;
}

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

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
    50% { box-shadow: 0 4px 40px var(--accent-glow), 0 0 60px var(--accent-glow); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #f5f5f5;
        --bg-card: #fff;
        --bg-card-hover: #f0f0f0;
        --text-primary: #222;
        --text-secondary: #666;
        --text-muted: #999;
        --border: #e0e0e0;
    }
}
