:root {
    /* Dark Mode (Default) */
    --bg-page: #09090b; /* zinc-950 */
    --card-bg: #18181b; /* zinc-900 */
    --card-border: #27272a; /* zinc-800 */
    --primary: #4f46e5; /* indigo-600 */
    --primary-hover: #4338ca;
    --accent-green: #059669; /* emerald-600 */
    --text-main: #f4f4f5; /* zinc-100 */
    --text-muted: #a1a1aa; /* zinc-400 */
    --input-bg: #18181b;
    --input-border: #27272a;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] {
    /* Light Mode */
    --bg-page: #f8fafc; /* slate-50 */
    --card-bg: #ffffff; /* white */
    --card-border: #e2e8f0; /* slate-200 */
    --primary: #4f46e5; /* indigo-600 */
    --primary-hover: #4338ca;
    --accent-green: #059669; /* emerald-600 */
    --text-main: #0f172a; /* slate-900 */
    --text-muted: #64748b; /* slate-500 */
    --input-bg: #ffffff;
    --input-border: #cbd5e1; /* slate-300 */
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 2rem 1rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 1;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--primary);
    transition: color 0.3s ease;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.3s ease;
}

.header-tagline i {
    color: #eab308; /* solid yellow bolt */
}

/* Theme Toggle Button */
.btn-theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    outline: none;
}

.btn-theme-toggle:hover {
    background: var(--input-bg);
    border-color: var(--text-muted);
}

/* Badge System */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.4k-badge {
    background: var(--input-bg);
    color: var(--text-muted);
    border: 1px solid var(--card-border);
}

/* Main Panel Card */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Hero Section */
.hero-title {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.5rem;
}

.gradient-text {
    color: var(--primary);
    transition: color 0.3s ease;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
    transition: color 0.3s ease;
}

/* Search Form */
.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.1rem;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
    transition: color 0.3s ease;
}

.input-wrapper input {
    width: 100%;
    padding: 1rem 7rem 1rem 2.8rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.input-wrapper input:focus {
    border-color: var(--primary);
    background: var(--input-bg);
}

.btn-paste {
    position: absolute;
    right: 0.6rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-paste:hover {
    background: var(--input-bg);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Skeleton Loading */
.skeleton-container {
    margin-top: 2rem;
    display: flex;
    gap: 1.25rem;
    animation: fadeIn 0.3s ease;
}

.skeleton-thumb {
    width: 200px;
    height: 115px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    animation: pulse 1.5s infinite;
}

.skeleton-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    justify-content: center;
}

.skeleton-line {
    height: 14px;
    background: var(--input-bg);
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

.skeleton-line.long { width: 90%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.short { width: 35%; }

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

/* Video Preview Card */
.preview-card {
    margin-top: 2rem;
    animation: slideUp 0.3s ease forwards;
}

.video-preview-wrapper {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.thumbnail-container {
    position: relative;
    width: 240px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--card-border);
}

.thumbnail-container img {
    width: 100%;
    height: 135px;
    object-fit: cover;
    display: block;
}

.duration-badge {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: monospace;
}

.video-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.max-badge {
    background: var(--accent-green);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    display: inline-block;
    width: fit-content;
}

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

.meta-row {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.1rem;
    transition: color 0.3s ease;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--card-border);
    margin: 1.5rem 0;
    transition: background-color 0.3s ease;
}

/* Quality Format Options Grid */
.download-options-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-subtitle {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.option-card {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.option-card:hover {
    border-color: var(--primary);
    opacity: 0.9;
}

.option-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.option-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.option-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Download Action Button */
.action-footer {
    margin-top: 1.5rem;
}

.btn-download-max {
    width: 100%;
    background: var(--accent-green);
    color: #fff;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.btn-download-max:hover {
    opacity: 0.9;
}

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

/* Progress Section */
.progress-section {
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
}

.glass-panel-inner {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.status-indicator-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pulse-ring {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

.status-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
}

.percent-counter {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 6px;
    transition: width 0.2s ease;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

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

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

/* Complete State */
.complete-state {
    margin-top: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
    animation: scaleIn 0.3s ease;
}

.success-icon {
    font-size: 2.2rem;
    color: var(--accent-green);
}

.complete-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.complete-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-save-file {
    background: var(--accent-green);
    color: #fff;
    text-decoration: none;
    padding: 0.8rem 2rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s ease;
}

.btn-save-file:hover {
    opacity: 0.9;
}

/* Features Footer */
.features-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.feature-badge {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.feature-badge i {
    color: var(--primary);
}

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

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    body { padding: 1rem 0.5rem; }
    .glass-panel { padding: 1.5rem; }
    .video-preview-wrapper { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .thumbnail-container { width: 100%; }
    .thumbnail-container img { height: 180px; }
    .stats-row { grid-template-columns: 1fr; gap: 0.5rem; }
    .app-header { flex-direction: column; align-items: flex-start; }
    .header-right { width: 100%; justify-content: space-between; }
}
