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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 50%, #0f0f23 100%);
    min-height: 100vh;
    color: #e0e0e0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo svg {
    color: #6366f1;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #9ca3af;
    font-size: 1rem;
}

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

.input-wrapper {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e0e0e0;
    font-size: 1rem;
    padding: 12px 16px;
}

.input-wrapper input::placeholder {
    color: #6b7280;
}

.input-wrapper button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.input-wrapper button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.input-wrapper button:active {
    transform: translateY(0);
}

/* Error Message */
.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.loading p {
    color: #9ca3af;
}

/* Video Card */
.video-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.video-info {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.video-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 240px;
    border-radius: 12px;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.video-details {
    flex: 1;
    min-width: 0;
}

.video-details h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f0f0f0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.uploader {
    color: #8b5cf6;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.description {
    color: #9ca3af;
    font-size: 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Format Section */
.format-section {
    margin-bottom: 24px;
}

.format-section h3 {
    font-size: 1rem;
    color: #d1d5db;
    margin-bottom: 12px;
}

.format-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.format-option {
    cursor: pointer;
}

.format-option input {
    display: none;
}

.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.2s;
}

.format-option:hover .format-card {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

.format-option.selected .format-card {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.format-icon {
    color: #6366f1;
}

.format-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #e0e0e0;
}

.format-desc {
    font-size: 0.8rem;
    color: #9ca3af;
}

.format-list {
    margin-top: 12px;
}

.format-list h4 {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 8px;
}

.format-list select {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.format-list select:focus {
    border-color: #6366f1;
}

.format-list select option {
    background: #1a1a3e;
    color: #e0e0e0;
}

/* Download Button */
.action-section {
    text-align: center;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

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

.download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Progress Section */
.progress-section {
    margin-bottom: 20px;
}

.progress-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-header h3 {
    font-size: 1rem;
    color: #d1d5db;
    margin: 0;
}

.stop-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    text-decoration: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.stop-btn:hover {
    background: #dc2626 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.current-file {
    color: #a855f7;
    font-size: 0.85rem;
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
    border-radius: 5px;
    transition: width 0.3s ease;
}

#progressPercent {
    font-weight: 600;
    font-size: 0.9rem;
    color: #a855f7;
    min-width: 50px;
    text-align: right;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    color: #9ca3af;
    font-size: 0.85rem;
}

/* Success Section */
.success-section {
    text-align: center;
}

.success-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 20px;
    padding: 40px;
    animation: fadeIn 0.3s ease;
}

.success-card h3 {
    font-size: 1.3rem;
    color: #22c55e;
    margin: 16px 0 8px;
}

.success-card p {
    color: #9ca3af;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.save-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.new-download-btn {
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.new-download-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    color: #6b7280;
    font-size: 0.85rem;
}

.footer strong {
    color: #8b5cf6;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Playlist Videos */
.playlist-videos {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
}

.playlist-videos::-webkit-scrollbar {
    width: 6px;
}

.playlist-videos::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.playlist-videos::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.5);
    border-radius: 3px;
}

.playlist-video-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.playlist-video-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.video-number {
    color: #6366f1;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 24px;
    text-align: center;
}

.video-thumb-small {
    width: 80px;
    height: 45px;
    border-radius: 6px;
    object-fit: cover;
}

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

.video-title-small {
    display: block;
    font-size: 0.85rem;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-duration-small {
    font-size: 0.75rem;
    color: #9ca3af;
}

.progress-info {
    margin-bottom: 12px;
    color: #d1d5db;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 20px 16px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .input-wrapper button {
        justify-content: center;
    }

    .video-info {
        flex-direction: column;
    }

    .video-thumbnail {
        width: 100%;
    }

    .format-options {
        grid-template-columns: 1fr;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }

    .save-btn, .new-download-btn {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 12px;
        text-align: center;
    }

    .video-thumb-small {
        width: 60px;
        height: 34px;
    }
}
