/* ============================================================
   Short Video Parser — 现代极简
   单色主调 / 深色底 / 玻璃卡片 / 克制装饰
   ============================================================ */
:root {
    --bg: #0c0d10;
    --bg-soft: #131418;

    --surface: rgba(255, 255, 255, 0.04);
    --surface-strong: rgba(255, 255, 255, 0.07);
    --hairline: rgba(255, 255, 255, 0.08);
    --hairline-strong: rgba(255, 255, 255, 0.14);

    --text: #ededee;
    --text-soft: rgba(237, 237, 238, 0.74);
    --muted: rgba(237, 237, 238, 0.48);
    --muted-soft: rgba(237, 237, 238, 0.32);

    --accent: #6366f1;
    --accent-strong: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.14);

    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;

    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.40);

    --radius: 12px;
    --radius-lg: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
}

a { color: inherit; }
::selection { color: var(--bg); background: var(--accent-strong); }

/* —— 应用框架 —— */
.app-shell { min-height: 100vh; }
.top-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 32px;
    border-bottom: 1px solid var(--hairline);
    background: rgba(12, 13, 16, 0.80);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}
.brand-disc {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.top-nav { display: flex; align-items: center; gap: 2px; }
.top-nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: color 0.18s ease, background 0.18s ease;
}
.top-nav a:hover {
    color: var(--text);
    background: var(--surface);
}
.top-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: var(--surface);
}
.top-status::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
}
.top-status.offline::before { background: var(--danger); }
.top-status span { color: var(--muted); font-size: 13px; }
.top-status strong { font-size: 13px; font-weight: 600; }
.top-status.online strong { color: var(--text); }
.top-status.offline strong { color: var(--danger); }

.main-area {
    width: min(1140px, calc(100% - 48px));
    margin: 0 auto;
    padding: 48px 0 64px;
}
.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}
.page-kicker,
.section-title span {
    display: inline-block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.topbar h1 {
    margin: 10px 0 0;
    font-size: clamp(28px, 3.6vw, 42px);
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 600;
    color: var(--text);
}
.quick-stats { display: flex; gap: 10px; }
.quick-stats div {
    min-width: 100px;
    padding: 12px 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: right;
}
.quick-stats strong {
    display: block;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}
.quick-stats span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

/* —— 公告条 —— */
.notice {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    color: var(--text-soft);
    background: var(--surface);
    font-size: 14px;
}
.notice strong {
    flex: 0 0 auto;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 600;
}
.notice span { line-height: 1.55; }
.notice.is-danger { color: #fca5a5; }
.notice.is-danger strong { color: #fca5a5; }

/* —— 卡片基类 —— */
.parser-card,
.result-panel,
.platform-panel,
.resource-group {
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.parser-card { padding: 24px; }

.parse-form { display: grid; gap: 14px; }
.form-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.form-head label {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}
.form-head span {
    flex: 0 0 auto;
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-strong);
    font-size: 12px;
    font-weight: 500;
}
.form-head span.is-detected {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

textarea {
    width: 100%;
    min-height: 144px;
    resize: vertical;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--text);
    background: var(--bg-soft);
    font: inherit;
    font-size: 14px;
    line-height: 1.65;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
textarea::placeholder { color: var(--muted-soft); }
textarea:hover { border-color: var(--hairline-strong); }
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.extracted-line {
    min-height: 22px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.extracted-line.ok { color: var(--accent-strong); }

.actions, .main-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* —— 按钮 —— */
button, .download-btn {
    border: 0;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, opacity 0.18s ease;
}
.primary-btn, .download-btn {
    color: #fff;
    background: var(--accent);
}
.primary-btn:hover, .download-btn:hover {
    background: var(--accent-strong);
}
.primary-btn.is-busy { opacity: 0.6; pointer-events: none; }

.secondary-btn,
.copy-main,
.download-all,
.resource-card button {
    color: var(--text-soft);
    background: var(--surface);
    border: 1px solid var(--hairline);
}
.secondary-btn:hover,
.copy-main:hover,
.download-all:hover,
.resource-card button:hover {
    color: var(--text);
    background: var(--surface-strong);
    border-color: var(--hairline-strong);
}
.hidden { display: none; }

/* —— 结果面板 —— */
.result-panel { margin-top: 20px; padding: 24px; }
.result-panel:not(.hidden) { animation: resultIn 0.28s ease both; }
.loading-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 16px;
}
.loading-card span {
    width: 18px; height: 18px;
    border: 2px solid var(--hairline-strong);
    border-top-color: var(--accent-strong);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
.loading-card strong { display: block; font-weight: 500; }
.loading-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.error-box {
    padding: 16px 18px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius);
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.06);
}
.error-box p { margin: 6px 0 0; color: rgba(252, 165, 165, 0.78); font-size: 13px; }

.result-layout {
    display: grid;
    grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
}

/* —— 媒体预览 —— */
.preview-card {
    overflow: hidden;
    min-height: 300px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--bg-soft);
}
.preview-video,
.preview-image {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 300px;
    max-height: 540px;
    object-fit: contain;
    background: transparent;
}
.preview-image { object-fit: cover; }
.empty-preview {
    display: grid;
    min-height: 300px;
    place-items: center;
    color: var(--muted);
    font-size: 14px;
}

.result-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 4px 0;
}
.platform-pill {
    width: fit-content;
    margin-bottom: 14px;
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    font-size: 12px;
    font-weight: 500;
}
.result-info h2 {
    margin: 0 0 12px;
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.3;
    letter-spacing: -0.015em;
    font-weight: 600;
    color: var(--text);
}
.meta {
    margin: 4px 0;
    color: var(--muted);
    font-size: 13px;
}
.main-actions { margin-top: 18px; }

/* —— 资源列表 —— */
.resources {
    display: grid;
    gap: 12px;
    margin-top: 20px;
    max-height: 600px;
    overflow: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--hairline-strong) transparent;
}
.resources::-webkit-scrollbar { width: 6px; }
.resources::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--hairline-strong);
}
.resources::-webkit-scrollbar-track { background: transparent; }

.resource-group { overflow: hidden; }
.resource-group-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
    background: rgba(12, 13, 16, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.resource-group h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.resource-group-head span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}
.resource-list { display: grid; }
.resource-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
    transition: background 0.15s ease;
}
.resource-card:last-child { border-bottom: 0; }
.resource-card:hover { background: var(--surface); }

.resource-meta { min-width: 0; }
.resource-meta strong, .resource-meta span { display: block; }
.resource-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
}
.resource-meta span {
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.resource-url {
    grid-column: 1 / 2;
    overflow: hidden;
    color: var(--muted-soft);
    font-size: 12px;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.resource-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.mini-download,
.resource-card button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 6px 12px;
    border: 0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}
.mini-download {
    color: #fff;
    background: var(--accent);
}
.mini-download:hover { background: var(--accent-strong); }

.raw-json {
    overflow: auto;
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--hairline);
    color: var(--text-soft);
    background: var(--bg-soft);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.65;
}

/* —— 平台面板 —— */
.platform-panel { margin-top: 22px; padding: 24px; }
.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.section-title h2 {
    margin: 6px 0 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
}
.section-title p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.platform-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.platform-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    min-height: 88px;
    padding: 14px 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color 0.18s ease, background 0.18s ease;
}
.platform-item:hover {
    border-color: var(--hairline-strong);
    background: var(--surface-strong);
}
.platform-item strong, .platform-item span { display: block; }
.platform-item strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}
.platform-item span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}
.platform-item em {
    flex: 0 0 auto;
    font-style: normal;
    font-size: 11px;
    font-weight: 500;
    height: fit-content;
    padding: 3px 8px;
    border-radius: 999px;
}
.platform-item.on em {
    color: var(--success);
    background: rgba(34, 197, 94, 0.10);
}
.platform-item.off em {
    color: var(--warning);
    background: rgba(234, 179, 8, 0.10);
}

/* —— 动效 —— */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes resultIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* —— 响应式 —— */
@media (max-width: 1040px) {
    .top-status { display: none; }
}
@media (max-width: 880px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .quick-stats { width: 100%; }
    .quick-stats div { flex: 1; text-align: left; }
    .result-layout { grid-template-columns: 1fr; }
    .platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .top-header { padding: 14px 18px; flex-direction: column; align-items: flex-start; gap: 14px; }
    .top-nav { width: 100%; overflow-x: auto; }
    .main-area { width: 100%; padding: 28px 18px 40px; }
    .topbar h1 { font-size: 26px; }
    .form-head { flex-direction: column; align-items: flex-start; }
    .actions, .main-actions { flex-direction: column; align-items: stretch; }
    .actions button, .main-actions a, .main-actions button { width: 100%; text-align: center; }
    .resource-card { grid-template-columns: 1fr; }
    .resource-actions { width: 100%; }
    .mini-download, .resource-card button { flex: 1; }
    .platform-grid { grid-template-columns: 1fr; }
    .resources { max-height: 480px; }
    .preview-video, .preview-image, .preview-card { min-height: 240px; }
    .parser-card, .result-panel, .platform-panel { padding: 18px; }
}
