:root {
    --bg-main: #070a12;
    --bg-card: rgba(15, 23, 42, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.4);
    --border-accent: rgba(6, 182, 212, 0.4);

    --primary-indigo: #6366f1;
    --primary-purple: #8b5cf6;
    --primary-cyan: #06b6d4;
    --primary-emerald: #10b981;
    --primary-rose: #f43f5e;

    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    --gradient-badge: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-btn: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-btn-hover: linear-gradient(135deg, #6366f1 0%, #9333ea 100%);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Ambient glow background effect */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.45;
}

.glow-1 {
    width: 450px;
    height: 450px;
    top: -100px;
    left: -100px;
    background: radial-gradient(circle, var(--primary-indigo), transparent 70%);
}

.glow-2 {
    width: 500px;
    height: 500px;
    top: 20%;
    right: -150px;
    background: radial-gradient(circle, var(--primary-purple), transparent 70%);
}

.glow-3 {
    width: 400px;
    height: 400px;
    bottom: -50px;
    left: 30%;
    background: radial-gradient(circle, var(--primary-cyan), transparent 70%);
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    margin-bottom: 40px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-pro {
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-cyan);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(6, 182, 212, 0.4);
    margin-left: 6px;
    letter-spacing: 0.5px;
}

.header-badges {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill-badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-engine-toggle {
    cursor: pointer;
    transition: var(--transition);
}

.btn-engine-toggle:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.dot.live, .dot.connected {
    background-color: var(--primary-emerald);
    box-shadow: 0 0 8px var(--primary-emerald);
}

.dot.disconnected {
    background-color: #eab308;
    box-shadow: 0 0 8px #eab308;
}

.dot.active {
    background-color: var(--primary-cyan);
    box-shadow: 0 0 8px var(--primary-cyan);
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 35px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
    margin-bottom: 14px;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 650px;
    margin: 0 auto 30px;
}

/* Search Box Group */
.search-box-wrapper {
    max-width: 820px;
    margin: 0 auto;
    position: relative;
    padding: 3px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(6, 182, 212, 0.2));
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}

.search-box-wrapper:focus-within {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(6, 182, 212, 0.8));
    box-shadow: 0 0 35px rgba(99, 102, 241, 0.4);
}

.search-input-group {
    display: flex;
    align-items: center;
    background: rgba(13, 19, 33, 0.95);
    border-radius: calc(var(--radius-lg) - 3px);
    padding: 8px 10px 8px 18px;
    gap: 10px;
}

.link-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-family: var(--font-body);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.btn-paste {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-paste:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--gradient-btn);
    border: none;
    color: white;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--gradient-btn-hover);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

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

.btn-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Alerts */
.alert-box {
    max-width: 820px;
    margin: 18px auto 0;
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fca5a5;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.alert-message {
    flex: 1;
    text-align: left;
}

.alert-close {
    background: transparent;
    border: none;
    color: #fca5a5;
    font-size: 1.3rem;
    cursor: pointer;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease-out;
}

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

/* Video Meta Card */
.video-meta-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    gap: 24px;
    box-shadow: var(--shadow-glass);
    backdrop-filter: blur(16px);
}

.thumbnail-wrapper {
    position: relative;
    width: 240px;
    min-width: 240px;
    height: 135px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 5px;
}

.meta-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
}

.video-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

.meta-stats {
    display: flex;
    gap: 24px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-value.highlight {
    color: var(--primary-cyan);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-indigo);
    color: white;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.search-filter-box input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 9px 16px;
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    width: 220px;
    transition: var(--transition);
}

.search-filter-box input:focus {
    border-color: var(--primary-indigo);
    width: 250px;
}

/* Formats Container / Cards */
.formats-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.format-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    transition: var(--transition);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.format-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quality-badge {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.format-type-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-hd {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-audio {
    background: rgba(244, 63, 94, 0.15);
    color: var(--primary-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.tag-combined {
    background: rgba(6, 182, 212, 0.15);
    color: var(--primary-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.detail-label {
    color: var(--text-muted);
}

.detail-value {
    color: var(--text-secondary);
    font-weight: 500;
}

.filesize-highlight {
    font-size: 1rem;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.codec-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-download-format {
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    border: none;
    color: white;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-download-format:hover {
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
    transform: translateY(-1px);
}

/* Skeletons */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 820px;
    margin: 0 auto;
}

.skeleton-meta {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    gap: 20px;
}

.skeleton-thumb {
    width: 220px;
    height: 120px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    animation: shimmer 1.5s infinite;
}

.skeleton-text-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.skeleton-line {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
}

.skeleton-line.title { height: 24px; width: 80%; }
.skeleton-line.sub { height: 16px; width: 40%; }
.skeleton-line.chips { height: 28px; width: 60%; }

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-row {
    height: 70px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { opacity: 0.3; }
    50% { opacity: 0.7; }
    100% { opacity: 0.3; }
}

/* Download Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #0f172a;
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pulse-icon {
    width: 50px;
    height: 50px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-indigo);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-indeterminate {
    width: 40%;
    height: 100%;
    background: var(--gradient-brand);
    border-radius: var(--radius-full);
    position: absolute;
    animation: indeterminate 1.4s infinite ease-in-out;
}

@keyframes indeterminate {
    0% { left: -40%; }
    50% { left: 40%; }
    100% { left: 100%; }
}

.modal-tips {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    text-align: left;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    padding: 8px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-cancel:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

/* Footer */
.footer {
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding-top: 40px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    .video-meta-card {
        flex-direction: column;
    }
    .thumbnail-wrapper {
        width: 100%;
        height: 190px;
    }
    .search-input-group {
        flex-wrap: wrap;
    }
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}
