@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(40px, 30px) scale(1.05); }
}

@keyframes blobPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.3; }
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes skeletonLoading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: rgba(26, 26, 46, 0.8);
    --bg-card: rgba(22, 33, 62, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #ff0000;
    --accent-hover: #cc0000;
    --border: rgba(42, 42, 74, 0.6);
    --radius: 12px;
    --transition: 0.3s ease;
}

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -2;
    background: linear-gradient(-45deg, #0f0f0f, #1a0000, #0f0f0f, #001a1a);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

body::after {
    content: '';
    position: fixed;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    z-index: -1;
    width: 200%; height: 200%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    animation: grain 8s steps(10) infinite;
    pointer-events: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

.background-blob {
    position: fixed;
    z-index: -1;
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.15;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 40%;
    height: 40%;
    background: var(--accent);
    animation: blobFloat 20s ease-in-out infinite, blobPulse 6s ease-in-out infinite;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 35%;
    height: 35%;
    background: #ff6b00;
    animation: blobFloat 25s ease-in-out infinite reverse, blobPulse 8s ease-in-out infinite;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 20%;
    height: 20%;
    background: #ff0044;
    animation: blobFloat 18s ease-in-out infinite, blobPulse 7s ease-in-out infinite;
    animation-delay: -10s;
}

.blob-4 {
    top: 60%;
    left: 10%;
    width: 25%;
    height: 25%;
    background: #8b00ff;
    animation: blobFloat 22s ease-in-out infinite reverse, blobPulse 9s ease-in-out infinite;
    animation-delay: -15s;
}

.blob-5 {
    top: 10%;
    right: 10%;
    width: 30%;
    height: 30%;
    background: #0066ff;
    animation: blobFloat 28s ease-in-out infinite, blobPulse 5s ease-in-out infinite;
    animation-delay: -7s;
}

.container {
    width: 100%;
    max-width: 600px;
}

.main {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.header {
    text-align: center;
    margin-bottom: 32px;
}

.batch-list {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.batch-list.show {
    display: block;
}

.batch-list h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.batch-item {
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.batch-item img {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

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

.batch-item-title {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batch-item-duration {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.batch-download-all {
    margin-top: 8px;
    width: 100%;
}

.batch-item--active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.batch-item--done {
    opacity: 0.6;
}

.batch-item--failed {
    opacity: 0.5;
    border-left: 3px solid var(--accent);
}

.audio-options {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.audio-options label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.audio-options input[type="checkbox"] {
    width: auto;
}

.subtitle-options {
    margin-bottom: 8px;
    display: none;
}

.subtitle-options.show {
    display: block;
}

.subtitle-select {
    width: 100%;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo svg {
    color: var(--accent);
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 1rem;
}

.main {
    border-radius: var(--radius);
    padding: 0;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.input-group input::placeholder {
    color: var(--text-secondary);
}

button {
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

.error {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: var(--radius);
    color: #ff6b6b;
    font-size: 0.9rem;
}

.results {
    margin-top: 24px;
}

.video-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.video-info {
    padding: 16px;
}

.url-preview {
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.url-preview .thumbnail-preview {
    border-radius: var(--radius);
}

.thumbnail-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-primary);
    overflow: hidden;
}

.thumbnail-preview .video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

.thumbnail-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 40%, rgba(0, 0, 0, 0.45) 100%);
    pointer-events: none;
}

.thumbnail-play {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.92);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    padding-left: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.thumbnail-duration {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: var(--radius) var(--radius) 0 0;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 12px 0 8px;
    line-height: 1.4;
}

.video-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

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

.format-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.format-select:focus {
    outline: none;
    border-color: var(--accent);
}

.format-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px;
}

.format-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.format-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.format-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.seo-copy {
    margin-top: 32px;
    padding: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.seo-copy h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.seo-copy p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.seo-copy ul {
    list-style: none;
    padding: 0;
}

.seo-copy li {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}

.seo-copy li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent);
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

.faq-container .header {
    text-align: left;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 16px;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.faq-page {
    margin-top: 24px;
}

.faq-page h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.faq-page details {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.faq-page details[open] {
    border-color: var(--accent);
}

.faq-page summary {
    padding: 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.faq-page summary:hover {
    color: var(--accent);
}

.faq-page details p {
    padding: 0 16px 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.5rem;
    }
    
    .main {
        padding: 16px;
    }
}