:root {
    --bg: radial-gradient(circle at 20% 20%, #eef2ff 0, #f7fbff 24%, #f9fafb 65%);
    --card: rgba(255, 255, 255, 0.9);
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #475569;
    --brand: #2563eb;
    --accent: #14b8a6;
    color-scheme: light;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}
.shell { max-width: 1080px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left)); }
header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
h1 { margin: 0; font-size: 24px; letter-spacing: 0.4px; }
.pill { padding: 8px 12px; border-radius: 999px; background: #e0f2fe; color: #0ea5e9; font-weight: 600; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: 0 18px 60px rgba(15, 23, 42, 0.08); }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
input { width: 100%; padding: 13px 14px; font-size: 14px; border-radius: 12px; border: 1px solid #cbd5e1; outline: none; background: #fff; }
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
button { padding: 13px 16px; font-size: 14px; border-radius: 12px; border: none; color: #fff; background: linear-gradient(135deg, #2563eb, #1e3a8a); cursor: pointer; font-weight: 700; letter-spacing: 0.2px; touch-action: manipulation; }
button:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.hint { margin-top: 8px; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; margin-top: 14px; }
.stat { display: flex; align-items: center; gap: 10px; }
.stat-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; }
.video-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.video-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ghost-btn { padding: 8px 10px; font-size: 12px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: #1f2937; cursor: pointer; font-weight: 600; }
.ghost-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.video-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: #fff; }
.video-item { display: grid; grid-template-columns: 24px 120px 1fr; gap: 12px; padding: 8px 10px; border-radius: 10px; border: 1px solid #e2e8f0; align-items: start; }
.video-checkbox { margin-top: 6px; }
.video-thumb { width: 120px; aspect-ratio: 16 / 9; border-radius: 10px; background: #f1f5f9; overflow: hidden; border: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-content { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.video-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.video-footer { margin-top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.tasks { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
details.task { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #fff; position: relative; overflow: visible; }
details.task summary {
    list-style: none;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: 12px 14px;
    margin: -12px -14px 0;
    border-radius: 12px 12px 0 0;
    transition: box-shadow 0.2s ease;
}
details.task summary.is-sticky {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
details.task summary::-webkit-details-marker { display: none; }
.badge { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.badge.pending { background: #f1f5f9; color: #475569; }
.badge.running { background: #e0f2fe; color: #0284c7; }
.badge.succeeded { background: #ecfdf3; color: #16a34a; }
.badge.failed { background: #fef2f2; color: #dc2626; }
.task-no { font-size: 12px; font-weight: 700; color: #334155; padding: 6px 10px; border-radius: 999px; background: #f1f5f9; letter-spacing: 0.2px; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-title { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { color: var(--muted); font-size: 13px; font-weight: 600; }
.task-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-btn { padding: 6px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #cbd5e1; color: #1f2937; background: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; }
.link-btn:hover { background: #f1f5f9; }
.delete-btn { padding: 6px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #dc2626; color: #dc2626; background: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.delete-btn:hover { background: #dc2626; color: #fff; }
.retry-btn { padding: 6px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #2563eb; color: #2563eb; background: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.retry-btn:hover { background: #2563eb; color: #fff; }
.collapse-btn { padding: 6px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #64748b; color: #64748b; background: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.collapse-btn:hover { background: #64748b; color: #fff; }
.task-body { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e2e8f0; }
.task-cover { width: 100%; max-width: 720px; border-radius: 12px; overflow: hidden; border: 1px solid #e2e8f0; background: #f1f5f9; }
.task-cover img { width: 100%; height: auto; display: block; }
.md { line-height: 1.65; }
.md h1, .md h2, .md h3 { margin: 14px 0 6px; font-weight: 700; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 20px; margin: 10px 0; }
.md code { background: #f8fafc; padding: 2px 5px; border-radius: 6px; font-size: 13px; }
.md pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; overflow-x: auto; }
.md blockquote { border-left: 4px solid var(--brand); margin: 12px 0; padding-left: 12px; color: #334155; background: #f8fafc; }
.manuscript-section { margin-top: 16px; border-top: 2px solid #e2e8f0; padding-top: 12px; }
.manuscript-header { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.manuscript-content { max-height: 400px; overflow-y: auto; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.tag { font-size: 12px; color: var(--muted); }
.coverage { font-weight: 700; }
.coverage.coverage-good { color: #16a34a; }
.coverage.coverage-bad { color: #dc2626; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.collapse-all-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 16px;
    border: none;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}
.collapse-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
}
.collapse-all-btn:active {
    transform: translateY(0) scale(0.96);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
.collapse-all-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.pending-hint { color: #b45309; font-size: 13px; margin-top: 6px; font-weight: 600; }
.error { color: #dc2626; font-size: 13px; margin-top: 6px; }
.file-link { color: var(--brand); font-size: 13px; word-break: break-all; }
.source-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
@supports not (gap: 12px) {
    header { gap: 0; }
    header > * { margin-right: 12px; margin-bottom: 12px; }
    .video-toolbar { gap: 0; }
    .video-toolbar > * { margin-right: 10px; margin-bottom: 10px; }
    .video-actions { gap: 0; }
    .video-actions > * { margin-right: 8px; margin-bottom: 8px; }
    .tasks { gap: 0; }
    .tasks > * { margin-bottom: 10px; }
    details.task summary { gap: 0; }
    details.task summary > * { margin-right: 10px; margin-bottom: 8px; }
    .task-actions { gap: 0; }
    .task-actions > * { margin-left: 8px; margin-bottom: 8px; }
    .source-actions { gap: 0; }
    .source-actions > * { margin-right: 8px; margin-bottom: 8px; }
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .video-item { grid-template-columns: 24px 1fr; } .video-thumb { width: 100%; grid-column: 2 / -1; } .video-content { grid-column: 2 / -1; } }
@media (max-width: 520px) {
    .shell { padding: calc(18px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
    h1 { font-size: 20px; }
    .card { padding: 14px 14px; }
    input, button { font-size: 16px; }
    .input-row { grid-template-columns: 1fr; }
    .input-row button { width: 100%; }
    .video-list { max-height: 55vh; }
    .video-footer button { width: 100%; }
    details.task { padding: 10px 12px; position: relative; overflow: visible; }
    details.task summary {
        flex-wrap: wrap;
        gap: 8px;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        padding: 10px 12px;
        margin: -10px -12px 0;
        border-radius: 12px 12px 0 0;
    }
    details.task summary .badge { padding: 4px 8px; font-size: 11px; order: 1; }
    details.task summary .task-no { padding: 4px 8px; font-size: 11px; order: 2; }
    details.task summary .task-main { flex-basis: 100%; order: 3; }
    details.task summary .task-title { -webkit-line-clamp: 3; }
    details.task summary .task-meta { font-size: 12px; }
    details.task summary .task-actions { margin-left: 0; flex-basis: 100%; order: 4; justify-content: flex-end; flex-wrap: wrap; }
    .link-btn, .delete-btn, .retry-btn { padding: 6px 8px; font-size: 12px; }
}
