/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.15);
    --bilibili: #fb7299;
    --douyin: #000000;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== 容器 ===== */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ===== 头部 ===== */
.header {
    text-align: center;
    margin-bottom: 28px;
    padding-top: 12px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== 输入区域 ===== */
.input-section {
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 14px;
}

.url-input {
    width: 100%;
    padding: 16px 48px 16px 18px;
    font-size: 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

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

.url-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-btn.show {
    display: flex;
}

.clear-btn:hover {
    color: var(--text-primary);
    background: var(--border);
}

.clear-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== 平台选择 ===== */
.platform-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.platform-option {
    flex: 1;
    cursor: pointer;
}

.platform-option input {
    display: none;
}

.platform-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    font-size: 0.8125rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.platform-option.active .platform-label {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--accent-light);
}

.platform-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
}

.bili-icon {
    background: var(--bilibili);
}

.dy-icon {
    background: #000;
    border: 1px solid var(--border);
}

/* ===== 解析按钮 ===== */
.parse-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.parse-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.parse-btn:active:not(:disabled) {
    transform: translateY(0);
}

.parse-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

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

.parse-btn.loading .btn-loader {
    display: block;
}

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

/* ===== 结果区域 ===== */
.result-section {
    margin-bottom: 24px;
    animation: fadeInUp 0.3s ease;
}

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

.hidden {
    display: none !important;
}

/* ===== 视频卡片 ===== */
.video-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.video-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

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

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 4px;
}

.platform-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    border-radius: 6px;
    text-transform: uppercase;
}

.platform-badge.bilibili {
    background: var(--bilibili);
}

.platform-badge.douyin {
    background: #000;
    border: 1px solid rgba(255,255,255,0.2);
}

.video-meta {
    padding: 16px;
}

.video-title {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
}

.video-author span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.video-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.video-stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ===== 下载区域 ===== */
.download-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.section-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.download-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.download-item:hover {
    border-color: var(--accent);
}

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

.download-quality {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.download-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.download-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

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

.download-btn svg {
    width: 14px;
    height: 14px;
}

/* ===== 合并提示 ===== */
.merge-tip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding: 12px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.merge-tip svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--warning);
    margin-top: 1px;
}

.merge-tip code {
    background: var(--bg-input);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--accent);
    word-break: break-all;
}

/* ===== 图集网格 ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* ===== 错误区域 ===== */
.error-section {
    text-align: center;
    padding: 32px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 24px;
    animation: fadeInUp 0.3s ease;
}

.error-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--error);
}

.error-icon svg {
    width: 28px;
    height: 28px;
}

.error-section h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

.error-section p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-line;
}

/* ===== 使用说明 ===== */
.guide-section {
    margin-bottom: 24px;
}

.guide-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.guide-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.guide-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
}

.guide-text strong {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

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

.disclaimer {
    padding: 12px 14px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.disclaimer strong {
    color: var(--warning);
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 20px 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: toastIn 0.3s ease;
    max-width: 90%;
    text-align: center;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== 复制按钮 ===== */
.copy-btn {
    margin-left: auto;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* ===== 文本信息 ===== */
.text-info-content {
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.text-info-row {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.text-info-row:last-child {
    border-bottom: none;
}

.text-info-label {
    flex-shrink: 0;
    width: 80px;
    color: var(--text-muted);
    font-weight: 500;
}

.text-info-value {
    flex: 1;
    color: var(--text-primary);
    word-break: break-all;
}

.text-info-desc {
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* ===== 响应式 ===== */
@media (max-width: 380px) {
    .platform-label {
        font-size: 0.75rem;
        padding: 8px 4px;
    }
    .platform-icon {
        display: none;
    }
}

@media (min-width: 640px) {
    .container {
        padding: 32px 24px 48px;
    }
    .guide-grid {
        flex-direction: row;
    }
    .guide-item {
        flex: 1;
    }
}
