/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.08);
    --border-active: rgba(233,69,96,0.5);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --accent: #e94560;
    --accent-light: #ff6b8a;
    --accent-glow: rgba(233,69,96,0.15);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234,179,8,0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59,130,246,0.12);
    --spotify: #1DB954;
    --spotify-bg: rgba(29,185,84,0.12);
    --red-bg: rgba(233,69,96,0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── LAYOUT ── */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

@media (min-width: 640px) {
    .container { padding: 40px 24px 60px; }
}

/* ── HEADER ── */
.header {
    text-align: center;
    margin-bottom: 36px;
}
.header-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 16px;
    box-shadow: 0 0 40px var(--accent-glow);
}
.header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.header p {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 14px;
}
.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    background: var(--green-bg);
    color: var(--green);
    font-weight: 500;
}

/* ── CARD ── */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* ── FORM ELEMENTS ── */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
label i { margin-right: 6px; opacity: 0.7; }
label .label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

textarea, select, input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    resize: none;
}
textarea:focus, select:focus, input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea::placeholder { color: var(--text-muted); }

select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
select option { background: #1a1a2e; color: var(--text-primary); }

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.textarea-footer button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 12px; font-family: inherit;
    transition: color var(--transition);
}
.textarea-footer button:hover { color: var(--accent); }

/* ── SOURCE BADGES ── */
.source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 500;
}
.source-badge.youtube { background: rgba(255,0,0,0.12); color: #ff4444; }
.source-badge.spotify { background: var(--spotify-bg); color: var(--spotify); }
.source-badge.soundcloud { background: rgba(255,85,0,0.12); color: #ff5500; }
.source-badge.tiktok { background: rgba(0,242,234,0.12); color: #00f2ea; }
.source-badge.other { background: var(--blue-bg); color: var(--blue); }

/* ── GRID ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 640px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* ── TOGGLE BUTTONS ── */
.toggle-group {
    display: flex;
    gap: 8px;
}
.toggle-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.toggle-btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.15);
}
.toggle-btn.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text-primary);
}
.toggle-btn i { margin-right: 6px; }

/* ── CHECKBOX ROW ── */
.options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}
.option-item input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── SAVE TO MUSIC TOGGLE ── */
.music-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--green-bg);
    border: 1px solid rgba(34,197,94,0.2);
    border-radius: var(--radius);
    margin-bottom: 20px;
    cursor: pointer;
    transition: all var(--transition);
}
.music-toggle:hover { border-color: rgba(34,197,94,0.4); }
.music-toggle i { color: var(--green); font-size: 18px; }
.music-toggle .mt-text { flex: 1; }
.music-toggle .mt-title { font-size: 14px; font-weight: 600; color: var(--green); }
.music-toggle .mt-desc { font-size: 11px; color: var(--text-muted); }
.music-toggle input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--green); cursor: pointer;
}

/* ── PRIMARY BUTTON ── */
.btn-primary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(233,69,96,0.3);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ── PROGRESS ── */
.progress-section { display: none; }
.progress-section.visible { display: block; }

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.progress-header h3 { font-size: 16px; font-weight: 600; }
.progress-header h3 i { margin-right: 8px; color: var(--accent); }
.progress-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}
.progress-meta span { font-size: 13px; color: var(--text-muted); }
.progress-pct { color: var(--accent) !important; font-weight: 700; }

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    transition: width 0.3s ease;
    width: 0%;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-status {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 10px;
}
.progress-status i { margin-right: 6px; }

/* ── QUEUE ITEMS ── */
.queue-list {
    margin-top: 14px;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    font-size: 13px;
}
.queue-item.active { outline: 1px solid rgba(234,179,8,0.3); }
.queue-item .qi-icon { width: 16px; text-align: center; }
.queue-item .qi-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .qi-num { font-size: 11px; color: var(--text-muted); }
.qi-pending { color: var(--text-muted); }
.qi-downloading { color: var(--yellow); }
.qi-success { color: var(--green); }
.qi-error { color: var(--accent); }

/* ── RESULTS ── */
.results-section { display: none; }
.results-section.visible { display: block; }
.results-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.results-section h3 i { margin-right: 8px; color: var(--green); }

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: background var(--transition);
}
.file-item:hover { background: rgba(255,255,255,0.06); }
.file-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.file-icon.video { background: var(--red-bg); color: var(--accent); }
.file-icon.audio { background: var(--blue-bg); color: var(--blue); }
.file-icon.subtitle { background: var(--yellow-bg); color: var(--yellow); }
.file-icon.thumbnail { background: var(--green-bg); color: var(--green); }
.file-icon.other { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--text-muted); }

.file-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-file {
    padding: 6px 14px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-file.download {
    background: var(--green-bg);
    color: var(--green);
}
.btn-file.download:hover { background: rgba(34,197,94,0.2); }
.btn-file.delete {
    background: var(--red-bg);
    color: var(--accent);
}
.btn-file.delete:hover { background: rgba(233,69,96,0.2); }

/* ── DEBUG ── */
.debug-section { display: none; }
.debug-section.visible { display: block; }
.debug-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.debug-section h3 i { margin-right: 8px; color: var(--yellow); }
.debug-pre {
    background: rgba(0,0,0,0.4);
    padding: 16px;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
}

/* ── HISTORY ── */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.history-header h3 { font-size: 16px; font-weight: 600; }
.history-header h3 i { margin-right: 8px; color: var(--blue); }
.btn-clear {
    background: none; border: none; color: var(--text-muted);
    font-size: 12px; font-family: inherit; cursor: pointer;
    transition: color var(--transition);
}
.btn-clear:hover { color: var(--accent); }
.btn-clear i { margin-right: 4px; }

.history-list {
    max-height: 280px;
    overflow-y: auto;
}
.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background var(--transition);
    cursor: default;
}
.history-item:hover { background: rgba(255,255,255,0.04); }
.history-item .hi-icon { color: var(--text-muted); width: 16px; text-align: center; }
.history-item .hi-text { flex: 1; min-width: 0; }
.history-item .hi-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .hi-date { font-size: 11px; color: var(--text-muted); }
.history-item .hi-source {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}
.btn-redo {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; font-size: 12px;
    border-radius: 6px;
    transition: all var(--transition);
    opacity: 0;
}
.history-item:hover .btn-redo { opacity: 1; }
.btn-redo:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

/* ── SETUP ── */
.setup-card details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
}
.setup-card details summary::-webkit-details-marker { display: none; }
.setup-card details summary h3 { font-size: 16px; font-weight: 600; }
.setup-card details summary h3 i { margin-right: 8px; color: var(--yellow); }
.setup-card details summary .chevron { transition: transform 0.2s; }
.setup-card details[open] summary .chevron { transform: rotate(180deg); }

.setup-content {
    margin-top: 16px;
}
.code-block {
    background: rgba(0,0,0,0.4);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    overflow-x: auto;
    line-height: 1.6;
}
.code-block .comment { color: var(--green); }
.code-block .cmd { color: var(--text-secondary); }

.alert-yellow {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--yellow-bg);
    border: 1px solid rgba(234,179,8,0.2);
    border-radius: var(--radius);
    margin-top: 14px;
    font-size: 13px;
    color: var(--yellow);
}
.alert-yellow i { margin-top: 2px; }

.btn-test {
    margin-top: 14px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    background: var(--yellow-bg);
    color: var(--yellow);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-test:hover { background: rgba(234,179,8,0.2); }
.btn-test:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-test i { margin-right: 6px; }

/* ── FOOTER ── */
.footer {
    text-align: center;
    margin-top: 28px;
    font-size: 12px;
    color: var(--text-muted);
}
.footer i { margin-right: 4px; }

/* ── NOTIFICATIONS ── */
.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.notification.show { transform: translateX(0); }
.notification.success { background: #166534; color: #bbf7d0; }
.notification.error { background: #7f1d1d; color: #fecaca; }
.notification.info { background: #1e3a5f; color: #bfdbfe; }

/* ── FILES BROWSER ── */
.files-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 3px;
}
.files-tab {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.files-tab:hover { color: var(--text-secondary); }
.files-tab.active {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}
.files-tab .tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(255,255,255,0.1);
    font-size: 10px;
    margin-left: 5px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── HIDDEN ── */
.hidden { display: none !important; }

/* ── SECTION SPACING ── */
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }