/* Video模版库（浅色） */
:root {
    color-scheme: light;
    --bg: #f5f3ee;
    --bg-translucent: rgba(245, 243, 238, 0.92);
    --surface: #fffefa;
    --surface-soft: #efede7;
    --surface-strong: #e8e5dd;
    --text: #211f1b;
    --muted: #716d64;
    --line: #d9d5cc;
    --accent: #bd761d;
    --accent-text: #985c15;
    --accent-soft: rgba(189, 118, 29, 0.11);
    --accent-ink: #281805;
    --danger: #a84937;
    --preview-bg: #e8e6e0;
    --control-hover: #f1ece3;
    --control-active: #e7e0d3;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(61, 53, 38, 0.08);
    font-family: "Avenir Next", Avenir, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    transition: background 240ms ease, color 240ms ease;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px; top: -48px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
    transition: top 160ms ease;
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------------ 顶栏（与其他工具箱页面的 page-shell 对齐：back-link 左、标题居中） */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(1460px, calc(100% - 48px));
    margin: 0 auto 28px;
    padding-top: 20px;
}

.topbar-tail { width: 38px; flex: none; }

.back-link {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    color: #9a5c17;
    border: 1px solid #9a5c17;
    border-radius: 999px;
    background: rgba(255, 252, 243, 0.72);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}

.back-link:hover,
.back-link:focus-visible {
    background: rgba(255, 252, 243, 0.92);
    outline: none;
}

/* ------------------------------------------------------------------ 布局 */
.library-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 32px;
    width: min(1460px, calc(100% - 48px));
    margin: 0 auto;
    padding: 0 0 80px;
}

.sidebar { position: sticky; top: 24px; align-self: start; }

.sidebar-heading {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.category-nav { display: flex; flex-direction: column; gap: 4px; }

.category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.category-link:hover { background: var(--control-hover); color: var(--text); }
.category-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-text);
}
.category-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    opacity: 0.8;
}

.sidebar-tip {
    margin-top: 26px;
    padding: 16px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.tip-title { margin: 0 0 8px; font-size: 13px; font-weight: 800; color: var(--text); }
.tip-text { margin: 0; font-size: 12px; line-height: 1.7; color: var(--muted); }

/* ------------------------------------------------------------------ 内容区 */
.content-header { margin-bottom: 22px; }

/* 顶栏标题（topbar 内居中，字号与其他工具箱页面的 page-title 一致） */
.topbar .page-title {
    flex: 1;
    margin: 0;
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    letter-spacing: -0.02em;
    text-align: center;
}

.page-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

.content-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.search-wrap { flex: 1; min-width: 220px; max-width: 420px; }

#card-search {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
#card-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
#card-search::placeholder { color: var(--muted); }

.stats { margin: 0; color: var(--muted); font-size: 13px; }
.stats strong { color: var(--accent-text); font-weight: 800; }

/* ------------------------------------------------------------------ 卡片网格 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 20px;
}

.shot-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 180ms ease, border-color 180ms ease;
}
.shot-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
    padding: 16px;
}

/* 卡片标题行：左侧中文名，右侧英文 slug */
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-title-row h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-summary {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta { margin: 0; display: grid; gap: 6px; }
.card-meta > div { display: flex; gap: 8px; font-size: 12px; line-height: 1.6; }
.card-meta dt { flex: none; color: var(--muted); }
.card-meta dt::after { content: "·"; margin-left: 4px; color: var(--line); }
.card-meta dd { margin: 0; color: var(--text); opacity: 0.85; }

.use-btn {
    flex: none;
    padding: 9px 20px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 140ms ease, filter 140ms ease;
}
.use-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.use-btn:active { transform: translateY(0); }

.empty-state {
    margin: 40px 0;
    padding: 60px 20px;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

/* ------------------------------------------------------------------ 参考卡（157 张镜头参考，视频动效） */
.card-media { position: relative; }

.ref-card .preview {
    position: relative;
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    background: var(--preview-bg);
}

.preview video.lazy-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.preview-missing {
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}
.preview-missing p { margin: 0; }

.video-expand {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(15, 14, 12, 0.62);
    color: #f0ede5;
    cursor: pointer;
    opacity: 0;
    transition: opacity 160ms ease, background 160ms ease;
    backdrop-filter: blur(4px);
}
.video-expand svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.preview:hover .video-expand,
.video-expand:focus-visible { opacity: 1; }
.video-expand:hover { background: rgba(15, 14, 12, 0.82); }

/* 式样切换（多动效卡） */
.style-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px 0;
}
.style-option {
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.style-option:hover { background: var(--control-hover); color: var(--text); }
.style-option.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.card-slug {
    margin: 0;
    flex: none;
    max-width: 55%;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}
.card-actions .use-btn { margin-left: auto; }

.copy-btn {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.copy-btn:hover { background: var(--control-hover); color: var(--text); border-color: var(--accent); }

.source-link {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background 140ms ease, color 140ms ease;
}
.source-link:hover { background: var(--control-hover); color: var(--text); }

/* 全屏播放态 */
.preview:fullscreen { aspect-ratio: auto; display: grid; place-items: center; background: #000; }
.preview:fullscreen video.lazy-media { width: 100%; height: 100%; max-height: 100%; }

/* ------------------------------------------------------------------ 弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(10, 9, 7, 0.66);
    backdrop-filter: blur(8px);
    overflow-y: auto;
}

.modal-card {
    display: flex;
    flex-direction: column;
    width: min(980px, 100%);
    max-height: min(92vh, 860px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
}
.modal-title-wrap { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.modal-title { margin: 0; font-size: 20px; font-weight: 800; }
.modal-en { font-size: 12px; color: var(--muted); }

.modal-close {
    width: 34px; height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.modal-close:hover { background: var(--control-hover); color: var(--text); }

.modal-body {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 0;
    overflow-y: auto;
    flex: 1;
}

/* 配方卡说明 */
.recipe-panel {
    padding: 20px 22px;
    border-right: 1px solid var(--line);
    background: var(--surface-soft);
}
.recipe-heading { margin: 0 0 10px; font-size: 13px; font-weight: 800; letter-spacing: 0.14em; color: var(--accent-text); }
.engine-line {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--accent-soft);
    font-size: 12px;
    color: var(--muted);
}
.engine-line strong { color: var(--accent-text); font-weight: 800; }
.recipe-summary { margin: 0 0 14px; font-size: 13px; line-height: 1.8; color: var(--text); }
.recipe-meta { margin: 0 0 14px; display: grid; gap: 8px; }
.recipe-meta > div { display: flex; gap: 8px; font-size: 12px; line-height: 1.7; }
.recipe-meta dt { flex: none; color: var(--muted); }
.recipe-meta dd { margin: 0; }
.recipe-intention {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    font-size: 12px;
    line-height: 1.8;
    color: var(--text);
    border-radius: 0 8px 8px 0;
}
.recipe-note { font-size: 12px; line-height: 1.8; color: var(--muted); }
.recipe-note strong { color: var(--text); }

/* 配方卡详情弹窗（单列：动效预览 + 说明 + 原文/生成入口） */
.recipe-modal-card { width: min(720px, 100%); }

.recipe-modal-body {
    display: grid;
    gap: 14px;
    padding: 20px 24px 24px;
    overflow-y: auto;
    flex: 1;
}
.recipe-modal-body .recipe-summary,
.recipe-modal-body .recipe-meta { margin: 0; }

.recipe-preview { margin: 0; }
.recipe-preview video {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    background: #000;
    display: block;
}
.recipe-preview .preview-missing { border-radius: var(--radius); }

.recipe-modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.recipe-modal-foot .generate-btn { padding: 11px 24px; }

/* 表单 */
.form-panel { display: flex; flex-direction: column; gap: 18px; padding: 20px 24px; }

.field-list { display: grid; gap: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.field label .req { color: var(--danger); }
.field label .len { float: right; color: var(--muted); font-weight: 400; font-size: 11px; }
.field input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
.field input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.upload-block { display: grid; gap: 10px; }

.upload-hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

.dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 26px 16px;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone .dz-icon { font-size: 24px; }
.dropzone .dz-main { font-weight: 700; color: var(--text); }

.thumb-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
    position: relative;
    width: 92px; height: 60px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--preview-bg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    display: grid;
    place-items: center;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(15, 14, 12, 0.75);
    color: #f0ede5;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.thumb-remove:hover { background: var(--danger); }
.thumb-order {
    position: absolute;
    bottom: 4px; left: 4px;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(15, 14, 12, 0.72);
    color: #f0ede5;
    font-size: 10px;
    font-weight: 700;
}

.generate-btn {
    padding: 13px 20px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}
.generate-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.generate-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 渲染状态与结果 */
.render-state { display: grid; gap: 8px; }
.render-state-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.render-percent { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent-text); }
.progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-strong);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-text));
    transition: width 600ms ease;
}

.render-result { display: grid; gap: 14px; }
.render-result video {
    width: 100%;
    max-height: 420px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #000;
}
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.result-download {
    padding: 10px 22px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}
.result-again {
    padding: 10px 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.result-again:hover { background: var(--control-hover); color: var(--text); }

.render-error {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--danger);
    border-radius: 10px;
    background: rgba(200, 90, 70, 0.12);
    color: var(--danger);
    font-size: 13px;
    line-height: 1.7;
    word-break: break-all;
}

/* toast */
.toast {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
    padding: 10px 22px;
    border-radius: 999px;
    background: rgba(15, 14, 12, 0.88);
    color: #f0ede5;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 1020px) {
    .library-layout { grid-template-columns: 1fr; gap: 22px; }
    .sidebar { position: static; }
    .category-nav { flex-direction: row; flex-wrap: wrap; }
    .category-link { padding: 7px 12px; }
    .category-count { display: none; }
    .sidebar-tip { display: none; }
}

@media (max-width: 720px) {
    .library-layout { width: calc(100% - 28px); }
    .modal-body { grid-template-columns: 1fr; }
    .recipe-panel { border-right: none; border-bottom: 1px solid var(--line); }
    .card-grid { grid-template-columns: 1fr; }
}
