:root {
    --primary-color: #1d9bf0;
    --primary-hover: #1a8cd8;
    --bg-dark: #000000;
    --card-bg: rgba(21, 24, 28, 0.8);
    --text-main: #e7e9ea;
    --text-dim: #71767b;
    --input-bg: #202327;
    --error-color: #f4212e;
    --success-color: #00ba7c;
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 32px 20px;
    overflow-x: hidden;
}

/* Background blobs for a modern look */
.background-blob {
    position: fixed;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.15;
    border-radius: 50%;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 40%;
    height: 40%;
    background: var(--primary-color);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 35%;
    height: 35%;
    background: #7856ff;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 20%;
    height: 20%;
    background: #ff7a00;
}

.container {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

header {
    margin-bottom: 24px;
}

.logo-container {
    font-size: 44px;
    color: white;
    margin-bottom: 12px;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1.5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.download-tool {
    margin-bottom: 22px;
}

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

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

.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-dim);
    font-size: 18px;
}

input[type="text"],
input[type="url"] {
    width: 100%;
    padding: 18px 18px 18px 48px;
    border: 2px solid transparent;
    border-radius: 12px;
    background-color: var(--input-bg);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
    outline: none;
}

input[type="text"]:focus,
input[type="url"]:focus {
    border-color: var(--primary-color);
    background-color: #000000;
    box-shadow: 0 0 0 4px rgba(29, 155, 240, 0.15);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #1a4d6e;
    color: #71767b;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none;
}

#loader {
    margin: 30px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

#result {
    margin-top: 32px;
    animation: fadeIn 0.5s ease-out;
}

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

.video-preview {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #000;
    border: 1px solid var(--glass-border);
}

#preview-image {
    width: 100%;
    max-height: 350px;
    display: block;
    object-fit: cover;
}

.quality-wrap {
    text-align: left;
    margin-bottom: 16px;
}

.quality-wrap label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-dim);
}

#quality-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
}

#quality-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.15);
}

.actions {
    display: flex;
    gap: 12px;
}

.btn-download {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #ffffff;
    color: #000000;
    padding: 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-secondary {
    flex: 1;
    background-color: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* History Section */
#history-section {
    margin-top: 48px;
    text-align: left;
    border-top: 1px solid var(--glass-border);
    padding-top: 32px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
}

#clear-history {
    background: transparent;
    padding: 8px;
    font-size: 14px;
    color: var(--text-dim);
    border-radius: 8px;
}

#clear-history:hover {
    color: var(--error-color);
    background: rgba(244, 33, 46, 0.1);
    transform: none;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.history-thumb {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: #000;
}

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

.history-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.history-date {
    font-size: 12px;
    color: var(--text-dim);
}

.history-actions {
    display: flex;
    gap: 8px;
}

.btn-history-action {
    background: var(--input-bg);
    padding: 8px;
    border-radius: 8px;
    font-size: 14px;
    width: 36px;
    height: 36px;
}

.error-msg {
    color: var(--error-color);
    background-color: rgba(244, 33, 46, 0.1);
    padding: 16px;
    border-radius: 12px;
    margin-top: 24px;
    font-size: 14px;
    border: 1px solid rgba(244, 33, 46, 0.2);
}

footer {
    margin-top: 40px;
    border-top: 1px solid var(--glass-border);
    padding-top: 24px;
    font-size: 13px;
    color: var(--text-dim);
}

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

.app-version {
    color: var(--text-dim);
    white-space: nowrap;
}

.footer-links a,
.back-link {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover,
.back-link:hover {
    color: var(--primary-color);
}

.faq-container {
    max-width: 640px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 700;
}

/* SEO Copy Section */
.seo-copy {
    margin-bottom: 24px;
    text-align: center;
}

.seo-copy h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
}

.seo-copy p {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.seo-copy ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 14px;
}

.seo-copy li {
    color: var(--text-main);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.seo-copy li:before {
    content: "✓";
    color: var(--success-color);
    font-weight: bold;
    font-size: 18px;
}

.faq-section {
    margin-bottom: 24px;
    text-align: left;
}

.faq-section h2 {
    color: var(--text-main);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.faq-section details {
    border-top: 1px solid var(--glass-border);
    padding: 10px 0;
}

.faq-section details:last-child {
    border-bottom: 1px solid var(--glass-border);
}

.faq-section summary {
    color: var(--text-main);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

.faq-section p {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 8px;
}

.faq-page {
    margin-bottom: 0;
}

.faq-page h2 {
    text-align: left;
}
