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

:root {
    --primary-color: #ff0000;
    --accent-color: #ff4444;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-radius: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.15);
    --green: #27ae60;
    --red: #e74c3c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* ─── Header ─── */

header {
    text-align: center;
    padding: 40px 20px;
    color: white;
}

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

.logo i {
    font-size: 48px;
    color: #ff0000;
    background: white;
    padding: 10px;
    border-radius: 50%;
}

.logo h1 {
    font-size: 42px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 18px;
    opacity: 0.95;
    font-weight: 300;
}

/* ─── Main ─── */

main {
    background: white;
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

/* ─── Search ─── */

.search-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#urlInput {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: all 0.3s ease;
}

#urlInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.btn-primary {
    padding: 16px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.hint {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 4px;
}

/* ─── Loading / Hidden ─── */

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

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* ─── Error ─── */

.error-message {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    border-left: 4px solid #c33;
}

.error-message i {
    font-size: 24px;
}

/* ─── Video Card ─── */

.video-card {
    display: flex;
    gap: 24px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    padding: 24px;
    animation: fadeIn 0.5s ease;
}

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

.video-card img {
    width: 280px;
    height: 157px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.video-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-details h2 {
    font-size: 22px;
    color: var(--text-primary);
    line-height: 1.3;
}

.author, .duration, .count {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 15px;
}

.btn-download {
    margin-top: auto;
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-download:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

/* ─── Progress Bar ─── */

.progress-section {
    margin-top: 20px;
    animation: fadeIn 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ─── Playlist ─── */

.playlist-header {
    display: flex;
    gap: 24px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease;
}

.playlist-header img {
    width: 200px;
    height: 112px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.playlist-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.playlist-details h2 {
    font-size: 20px;
    line-height: 1.3;
}

.playlist-videos {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 4px;
}

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

.playlist-videos::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.playlist-videos::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.playlist-videos::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
    transition: background 0.2s;
    animation: fadeIn 0.3s ease;
}

.playlist-item:hover {
    background: #f0f0f0;
}

.playlist-item img {
    width: 100px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

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

.playlist-item-info h4 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-item-duration {
    font-size: 12px;
    color: var(--text-secondary);
}

.playlist-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-download-small {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-download-small:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-download-small:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-download-small.btn-success {
    background: var(--green) !important;
}

.btn-download-small.btn-error {
    background: var(--red) !important;
}

/* ─── Mini Progress Bar (playlist items) ─── */

.playlist-item-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.mini-progress-bar {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 0%;
}

.mini-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: right;
}

/* ─── Footer ─── */

footer {
    color: white;
    text-align: center;
    padding: 40px 20px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
    padding: 0 20px;
}

.feature {
    text-align: center;
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.feature:hover {
    transform: translateY(-5px);
}

.feature i {
    font-size: 40px;
    margin-bottom: 15px;
    display: block;
}

.feature h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.feature p {
    opacity: 0.9;
    font-size: 14px;
}

.copyright {
    opacity: 0.8;
    font-size: 14px;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    main {
        padding: 20px;
    }

    .logo h1 {
        font-size: 28px;
    }

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

    .video-card, .playlist-header {
        flex-direction: column;
    }

    .video-card img, .playlist-header img {
        width: 100%;
        height: auto;
    }

    .playlist-item img {
        width: 70px;
        height: 40px;
    }

    .playlist-item-info h4 {
        font-size: 12px;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}
