/* =============================================
   AIFF-to-MP3 Converter — Mobile-first Styles
   ============================================= */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #24243a;
    --border-color: #2e2e48;
    --border-hover: #6366f1;
    --text-primary: #e0e0e0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --transition: 0.2s ease;
    --max-w: 640px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 100;
    font-size: 0.875rem;
}
.skip-link:focus { top: 16px; }

header {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
nav {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 8px;
}
.logo {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.logo:hover { color: var(--accent); }
.logo-icon { font-size: 1.3rem; }
.nav-links {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
    background: var(--accent-glow);
    color: var(--accent);
}

main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 32px 16px 48px;
}
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}
.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 32px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.converter-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.upload-zone.drag-over {
    transform: scale(1.01);
}
.upload-icon {
    color: var(--accent);
    opacity: 0.8;
}
.upload-text {
    font-size: 1.05rem;
    font-weight: 500;
}
.upload-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    animation: slideIn 0.2s ease-out;
}
.file-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-primary);
    flex-shrink: 0;
}
.file-info {
    flex: 1;
    min-width: 0;
}
.file-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.file-status {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.file-status.pending { color: var(--text-muted); }
.file-status.converting { color: var(--accent); }
.file-status.done { color: var(--success); }
.file-status.error { color: var(--error); }

.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1;
    transition: color var(--transition);
}
.file-remove:hover { color: var(--error); }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn {
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn:active { transform: scale(0.97); }

.btn-convert {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.btn-convert:hover { background: var(--accent-hover); }
.btn-convert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-clear {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-clear:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

.btn-download-all {
    margin-top: 16px;
    width: 100%;
    background: var(--success);
    color: #fff;
    justify-content: center;
}
.btn-download-all:hover { background: #16a34a; }

.btn-download {
    background: var(--bg-tertiary);
    color: var(--accent);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    font-size: 0.8rem;
}
.btn-download:hover { background: var(--accent-glow); border-color: var(--accent); }

.btn-spinner {
    display: inline-flex;
    animation: spin 0.8s linear infinite;
}

.progress-bar {
    margin-top: 16px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: var(--radius-sm);
    width: 0%;
    transition: width 0.3s ease;
}
.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    mix-blend-mode: difference;
}

.results { margin-top: 24px; }
.results-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.result-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    animation: slideIn 0.3s ease-out;
}
.result-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.result-info {
    flex: 1;
    min-width: 0;
}
.result-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.error-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.85rem;
    font-weight: 500;
}

.info-section {
    margin-top: 48px;
}
.info-section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
}
.steps {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
.step {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.step h3 {
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.step p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: 48px;
}

@media (min-width: 480px) {
    main { padding: 40px 24px 56px; }
    .results-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 640px) {
    .page-title { font-size: 2rem; }
    .steps { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

[hidden] { display: none !important; }