
/* --- 1. Material 3 & Apple Design Tokens --- */
:root {
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* M3 Light Theme */
    --m3-primary: #0058E3;
    --m3-on-primary: #FFFFFF;
    --m3-surface: #FDFCFF;
    --m3-surface-container: #FFFFFF;
    --m3-on-surface: #1C1B1F;
    --m3-outline: #79747E;
    --m3-error: #B3261E;
    
    /* Apple Glass Light */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-apple: 0 8px 32px 0 rgba(0, 0, 0, 0.04);
    --shadow-m3: 0 2px 6px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
}

[data-theme="dark"] {
    --m3-primary: #A8C7FA;
    --m3-on-primary: #003258;
    --m3-surface: #141218;
    --m3-surface-container: #1C1B1F;
    --m3-on-surface: #E6E1E5;
    --m3-outline: #938F99;
    --m3-error: #F2B8B5;
    
    --glass-bg: rgba(28, 27, 31, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-apple: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --shadow-m3: 0 2px 6px rgba(0,0,0,0.2);
}

/* --- 2. Base & Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background-color: var(--m3-surface);
    color: var(--m3-on-surface);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 16px;
    width: 100%;
    flex: 1;
}

/* --- 3. Components --- */

/* Glassmorphism Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px; /* M3 Large Shape */
    box-shadow: var(--shadow-apple);
}

/* Header */
.app-header {
    position: sticky;
    top: 16px;
    z-index: 100;
    margin: 16px auto;
    max-width: 1000px;
    width: calc(100% - 32px);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 100px; /* Apple Pill Shape */
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 24px; }
.logo h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }

.header-actions { display: flex; align-items: center; gap: 16px; }

.queue-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--m3-outline);
    padding: 6px 12px;
    background: rgba(0,0,0,0.03);
    border-radius: 100px;
}
[data-theme="dark"] .queue-badge { background: rgba(255,255,255,0.05); }

.pulse {
    width: 8px; height: 8px;
    background: #34C759; /* Apple Green */
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(52, 199, 89, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

.theme-switcher {
    display: flex;
    background: rgba(0,0,0,0.05);
    border-radius: 100px;
    padding: 4px;
}
[data-theme="dark"] .theme-switcher { background: rgba(255,255,255,0.08); }
.theme-switcher button {
    background: none; border: none; cursor: pointer;
    padding: 6px 10px; border-radius: 100px;
    font-size: 14px; transition: all 0.2s;
}
.theme-switcher button.active {
    background: var(--m3-surface-container);
    box-shadow: var(--shadow-m3);
}

/* Hero */
.hero { text-align: center; margin: 48px 0 32px; }
.hero-title { font-size: clamp(32px, 5vw, 48px); font-weight: 800; letter-spacing: -1px; margin-bottom: 12px; }
.hero-subtitle { font-size: 18px; color: var(--m3-outline); max-width: 600px; margin: 0 auto; }

/* Input Section */
.input-section { padding: 32px; margin-bottom: 32px; }

.tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--glass-border); }
.tab-btn {
    background: none; border: none; padding: 12px 20px;
    font-size: 15px; font-weight: 600; color: var(--m3-outline);
    cursor: pointer; position: relative; transition: color 0.2s;
}
.tab-btn.active { color: var(--m3-primary); }
.tab-btn.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
    height: 3px; background: var(--m3-primary); border-radius: 3px 3px 0 0;
}
.badge {
    font-size: 10px; background: var(--m3-primary); color: var(--m3-on-primary);
    padding: 2px 6px; border-radius: 100px; margin-left: 6px; vertical-align: middle;
}

.form-container { display: none; }
.form-container.active { display: block; animation: fadeIn 0.3s ease; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.optional { font-weight: 400; color: var(--m3-outline); font-size: 12px; }

textarea, input[type="email"], .search-input {
    width: 100%; padding: 16px;
    background: rgba(0,0,0,0.03); border: 2px solid transparent;
    border-radius: 16px; font-family: inherit; font-size: 15px;
    color: var(--m3-on-surface); transition: all 0.2s;
    outline: none;
}
[data-theme="dark"] textarea, [data-theme="dark"] input[type="email"], [data-theme="dark"] .search-input { background: rgba(255,255,255,0.05); }

textarea:focus, input[type="email"]:focus, .search-input:focus {
    border-color: var(--m3-primary); background: var(--m3-surface-container);
}

textarea { resize: vertical; min-height: 100px; }

.file-input {
    font-size: 14px; color: var(--m3-outline);
}
.file-input::file-selector-button {
    background: var(--m3-surface-container); border: 1px solid var(--glass-border);
    padding: 8px 16px; border-radius: 100px; margin-right: 16px;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.file-input::file-selector-button:hover { background: var(--m3-primary); color: var(--m3-on-primary); border-color: var(--m3-primary); }

.btn-primary {
    width: 100%; padding: 16px;
    background: var(--m3-primary); color: var(--m3-on-primary);
    border: none; border-radius: 100px; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    box-shadow: var(--shadow-m3);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-loader {
    width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite;
}
.hidden { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-status { margin-top: 16px; text-align: center; font-size: 14px; font-weight: 500; min-height: 20px; }
.form-status.success { color: #34C759; }
.form-status.error { color: var(--m3-error); }

/* Task Board */
.task-board { padding: 32px; margin-bottom: 48px; }
.board-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.board-title { font-size: 22px; font-weight: 700; }

.board-controls { display: flex; align-items: center; gap: 12px; flex: 1; max-width: 500px; }
.search-input { flex: 1; padding: 12px 16px; border-radius: 100px; font-size: 14px; }

.icon-btn {
    background: rgba(0,0,0,0.05); border: none; width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--m3-on-surface); transition: all 0.2s;
}
[data-theme="dark"] .icon-btn { background: rgba(255,255,255,0.08); }
.icon-btn:hover { background: rgba(0,0,0,0.1); }
[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,0.15); }
.icon-btn.loading svg { animation: spin 1s linear infinite; }

.view-toggle { display: flex; background: rgba(0,0,0,0.05); border-radius: 100px; padding: 4px; }
[data-theme="dark"] .view-toggle { background: rgba(255,255,255,0.08); }
.view-toggle button {
    background: none; border: none; width: 32px; height: 32px; border-radius: 50%;
    cursor: pointer; font-size: 16px; color: var(--m3-outline); transition: all 0.2s;
}
.view-toggle button.active { background: var(--m3-surface-container); color: var(--m3-on-surface); box-shadow: var(--shadow-m3); }

/* Task Items */
.task-container.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.task-container.list-view { display: flex; flex-direction: column; gap: 12px; }

.task-card {
    background: var(--m3-surface-container); border-radius: 16px; padding: 20px;
    cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
    display: flex; flex-direction: column; gap: 12px;
}
.task-card:hover { border-color: var(--m3-primary); transform: translateY(-2px); box-shadow: var(--shadow-m3); }

.task-header { display: flex; justify-content: space-between; align-items: center; }
.task-title { font-size: 16px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-artist { font-size: 13px; color: var(--m3-outline); }

.status-badge {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 4px 10px; border-radius: 100px;
}
.status-pending { background: #FF9F0A20; color: #FF9F0A; }
.status-processing { background: #0A84FF20; color: #0A84FF; }
.status-complete { background: #34C75920; color: #34C759; }
.status-error { background: #FF453A20; color: #FF453A; }

.downloaded-badge {
    font-size: 11px; color: #34C759; display: flex; align-items: center; gap: 4px;
}

.empty-state { text-align: center; padding: 48px 24px; color: var(--m3-outline); }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px);
    z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px;
    opacity: 1; transition: opacity 0.3s;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto;
    padding: 32px; position: relative; transform: translateY(0); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.hidden .modal-content { transform: translateY(20px); }

.modal-close {
    position: absolute; top: 16px; right: 16px; width: 32px; height: 32px;
    border-radius: 50%; background: rgba(0,0,0,0.05); border: none;
    font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .modal-close { background: rgba(255,255,255,0.1); }

.video-player { width: 100%; border-radius: 16px; margin-bottom: 24px; background: #000; }

.download-card {
    text-align: center; padding: 32px; border: 2px dashed var(--m3-outline);
    border-radius: 24px; margin-bottom: 24px;
}
.download-card h4 { font-size: 20px; margin-bottom: 8px; }
.download-card p { font-size: 14px; color: var(--m3-outline); margin-bottom: 24px; }

/* Footer */
.app-footer {
    text-align: center; padding: 32px 16px; color: var(--m3-outline); font-size: 14px;
    margin-top: auto;
}
.app-footer a { color: var(--m3-primary); text-decoration: none; font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }
.footer-sub { font-size: 12px; margin-top: 4px; opacity: 0.7; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease forwards; }

/* Responsive */
@media (max-width: 640px) {
    .app-header { border-radius: 24px; padding: 12px 16px; }
    .board-header { flex-direction: column; align-items: flex-start; }
    .board-controls { max-width: 100%; width: 100%; }
    .hero-title { font-size: 32px; }
}