/* ========================================
   X 视频下载器 — 样式
   深色主题，极简设计，响应式
   ======================================== */

/* --- CSS 变量 --- */
:root {
    --bg: #0d0d0d;
    --bg-card: #1a1a1a;
    --bg-input: #262626;
    --border: #333333;
    --text-primary: #e7e9ea;
    --text-secondary: #71767b;
    --text-link: #1d9bf0;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --success: #00ba7c;
    --error: #f4212e;
    --error-bg: rgba(244, 33, 46, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.2s ease;
    --max-width: 640px;
}

/* --- 基础重置 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
    line-height: 1.6;
}

/* --- 容器 --- */
.container {
    width: 100%;
    max-width: var(--max-width);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 40px;
}

/* --- Header --- */
.header {
    text-align: center;
}

.title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo {
    font-size: 2rem;
}

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

/* --- Card --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- Input Section --- */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

.url-input {
    flex: 1;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.url-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.15);
}

.url-input:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

.submit-btn {
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), transform var(--transition), opacity var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.submit-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.97);
}

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

.input-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

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

/* --- Error --- */
.error-msg {
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-msg::before {
    content: "⚠️";
    flex-shrink: 0;
}

/* --- Result Section --- */
.result-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.3s ease;
}

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

/* --- Tweet Info --- */
.tweet-info {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.tweet-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tweet-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border);
    object-fit: cover;
}

.tweet-author {
    display: flex;
    flex-direction: column;
}

.tweet-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.tweet-handle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.tweet-text {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

/* --- Video Preview --- */
.video-preview {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- Download Section --- */
.download-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.download-btn {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

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

.download-btn:active {
    transform: scale(0.97);
}

.download-btn .quality {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 400;
}

/* --- Footer --- */
.footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-bottom: 40px;
}

.footer a {
    color: var(--text-link);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-note {
    margin-top: 4px;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* --- 响应式 --- */
@media (max-width: 500px) {
    .container {
        padding-top: 20px;
        gap: 16px;
    }

    .title {
        font-size: 1.4rem;
    }

    .card {
        padding: 20px;
        border-radius: var(--radius-sm);
    }

    .input-wrapper {
        flex-direction: column;
    }

    .submit-btn {
        justify-content: center;
        padding: 14px;
    }

    .download-buttons {
        flex-direction: column;
    }

    .download-btn {
        min-width: unset;
    }
}
