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

:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface-2: #1a1a26;
    --surface-3: #22222e;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-dim: #8888a0;
    --text-muted: #555568;
    --accent: #ff0033;
    --accent-glow: rgba(255, 0, 51, 0.3);
    --accent-soft: rgba(255, 0, 51, 0.1);
    --green: #00d26a;
    --green-glow: rgba(0, 210, 106, 0.2);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.bg-gradient {
    position: fixed;
    top: -40%;
    left: -20%;
    width: 140%;
    height: 140%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(255, 0, 51, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(100, 50, 255, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 150, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header { margin-bottom: 2.5rem; }

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 400;
    margin-top: 2px;
}

.search-section { margin-bottom: 2rem; }

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 6px 6px 16px;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
}

#urlInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    padding: 10px 0;
}

#urlInput::placeholder { color: var(--text-muted); }

#fetchBtn {
    flex-shrink: 0;
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#fetchBtn:hover { background: #e0002d; transform: translateY(-1px); }
#fetchBtn:active { transform: translateY(0); }
#fetchBtn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.spinner { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
    margin-top: 0.75rem;
    padding: 12px 16px;
    background: rgba(255, 60, 60, 0.1);
    border: 1px solid rgba(255, 60, 60, 0.2);
    border-radius: var(--radius-sm);
    color: #ff6b6b;
    font-size: 0.85rem;
    font-weight: 500;
}

.video-info { animation: fadeUp 0.4s ease; }

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

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.thumbnail-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-2);
}

.thumbnail-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.video-card:hover .thumbnail-wrap img { transform: scale(1.02); }

.duration-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(8px);
}

.video-details { padding: 1.5rem; }

.video-details h2 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.meta-row {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.meta-item svg { opacity: 0.7; }

.format-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.format-btn {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: inherit;
    color: var(--text);
}

.format-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.format-btn.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.format-res {
    font-size: 1.05rem;
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

.format-size {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.format-hd {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.download-trigger { margin-top: 1.25rem; }

.btn-start-dl {
    width: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, #cc0029 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-start-dl:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

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

.download-section {
    margin-top: 1.5rem;
    animation: fadeUp 0.4s ease;
}

.download-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.download-header h3 { font-size: 1rem; font-weight: 600; }

.dl-percent {
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, var(--accent) 0%, #ff6680 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--surface-3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, #ff4466 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2));
    animation: shimmer 1.5s infinite;
}

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

.dl-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.dl-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.btn-download-file {
    flex: 1;
    min-width: 180px;
    background: var(--green);
    color: #0a0a0f;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px var(--green-glow);
}

.btn-download-file:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--green-glow);
}

.btn-new {
    flex: 1;
    min-width: 160px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-new:hover {
    background: var(--surface-3);
    border-color: var(--text-muted);
}

.download-card.completed .progress-bar { background: var(--green); }

.download-card.completed .dl-percent {
    background: linear-gradient(135deg, var(--green) 0%, #66ffaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.download-card.completed .progress-bar::after { display: none; }

.footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
}

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

@media (max-width: 520px) {
    .container { padding: 1.25rem 1rem; }
    .logo h1 { font-size: 1.25rem; }
    .input-wrapper { flex-direction: column; padding: 10px; gap: 10px; }
    .input-icon { display: none; }
    #fetchBtn { width: 100%; justify-content: center; }
    .format-grid { grid-template-columns: repeat(3, 1fr); }
    .dl-actions { flex-direction: column; }
    .btn-download-file, .btn-new { min-width: unset; }
}
