/* ===== 基础变量 ===== */
:root {
    --c-bg: #f5f7fa;
    --c-surface: #ffffff;
    --c-text: #1a1a1a;
    --c-text-2: #555;
    --c-text-3: #888;
    --c-border: #e8e8ec;
    --c-primary: #4f6cff;
    --c-primary-hover: #3d56d8;
    --c-primary-soft: #eef1ff;
    --c-success: #21c07a;
    --c-danger: #ff4d4f;
    --c-warn: #ff8a3d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
    --radius: 14px;
    --radius-sm: 8px;
    --max-width: 920px;
}

/* ===== 重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* 显式声明 display 的元素会让 HTML hidden 属性失效，统一恢复 */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== 顶部导航 ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--c-border);
}
.topbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 18px; }
.brand-logo {
    display: inline-flex;
    width: 28px; height: 28px;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--c-primary), #7a5cff);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
}
.topnav { display: flex; gap: 18px; font-size: 14px; color: var(--c-text-2); }
.topnav a { transition: color .2s; }
.topnav a:hover { color: var(--c-primary); }

/* ===== 容器 ===== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* ===== Hero ===== */
.hero { text-align: center; padding: 32px 0 24px; }
.hero h1 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: .5px;
    background: linear-gradient(135deg, #4f6cff, #7a5cff 60%, #ff6ec4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero .subtitle { margin-top: 8px; color: var(--c-text-2); font-size: 15px; }

/* ===== 卡片 ===== */
.card {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--c-border);
}

/* ===== 解析区 ===== */
.input-label { display: block; font-size: 14px; color: var(--c-text-2); margin-bottom: 8px; }
.share-input {
    width: 100%;
    resize: vertical;
    min-height: 96px;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    transition: border-color .2s, background .2s;
}
.share-input:focus {
    outline: none;
    border-color: var(--c-primary);
    background: #fff;
}
.parser-actions { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.parse-tip { margin-top: 12px; font-size: 13px; color: var(--c-danger); }
.parse-tip.success { color: var(--c-success); }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .2s, color .2s, transform .1s, opacity .2s;
    user-select: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.is-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin .7s linear infinite;
}
.btn-ghost.is-loading::after {
    border-color: rgba(109, 92, 255, .25);
    border-top-color: var(--c-primary);
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-ghost { background: var(--c-primary-soft); color: var(--c-primary); }
.btn-ghost:hover:not(:disabled) { background: #e0e6ff; }

/* ===== 输出区 ===== */
.result-area { display: block; }
.result-header {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
/* 平台标签：放大、加图标底色（平台名前不加图标） */
.platform-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--c-primary), #7a5cff);
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(109, 92, 255, .25);
}
/* 关联分隔符：› */
.header-sep {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-text-3);
    line-height: 1;
    user-select: none;
}
/* 类型标签：放大、用 svg 图标替代 emoji */
.result-type-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 6px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
    background: #f0f1f5;
    border-radius: 20px;
}
.result-type-tag::before {
    content: "";
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
/* 视频：video.svg */
.result-type-tag[data-type="video"]::before {
    background-image: url("svg/video.svg");
}
/* 图集：images.svg */
.result-type-tag[data-type="image"]::before {
    background-image: url("svg/images.svg");
}
/* 解析失败：无图标，仅留 padding */
.result-type-tag[data-type="error"]::before {
    display: none;
}
.result-type-tag[data-type="error"] {
    padding-left: 14px;
}

/* 图片总数标签（放在图集 action-bar 右侧） */
.img-count-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #d6336c;
    background: #fff0f6;
    border: 1px solid #ffd0e0;
    border-radius: 16px;
    flex-shrink: 0;
    margin-left: auto;
}
.img-count-num { font-size: 14px; font-weight: 800; }

/* 视频信息区 */
.video-info, .image-info { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.video-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.author { display: flex; align-items: center; gap: 12px; }
.author-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #eee;
    border: 1px solid var(--c-border);
}
.author-meta { font-size: 13px; }
.author-nickname { font-weight: 600; font-size: 15px; color: var(--c-text); }
.author-signature { color: var(--c-text-3); margin-top: 2px; }
.author-uid { color: var(--c-text-3); font-size: 12px; margin-top: 2px; }

.video-title {
    margin-top: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}

/* 描述信息（标题下方，小红书等平台返回 desc） */
.video-description {
    color: var(--c-text-2);
    font-size: 14px;
    line-height: 1.5;
    margin-top: 8px;
    padding-left: 2px;
    word-break: break-word;
    white-space: pre-wrap;
}
.video-top:not([hidden]) { margin-bottom: 16px; }

.stats {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.stat-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}
.stat-icon { font-size: 13px; }
.stat-label { opacity: .85; }
.stats-num { font-weight: 800; }
.stat-play { background: #f3f0ff; color: #6d5cff; border-color: #ddd3ff; }
.stat-digg { background: #fff7ed; color: #ea580c; border-color: #ffd9b3; }
.stat-comment { background: #eef6ff; color: #1d6fd6; border-color: #d0e3ff; }
.stat-collect { background: #fff8e1; color: #d97706; border-color: #ffe9a8; }
.stat-share { background: #f0f7ee; color: #4caf50; border-color: #d6eccf; }

/* 视频元信息（大小 / 时长） */
.video-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--c-text-3);
}
.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #f3f4f6;
    border-radius: 12px;
}
.meta-value { font-weight: 600; color: var(--c-text-2); }

/* 话题标签 */
.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.video-tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--c-primary);
    background: var(--c-primary-soft);
    border-radius: 12px;
    cursor: default;
}

.player-wrap {
    margin-top: 16px;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    /* xgplayer 自带 fluid 模式按 16:9 渲染，aspect-ratio 保持最小高度兜底 */
    aspect-ratio: 16 / 9;
}
.player-wrap > #mse { width: 100%; height: 100%; }

/* 背景音乐条：水平排列，按钮同一行 */
.music-bar {
    margin-top: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #fff7ed, #fffaf0);
    border: 1px solid #ffd9b3;
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}
.music-icon { font-size: 20px; }
.music-label { font-size: 13px; color: var(--c-text-2); margin-right: 4px; }
.music-bar .btn { flex-shrink: 0; }

/* 小号按钮 */
.btn-sm { padding: 7px 14px; font-size: 12px; }

.action-bar {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.action-bar .btn { flex-shrink: 0; }

/* action-bar 右侧的视频元信息（大小 / 时长） */
.meta-inline {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 图集 */
.image-gallery {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.image-gallery figure {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f0f1f5;
    cursor: zoom-in;
    aspect-ratio: 3 / 4;
}
.image-gallery img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .3s;
}
.image-gallery figure:hover img { transform: scale(1.04); }
.image-gallery figcaption {
    position: absolute;
    left: 6px; bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 11px;
    border-radius: 10px;
}
.image-gallery .img-idx { font-weight: 700; color: #fff; }
.image-gallery .img-sep { opacity: .55; margin: 0 1px; }
.image-gallery .img-total { opacity: .75; }

/* 图片类型徽章：右上角，按扩展名配色 */
.img-type-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .3px;
    color: #fff;
    background: rgba(0, 0, 0, .65);
    border-radius: 8px;
    backdrop-filter: blur(2px);
    z-index: 2;
}
.img-type-jpg,
.img-type-jpeg { background: linear-gradient(135deg, #ff7a3d, #ff4e6a); }
.img-type-png  { background: linear-gradient(135deg, #5b8def, #6e5bff); }
.img-type-webp { background: linear-gradient(135deg, #4caf50, #1bb693); }
.img-type-gif  { background: linear-gradient(135deg, #ffb300, #ff7043); }
.img-type-bmp  { background: linear-gradient(135deg, #7e57c2, #5260ff); }
.img-type-svg  { background: linear-gradient(135deg, #26a69a, #00acc1); }
.img-type-jpg  { background: linear-gradient(135deg, #ff7a3d, #ff4e6a); }

/* 错误区 */
.error-area { text-align: center; padding: 30px 20px; }
.error-msg { color: var(--c-danger); font-size: 15px; margin-bottom: 14px; word-break: break-word; }

/* ===== 平台列表 ===== */
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title::before {
    content: '';
    width: 4px; height: 16px;
    background: var(--c-primary);
    border-radius: 2px;
}
.platform-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.platform-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    transition: border-color .2s, background .2s;
}
.platform-item.supported { border-color: var(--c-primary); background: var(--c-primary-soft); }
.platform-item .p-logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}
.p-meta { font-size: 13px; }
.p-name { font-weight: 600; }
.p-status { font-size: 11px; color: var(--c-text-3); }
.platform-item.supported .p-status { color: var(--c-success); }
.platform-note { margin-top: 14px; font-size: 12px; color: var(--c-text-3); text-align: center; }

/* ===== FAQ ===== */
.faq-list { padding-left: 20px; color: var(--c-text-2); font-size: 14px; line-height: 2; }
.faq-list.faq-ul { list-style: disc; }
.faq-list a { color: var(--c-primary); }
.faq-list code {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}

/* ===== 帮助卡片（下拉框 / 手风琴） ===== */
.help-card .section-title { margin-bottom: 18px; }

.help-item {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    overflow: hidden;
    background: #fafbfc;
    transition: border-color .2s, background .2s;
}
.help-item[open] {
    background: var(--c-surface);
    border-color: #d8dcff;
}

.help-summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
    font-size: 15px;
    font-weight: 500;
    color: var(--c-text);
}
.help-summary::-webkit-details-marker { display: none; }
.help-summary:hover { background: rgba(79, 108, 255, .04); }

.help-icon {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.help-title { flex: 1; }

.help-arrow {
    flex-shrink: 0;
    color: var(--c-text-3);
    font-size: 12px;
    transform: rotate(0);
    transition: transform .2s ease;
}
.help-item[open] .help-arrow { transform: rotate(180deg); }

.help-content {
    padding: 6px 20px 18px 56px;
    color: var(--c-text-2);
    font-size: 14px;
    line-height: 1.7;
    border-top: 1px dashed var(--c-border);
}
.help-content p { margin: 8px 0; }

.help-tip {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fff8ee;
    border-left: 3px solid var(--c-warn);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    line-height: 1.7;
    color: #7a4a0c;
}
.help-tip code {
    background: #ffe8cc;
    color: #8a4b00;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
}

/* ===== Footer ===== */
.footer { text-align: center; color: var(--c-text-3); font-size: 12px; padding: 30px 0 10px; }

/* ===== 回到顶部 ===== */
.back-to-top {
    position: fixed;
    right: 24px; bottom: 24px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    font-size: 20px;
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .2s, opacity .2s;
    z-index: 90;
}
.back-to-top:hover { background: var(--c-primary-hover); transform: translateY(-2px); }

/* ===== 图片预览弹窗 ===== */
.preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.preview-img { max-width: 95vw; max-height: 90vh; border-radius: 6px; }
.preview-close {
    position: absolute;
    top: 18px; right: 24px;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

/* ===== 响应式：手机端 ===== */
@media (max-width: 640px) {
    .topbar-inner { padding: 10px 14px; }
    .brand-name { font-size: 16px; }
    .topnav { gap: 12px; font-size: 13px; }
    .container { padding: 16px 14px 80px; }

    .hero h1 { font-size: 24px; }
    .hero .subtitle { font-size: 13px; }

    .card { padding: 16px; }

    .stats { gap: 6px; }
    .stat-tag { padding: 5px 10px; font-size: 12px; }

    .author-avatar { width: 40px; height: 40px; }
    .video-title { font-size: 15px; }

    .image-gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    .btn { padding: 9px 16px; font-size: 13px; flex: 1; min-width: 0; }
    .parser-actions .btn { flex: 1; }
    .action-bar .btn { flex: 1; }

    .platform-list { grid-template-columns: 1fr; }

    .back-to-top { right: 16px; bottom: 16px; width: 40px; height: 40px; font-size: 18px; }

    /* 帮助页移动端：缩小内边距与字号 */
    .help-summary { padding: 12px 14px; font-size: 14px; gap: 10px; }
    .help-icon { width: 26px; height: 26px; font-size: 12px; }
    .help-content { padding: 6px 14px 16px; font-size: 13.5px; }
    .faq-list { padding-left: 18px; line-height: 1.9; }
}

/* 超窄屏 */
@media (max-width: 380px) {
    .image-gallery { grid-template-columns: 1fr; }
}

/* PC 端宽屏优化 */
@media (min-width: 1100px) {
    .container { max-width: 980px; }
}

/* ===== 切换按钮（获取错误？点我获取视频/图集） ===== */
.switch-btn {
    margin-left: auto;
    border: 1px dashed var(--c-border);
    font-size: 13px;
    opacity: .85;
}
.switch-btn:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
    opacity: 1;
}
/* 错误区内的切换按钮：居中显示，不靠右 */
#error-area .switch-btn {
    margin: 14px auto 0;
    display: inline-flex;
}
