/* ============================================================================
 * Toonflow 短剧工厂 · 样式（影视金深色主题）
 * ========================================================================== */
:root {
    --tf-primary: #c8791f;
    --tf-primary-dark: #e0a13a;
    --tf-accent: #c8791f;
    --tf-bg: var(--bg-warm);
    --tf-panel: #ffffff;
    --tf-border: var(--border);
    --tf-text: #1f2333;
    --tf-muted: #6b7280;
    /* 深色面板层级 */
    --tf-bg-alt: var(--bg-warm);
    --tf-bg-deep: #1d2233;
}

#page-toonflow.page { padding: 0; height: 100vh; min-height: 100vh; overflow: hidden; }
.tf-root { height: 100%; }
.tf-wrap {
    display: flex; flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--tf-bg);
    color: var(--tf-text);
}

/* ------------------ header ------------------ */
.tf-header {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 24px; background: var(--bg-white);
    border-bottom: 1px solid var(--tf-border);
    flex-shrink: 0;
}
.tf-header-title { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.tf-header-title > i {
    width: 44px; height: 44px; border-radius: 10px;
    background: linear-gradient(135deg, var(--tf-primary) 0%, var(--tf-accent) 100%);
    color: #ffffff; display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.tf-title { font-size: 18px; font-weight: 700; color: var(--tf-text); }
.tf-sub   { font-size: 12px; color: var(--tf-muted); margin-top: 2px; }

.tf-header-actions { display: flex; align-items: center; gap: 10px; }
.tf-project-name {
    font-size: 13px; color: var(--text-secondary);
    background: var(--bg-warm); padding: 6px 12px; border-radius: 8px;
    border: 1px solid var(--tf-border);
    max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
}
.tf-project-name a { color: var(--tf-primary); text-decoration: none; font-size: 11px; margin-left: 6px; }

/* ------------------ 项目切换器 ------------------ */
.tf-proj-switcher { position: relative; }
.tf-proj-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; height: 36px;
    background: var(--bg-warm); border: 1px solid var(--tf-border); border-radius: 8px;
    font-size: 13px; color: var(--text-secondary); cursor: pointer; font-family: inherit;
    transition: all 0.15s; max-width: 320px;
}
.tf-proj-trigger:hover { border-color: var(--tf-primary); box-shadow: 0 0 0 3px rgba(200,121,31,0.08); }
.tf-proj-trigger .fa-folder-open { color: var(--tf-primary); }
.tf-proj-trigger-name {
    font-weight: 600; color: var(--tf-text);
    max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tf-proj-trigger-count {
    background: var(--tf-primary); color: #ffffff;
    border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.tf-proj-trigger-caret { color: var(--text-secondary); font-size: 11px; }

.tf-proj-menu {
    position: absolute; top: 42px; right: 0;
    width: 380px; max-height: 520px;
    background: var(--bg-white); border: 1px solid var(--tf-border); border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    overflow: hidden; z-index: 100;
    display: flex; flex-direction: column;
}
.tf-proj-menu-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; border-bottom: 1px solid var(--tf-border);
    font-size: 13px; font-weight: 600; color: var(--tf-text);
    background: var(--bg-warm);
}
.tf-proj-menu-list { flex: 1; overflow-y: auto; max-height: 340px; }
.tf-proj-item {
    padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
    transition: all 0.12s;
}
.tf-proj-item:hover { background: var(--bg-warm); }
.tf-proj-item.is-active { background: linear-gradient(90deg, rgba(200,121,31,0.08), transparent); border-left: 3px solid var(--tf-primary); padding-left: 11px; }
.tf-proj-item-name { font-size: 13px; font-weight: 600; color: var(--tf-text); line-height: 1.4; }
.tf-proj-item-sub { font-size: 11px; color: var(--tf-muted); margin-top: 2px; }

.tf-proj-menu-foot, .tf-proj-menu-sync {
    padding: 10px 14px; border-top: 1px solid var(--tf-border);
    display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg-warm);
}
.tf-proj-menu-sync { background: var(--bg-warm); }

/* ------------------ 提示词工程抽屉 ------------------ */
.tf-pe-modal { width: 1100px; max-width: 96vw; height: 84vh; }
.tf-pe-grid { display: grid; grid-template-columns: 280px 1fr; gap: 0; padding: 0 !important; height: calc(84vh - 64px); }
.tf-pe-left {
    background: var(--bg-warm); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.tf-pe-scope {
    display: flex; gap: 6px; padding: 12px;
    border-bottom: 1px solid var(--border);
}
.tf-pe-scope .tf-btn { flex: 1; font-size: 11px; justify-content: center; padding: 6px 4px; }
.tf-pe-list { flex: 1; overflow-y: auto; padding: 8px; }
.tf-pe-item {
    padding: 10px 12px; margin-bottom: 6px; border-radius: 8px;
    background: var(--bg-white); border: 1px solid var(--border); cursor: pointer;
    transition: all 0.15s;
}
.tf-pe-item:hover { border-color: #c8791f; background: var(--bg-warm); }
.tf-pe-item.is-active {
    background: linear-gradient(135deg, rgba(200,121,31,0.15), rgba(200,121,31,0.08));
    border-color: var(--tf-primary, #c8791f);
    box-shadow: 0 0 0 2px rgba(200,121,31,0.3);
}
.tf-pe-item-step {
    font-size: 10px; color: #e0a13a; text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px; font-weight: 600;
}
.tf-pe-item-name { font-size: 13px; color: var(--strong); font-weight: 600; line-height: 1.3; }
.tf-pe-item-desc { font-size: 11px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }

.tf-pe-main {
    background: var(--bg-white); padding: 18px; overflow-y: auto; color: var(--strong);
    display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.tf-pe-title b { color: var(--strong); font-size: 15px; }
.tf-pe-sub { font-size: 12px; margin-top: 2px; }
.tf-pe-vars {
    font-size: 11px; color: var(--text-secondary); margin-top: 8px;
    padding: 8px 10px; background: var(--bg-warm); border-radius: 6px; border: 1px solid var(--border);
}
.tf-pe-var { display: inline-block; margin-right: 8px; margin-bottom: 3px; }
.tf-pe-var code {
    background: var(--border); padding: 1px 6px; border-radius: 3px;
    color: #e0a13a; font-size: 11px; margin-right: 4px;
}

.tf-pe-textarea {
    width: 100%; box-sizing: border-box;
    background: var(--bg-warm); border: 1px solid var(--border); border-radius: 6px;
    color: var(--strong); padding: 10px 12px; font-size: 12px; line-height: 1.6;
    font-family: 'SF Mono', Menlo, monospace; resize: vertical; outline: none;
}
.tf-pe-textarea:focus { border-color: var(--tf-primary, #c8791f); }
.tf-pe-note-input {
    flex: 1; min-width: 160px;
    background: var(--bg-warm); border: 1px solid var(--border); border-radius: 6px;
    color: var(--strong); padding: 8px 10px; font-size: 12px; outline: none;
}
.tf-pe-note-input:focus { border-color: var(--tf-primary, #c8791f); }
.tf-pe-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tf-pe-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.tf-pe-section-title { font-size: 13px; font-weight: 600; color: var(--strong); margin-bottom: 10px; }
.tf-pe-ver-list { display: flex; flex-direction: column; gap: 8px; }
.tf-pe-ver {
    padding: 10px 12px; background: var(--bg-white); border: 1px solid var(--border); border-radius: 6px;
    display: flex; flex-direction: column; gap: 6px;
}
.tf-pe-ver-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px;
}
.tf-pe-ver-head b { color: var(--strong); }
.tf-pe-ver-note { font-size: 11px; color: var(--text-secondary); }
.tf-pe-ver-actions { display: flex; gap: 6px; }
.tf-pe-ver-actions .tf-btn {
    background: var(--border); color: var(--strong); border-color: var(--border);
}
.tf-pe-ver-actions .tf-btn:hover { background: var(--border); color: var(--strong); border-color: var(--tf-primary, #c8791f); }

/* 提示词工程 · 顶部 Tab */
.tf-pe-tabs { display: inline-flex; gap: 4px; margin-left: 16px; }
.tf-pe-tab {
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px; font-family: inherit;
    transition: all 0.15s;
}
.tf-pe-tab:hover { background: var(--bg-white); color: var(--strong); }
.tf-pe-tab.is-active {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #ffffff; border-color: transparent;
}

/* 提示词工程 · 反推面板 */
.tf-pe-reverse {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 0;
    padding: 0 !important;
    height: calc(84vh - 64px);
    overflow: hidden;
}

/* 反推·独立二级菜单页（挂在 #page-prompt-reverse 下） */
.tf-rev-standalone-wrap {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    margin-top: 8px;
}
.tf-rev-standalone-wrap .tf-pe-reverse {
    /* 独立页里把 Modal 用的 84vh 改为更合理的高度，让它紧凑地填满主内容区 */
    height: calc(100vh - 220px);
    min-height: 520px;
}
.tf-pe-rev-left {
    background: var(--bg-warm); border-right: 1px solid var(--border);
    padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.tf-pe-rev-right {
    background: var(--bg-white); padding: 18px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 14px; min-height: 0;
}
.tf-pe-rev-block { display: flex; flex-direction: column; gap: 6px; }
.tf-pe-rev-type { display: flex; gap: 14px; color: var(--strong); font-size: 13px; padding: 6px 0; }
.tf-pe-rev-type label { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.tf-pe-rev-type input[type="radio"] { accent-color: var(--tf-primary, #c8791f); }
.tf-pe-rev-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tf-pe-rev-hist {
    margin-top: 6px; border-top: 1px solid var(--border); padding-top: 10px;
}
.tf-rev-hist-item {
    padding: 7px 10px; font-size: 11px; color: var(--text); cursor: pointer;
    border-radius: 5px; margin-bottom: 4px; background: var(--bg-warm);
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    border: 1px solid var(--border);
}
.tf-rev-hist-item:hover { background: var(--bg-white); border-color: var(--tf-primary, #c8791f); }
.tf-rev-hist-item .tf-muted { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tf-pe-rev-result {
    background: var(--bg-warm); border: 1px solid var(--border); border-radius: 6px;
    padding: 14px; font-family: 'SF Mono', Menlo, monospace; font-size: 12px;
    line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word;
    max-height: 46vh; overflow-y: auto;
}

/* 提示词工程 · 媒体来源 Tab（URL / 本地） */
.tf-rev-source-tabs {
    display: inline-flex; gap: 4px; background: var(--bg-warm); padding: 3px; border-radius: 8px;
    border: 1px solid var(--border); margin-bottom: 6px;
}
.tf-rev-src-tab {
    background: transparent; border: 1px solid transparent; color: var(--text-secondary);
    border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px; font-family: inherit;
    transition: all 0.15s;
}
.tf-rev-src-tab:hover { background: var(--bg-white); color: var(--strong); }
.tf-rev-src-tab.is-active {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #fff;
}

/* 本地文件拖拽区 */
.tf-rev-local-drop {
    border: 2px dashed var(--border); border-radius: 10px; padding: 24px 16px;
    background: var(--bg-warm); color: var(--text-secondary); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    transition: all 0.15s; text-align: center;
}
.tf-rev-local-drop:hover, .tf-rev-local-drop.is-dragover {
    border-color: var(--tf-primary, #c8791f); background: var(--bg-warm); color: var(--strong);
}
.tf-rev-local-drop i { font-size: 26px; color: var(--tf-primary, #c8791f); }
.tf-rev-local-text { font-size: 12px; }

/* 反推模板列表 */
.tf-rev-tpl-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-warm);
    margin-bottom: 4px; transition: all 0.15s;
}
.tf-rev-tpl-item:hover { border-color: var(--tf-primary, #c8791f); background: var(--bg-warm); }
.tf-rev-tpl-main { flex: 1; cursor: pointer; overflow: hidden; }
.tf-rev-tpl-name { font-size: 12px; color: var(--strong); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-rev-tpl-meta { font-size: 10px; margin-top: 2px; }
.tf-rev-tpl-del {
    background: transparent; border: 1px solid transparent; color: var(--text-secondary);
    cursor: pointer; padding: 4px 7px; border-radius: 4px; font-size: 11px;
}
.tf-rev-tpl-del:hover { color: #e07b63; background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.2); }

/* 顶栏反推按钮高亮 */
.tf-btn-reverse {
    background: linear-gradient(135deg, rgba(200,121,31,0.12), rgba(200,121,31,0.12)) !important;
    border-color: rgba(200,121,31,0.45) !important;
    color: #e0a13a !important;
}
.tf-btn-reverse:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f)) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}
.tf-btn-reverse i { color: inherit; }

/* 分镜详情 · 提示词上方 label + 反推按钮一行 */
.tf-detail-label-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 10px; margin-bottom: 4px;
}
.tf-detail-reverse-btn {
    flex-shrink: 0; padding: 3px 10px !important; font-size: 11px !important;
    background: rgba(200,121,31,0.1) !important;
    border-color: rgba(200,121,31,0.3) !important;
    color: #e0a13a !important;
}
.tf-detail-reverse-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f)) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}

/* 分镜反推 Modal · 中号 */
.tf-modal-md { width: 720px; }
.tf-shot-rev-details { color: var(--text-secondary); font-size: 12px; }
.tf-shot-rev-details summary { cursor: pointer; padding: 4px 0; color: #e0a13a; }
.tf-shot-rev-details summary:hover { color: #e0a13a; }

/* ------------------ buttons ------------------ */
.tf-btn {
    border: 1px solid var(--tf-border); background: var(--bg-white);
    color: var(--tf-text); padding: 8px 16px; border-radius: 8px;
    font-size: 13px; cursor: pointer; transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.tf-btn:hover:not(:disabled) {
    border-color: var(--tf-primary); color: var(--tf-primary);
}
.tf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tf-btn.primary {
    background: linear-gradient(135deg, var(--tf-primary) 0%, var(--tf-accent) 100%);
    color: #ffffff; border-color: transparent;
}
.tf-btn.primary:hover:not(:disabled) {
    color: #ffffff; opacity: 0.92; box-shadow: 0 4px 14px rgba(200,121,31, 0.25);
}
.tf-btn.ghost { background: transparent; }
.tf-btn.small { padding: 5px 10px; font-size: 12px; }
.tf-btn.danger { color: #e07b63; border-color: #e07b63; }
.tf-btn.danger:hover:not(:disabled) { background: rgba(224,123,99,.13); color: #e07b63; border-color: #e07b63; }

/* ------------------ model bar ------------------ */
.tf-model-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 24px; background: var(--bg-white);
    border-bottom: 1px solid var(--tf-border);
    flex-shrink: 0;
}
.tf-model-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.tf-model-group label { font-size: 11px; color: var(--tf-muted); font-weight: 600; }
.tf-model-group select, .tf-model-group input {
    height: 32px; padding: 0 10px;
    border: 1px solid var(--tf-border); border-radius: 6px;
    background: var(--bg-white); color: var(--tf-text); font-size: 13px;
    outline: none; transition: all 0.15s;
}
.tf-model-group select:focus, .tf-model-group input:focus {
    border-color: var(--tf-primary);
    box-shadow: 0 0 0 3px rgba(200,121,31,0.08);
}
.tf-model-group input[type="number"] { width: 90px; }

/* ------------------ 风格选择器 ------------------ */
.tf-style-picker { min-width: 200px; }
.tf-style-trigger {
    height: 44px; padding: 4px 10px 4px 4px;
    border: 1px solid var(--tf-border); border-radius: 8px;
    background: var(--bg-white); cursor: pointer;
    display: inline-flex; align-items: center; gap: 10px;
    transition: all 0.15s; outline: none; font-family: inherit;
}
.tf-style-trigger:hover { border-color: var(--tf-primary); box-shadow: 0 0 0 3px rgba(200,121,31,0.08); }
.tf-style-trigger.is-custom {
    border-color: var(--tf-accent, #c8791f);
    background: linear-gradient(135deg, rgba(200,121,31,0.06), rgba(200,121,31,0.04));
}
.tf-style-trigger.is-custom:hover { box-shadow: 0 0 0 3px rgba(200,121,31,0.15); }
.tf-style-trigger-custom {
    width: 28px; height: 28px; border-radius: 6px;
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #ffffff; display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
}
.tf-style-trigger .tf-style-chip-svg { flex-shrink: 0; border-radius: 6px; }
.tf-style-trigger-text {
    display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 0;
}
.tf-style-trigger-name { font-size: 13px; font-weight: 600; color: var(--tf-text); }
.tf-style-trigger-en { font-size: 10px; color: var(--tf-muted); margin-top: 1px; letter-spacing: 0.3px; }
.tf-style-trigger-caret { color: var(--tf-muted); font-size: 11px; margin-left: 4px; }

.tf-style-modal { width: 980px; max-width: 94vw; }
.tf-style-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.tf-style-card {
    position: relative; background: var(--bg-warm); border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; cursor: pointer; transition: all 0.15s;
}
.tf-style-card:hover { border-color: #c8791f; transform: translateY(-2px); }
.tf-style-card.is-selected {
    border-color: var(--tf-primary, #c8791f);
    box-shadow: 0 0 0 2px rgba(200,121,31,0.35), 0 8px 18px rgba(0,0,0,0.4);
}
.tf-style-card-flash { animation: tfStyleFlash 0.45s ease-out; }
@keyframes tfStyleFlash {
    0% { transform: scale(1); }
    40% { transform: scale(1.03); box-shadow: 0 0 0 4px rgba(200,121,31,0.5); }
    100% { transform: scale(1); }
}
.tf-style-card-preview {
    display: block; width: 100%; aspect-ratio: 1 / 1;
    background: var(--bg-warm); overflow: hidden;
}
.tf-style-card-preview .tf-style-chip-svg { width: 100%; height: 100%; display: block; }
.tf-style-card-meta { padding: 10px 12px; }
.tf-style-card-name { font-size: 13px; font-weight: 600; color: var(--strong); line-height: 1.3; }
.tf-style-card-en { font-size: 10px; color: var(--text-secondary); margin-top: 2px; letter-spacing: 0.3px; text-transform: uppercase; }
.tf-style-card-desc { font-size: 11px; color: #e0a13a; margin-top: 6px; line-height: 1.4; }
.tf-style-card-tick {
    position: absolute; top: 8px; right: 8px; color: #e0a13a;
    font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.tf-style-custom {
    margin-top: 16px; padding: 14px; background: var(--bg-warm);
    border: 1px solid var(--border); border-radius: 8px;
}
.tf-style-custom textarea {
    width: 100%; background: var(--bg-white); border: 1px solid var(--border); border-radius: 6px;
    color: var(--strong); padding: 8px 10px; font-size: 12px; line-height: 1.6;
    outline: none; resize: vertical; font-family: 'SF Mono', monospace;
    box-sizing: border-box;
}
.tf-style-custom textarea:focus { border-color: var(--tf-primary, #c8791f); }

/* 自定义风格：特殊卡片（弹窗里第一张） */
.tf-style-card-custom {
    background: var(--bg-warm); border: 1px dashed #c8791f;
}
.tf-style-card-custom:hover { border-color: var(--tf-accent, #c8791f); }
.tf-style-card-custom.is-selected {
    border: 2px solid var(--tf-accent, #c8791f);
    box-shadow: 0 0 0 2px rgba(200,121,31,0.3), 0 8px 18px rgba(0,0,0,0.4);
}
.tf-style-custom-preview {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #ffffff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; font-weight: 600; font-size: 13px; letter-spacing: 1px;
}
.tf-style-custom-preview i { font-size: 42px; opacity: 0.92; }

/* 预设卡片在启用自定义时的"淡化"视觉 */
.tf-style-card.is-disabled {
    opacity: 0.45; filter: grayscale(0.4);
}
.tf-style-card.is-disabled:hover {
    opacity: 0.85; filter: grayscale(0); transform: translateY(-2px);
    border-color: #c8791f;
}
.tf-style-card.is-disabled .tf-style-card-desc {
    color: var(--text-hint);
}

/* 已启用自定义的提示 banner */
.tf-style-custom-banner {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(200,121,31,0.15), rgba(200,121,31,0.1));
    border: 1px solid rgba(200,121,31,0.3);
    border-radius: 8px;
    color: #e0a13a;
}
.tf-style-custom-banner > i { font-size: 18px; color: #e0a13a; }
.tf-style-custom-banner-text { flex: 1; font-size: 12px; line-height: 1.6; color: var(--strong); }
.tf-style-custom-banner-text b { color: var(--strong); margin-right: 4px; }
.tf-style-custom-banner .tf-btn.ghost.danger {
    background: rgba(220,38,38,0.12);
    color: #e07b63; border-color: rgba(220,38,38,0.4);
}
.tf-style-custom-banner .tf-btn.ghost.danger:hover { background: rgba(220,38,38,0.2); color: var(--strong); }

/* 自定义状态标签 */
.tf-style-custom-status {
    margin-left: 10px; font-size: 11px; font-weight: 500; color: var(--text-secondary);
    padding: 2px 8px; border-radius: 10px; background: var(--border);
}
.tf-style-custom-status.is-on {
    color: #e0a13a;
    background: rgba(200,121,31,0.15);
}

/* 自定义区域的操作行 */
.tf-style-custom-actions {
    display: flex; align-items: center; gap: 8px; margin-top: 8px;
    flex-wrap: wrap;
}

/* ------------------ body layout ------------------ */
.tf-body {
    display: grid; grid-template-columns: 180px 1fr;
    flex: 1; min-height: 0; overflow: hidden;
}

/* ------------------ stepper ------------------ */
.tf-stepper {
    background: var(--bg-white); border-right: 1px solid var(--tf-border);
    padding: 28px 18px;
    display: flex; flex-direction: column; gap: 0;
}
.tf-step {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    transition: all 0.15s;
}
.tf-step:hover { background: var(--bg-warm); }
.tf-step.active { background: linear-gradient(135deg, rgba(200,121,31,0.12), rgba(200,121,31,0.08)); }
.tf-step-dot {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--border); color: var(--tf-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
    transition: all 0.15s;
}
.tf-step.active .tf-step-dot {
    background: linear-gradient(135deg, var(--tf-primary), var(--tf-accent));
    color: #fff;
}
.tf-step.done .tf-step-dot { background: #16a34a; color: #ffffff; }
.tf-step-label { font-size: 14px; color: var(--tf-text); font-weight: 500; }
.tf-step.active .tf-step-label { color: var(--tf-primary); font-weight: 600; }
.tf-step-line {
    width: 2px; height: 18px; background: var(--tf-border);
    margin-left: 27px;
}

/* ------------------ main panel ------------------ */
.tf-main {
    overflow-y: auto; padding: 24px;
    background: var(--tf-bg);
    min-height: 0;
}
.tf-panel {
    background: var(--tf-panel);
    border: 1px solid var(--tf-border); border-radius: 12px;
    padding: 24px; margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.tf-panel-title {
    font-size: 16px; font-weight: 700; color: var(--tf-text);
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.tf-panel-title > i { color: var(--tf-primary); }
.tf-panel-desc { color: var(--tf-muted); font-size: 13px; margin-bottom: 18px; line-height: 1.6; }
.tf-panel-footer {
    display: flex; align-items: center; gap: 10px;
    padding-top: 18px; margin-top: 18px;
    border-top: 1px solid var(--tf-border);
}

/* ------------------ Step 0 ------------------ */
.tf-novel-input {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--tf-border); border-radius: 10px;
    padding: 16px 18px; font-size: 14px; line-height: 1.7;
    resize: vertical; outline: none; background: var(--bg-warm);
    font-family: inherit; color: var(--tf-text);
}
.tf-novel-input:focus { border-color: var(--tf-primary); background: var(--bg-white); box-shadow: 0 0 0 3px rgba(200,121,31,0.08); }
.tf-char-count { color: var(--tf-muted); font-size: 12px; margin-right: auto; }

/* ------------------ Step 1 ------------------ */
.tf-screenplay-meta {
    background: var(--bg-warm); border: 1px solid var(--tf-border);
    border-radius: 10px; padding: 16px; margin-bottom: 18px;
    display: flex; flex-direction: column; gap: 10px;
}
.tf-sp-row { display: flex; align-items: center; gap: 10px; }
.tf-sp-row > label { font-size: 12px; color: var(--tf-muted); width: 90px; flex-shrink: 0; font-weight: 600; }
.tf-sp-row input, .tf-sp-row textarea {
    flex: 1; padding: 8px 10px;
    border: 1px solid var(--tf-border); border-radius: 6px;
    font-size: 13px; background: var(--bg-white); color: var(--tf-text);
    outline: none; font-family: inherit; resize: vertical;
}
.tf-sp-row input:focus, .tf-sp-row textarea:focus { border-color: var(--tf-primary); box-shadow: 0 0 0 3px rgba(200,121,31,0.08); }

.tf-acts { display: flex; flex-direction: column; gap: 12px; }
.tf-act-card {
    border: 1px solid var(--tf-border); border-radius: 10px;
    padding: 14px 16px; background: var(--bg-white);
}
.tf-act-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tf-act-no {
    background: linear-gradient(135deg, var(--tf-primary), var(--tf-accent));
    color: #ffffff; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600;
}
.tf-act-title {
    flex: 1; border: none; outline: none;
    font-size: 15px; font-weight: 600; color: var(--tf-text);
    background: transparent; border-bottom: 1px dashed transparent;
    padding: 2px 0;
}
.tf-act-title:hover, .tf-act-title:focus { border-bottom-color: var(--tf-primary); }
.tf-act-summary {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--tf-border); border-radius: 6px;
    padding: 10px; font-size: 13px; line-height: 1.6;
    color: var(--text-secondary); background: var(--bg-warm); resize: vertical;
    outline: none; font-family: inherit;
}
.tf-act-summary:focus { border-color: var(--tf-primary); background: var(--bg-white); }

/* ------------------ Step 2 角色 ------------------ */
.tf-char-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.tf-char-card {
    border: 1px solid var(--tf-border); border-radius: 10px;
    background: var(--bg-white); overflow: hidden;
    display: flex; flex-direction: column;
    transition: all 0.15s;
}
.tf-char-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.06); border-color: var(--tf-primary); }
.tf-char-cover {
    position: relative; aspect-ratio: 3/4;
    background: linear-gradient(135deg, var(--bg-warm), var(--bg-warm));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.tf-char-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tf-char-loading, .tf-char-empty {
    color: var(--tf-muted); text-align: center; font-size: 13px; line-height: 1.8;
}
.tf-char-loading i, .tf-char-empty i { font-size: 32px; color: var(--tf-primary); }
.tf-cloud-badge {
    position: absolute; top: 8px; right: 8px;
    background: rgba(34, 197, 94, 0.9); color: #ffffff;
    padding: 3px 8px; border-radius: 12px; font-size: 11px;
}
.tf-char-meta { padding: 12px; display: flex; flex-direction: column; gap: 7px; }
.tf-char-name {
    font-size: 15px; font-weight: 600; border: none; outline: none;
    border-bottom: 1px dashed transparent; padding: 2px 0;
    color: var(--tf-text); background: transparent;
}
.tf-char-name:hover, .tf-char-name:focus { border-bottom-color: var(--tf-primary); }
.tf-char-role { display: flex; gap: 6px; }
.tf-char-role input, .tf-char-meta textarea {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--tf-border); border-radius: 5px;
    padding: 5px 8px; font-size: 12px; color: var(--tf-text);
    outline: none; background: var(--bg-warm); font-family: inherit; resize: vertical;
}
.tf-char-role input { flex: 1; }
.tf-char-prompt { font-family: 'SF Mono', monospace !important; font-size: 11px !important; color: var(--text-hint); }
.tf-char-meta textarea:focus, .tf-char-role input:focus { border-color: var(--tf-primary); background: var(--bg-white); }
.tf-char-actions { display: flex; gap: 6px; margin-top: 4px; }
.tf-char-actions .tf-btn { flex: 1; }
.tf-char-actions .tf-btn.small.ghost.danger { flex: 0 0 auto; }

/* ------------------ Step 3 分镜 ------------------ */
.tf-shot-toolbar {
    display: flex; gap: 8px; margin-bottom: 14px;
    padding-bottom: 14px; border-bottom: 1px solid var(--tf-border);
    flex-wrap: wrap;
}
.tf-shot-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.tf-shot-card {
    border: 1px solid var(--tf-border); border-radius: 10px;
    background: var(--bg-white); overflow: hidden;
    display: flex; flex-direction: column;
    transition: all 0.15s;
}
.tf-shot-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.06); }
.tf-shot-thumb {
    position: relative; aspect-ratio: 16/9;
    background: var(--bg-warm);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.tf-shot-thumb img, .tf-shot-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tf-shot-loading, .tf-shot-empty {
    color: var(--text-hint); font-size: 26px;
}
.tf-shot-idx {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0,0,0,0.6); color: #fff;
    padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
}
.tf-badge {
    position: absolute; top: 8px; right: 8px;
    padding: 2px 8px; border-radius: 10px; font-size: 10px;
    display: inline-flex; align-items: center; gap: 3px;
}
.tf-badge.image { background: rgba(96,165,250,0.95); color: #ffffff; }
.tf-badge.video { background: rgba(200,121,31,0.95); color: #ffffff; }
.tf-badge.cloud { top: 34px; background: rgba(34,197,94,0.95); color: #ffffff; }
.tf-shot-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tf-shot-title {
    border: none; outline: none; background: transparent;
    font-size: 14px; font-weight: 600; color: var(--tf-text);
    border-bottom: 1px dashed transparent; padding: 2px 0;
}
.tf-shot-title:hover, .tf-shot-title:focus { border-bottom-color: var(--tf-primary); }
.tf-shot-desc, .tf-shot-prompt {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--tf-border); border-radius: 5px;
    padding: 6px 8px; font-size: 11px; line-height: 1.5;
    color: var(--text-secondary); background: var(--bg-warm); resize: vertical;
    outline: none; font-family: inherit;
}
.tf-shot-prompt { font-family: 'SF Mono', monospace; font-size: 10px !important; color: var(--text-hint); }
.tf-shot-desc:focus, .tf-shot-prompt:focus { border-color: var(--tf-primary); background: var(--bg-white); }
.tf-shot-actions { display: flex; gap: 5px; margin-top: 4px; }
.tf-shot-actions .tf-btn { flex: 1; padding: 5px 8px; font-size: 11px; }
.tf-shot-actions .tf-btn.ghost.danger { flex: 0 0 auto; }

/* ------------------ Step 4 成片 ------------------ */
.tf-compose-running {
    background: linear-gradient(135deg, rgba(200,121,31,0.08), rgba(200,121,31,0.04));
    border: 1px solid var(--tf-border); border-radius: 10px;
    padding: 20px; margin-bottom: 16px;
}
.tf-compose-title {
    font-size: 15px; font-weight: 600; color: var(--tf-primary);
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.tf-compose-text { font-size: 13px; color: var(--text-secondary); font-family: 'SF Mono', monospace; }

.tf-final-preview {
    background: var(--bg-warm); border-radius: 12px; overflow: hidden;
    margin-bottom: 16px;
}
.tf-final-preview video { width: 100%; max-height: 560px; display: block; background: var(--bg-warm); }
.tf-final-meta {
    padding: 12px 14px; background: var(--bg-white);
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.tf-final-stat { color: var(--text); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.tf-final-stat i { color: var(--tf-accent); }
.tf-cloud-badge-lg {
    padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 5px;
}
.tf-cloud-badge-lg.uploading { background: rgba(251,146,60,0.22); color: #e8c073; }
.tf-cloud-badge-lg.done      { background: rgba(34,197,94,0.2);  color: #4dbfa8; }
.tf-cloud-badge-lg.fail      { background: rgba(239,68,68,0.18); color: #e07b63; }
.tf-cloud-badge-lg.fail a    { color: var(--strong); text-decoration: underline; margin-left: 6px; }

.tf-compose-expired {
    background: rgba(232,176,75,.12); border: 1px dashed #d97706; border-radius: 10px;
    padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start;
    color: #e8c073; margin-bottom: 16px;
}
.tf-compose-expired > i { font-size: 26px; color: #e8c073; flex-shrink: 0; margin-top: 2px; }

/* ------------------ empty ------------------ */
.tf-empty {
    background: var(--bg-white); border: 1px dashed var(--tf-border); border-radius: 12px;
    padding: 60px 24px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    color: var(--tf-muted);
}
.tf-empty > i { font-size: 44px; color: var(--tf-primary); opacity: 0.6; }

/* ------------------ side log panel ------------------ */
.tf-side {
    background: var(--bg-white); color: var(--text);
    border-left: 1px solid var(--tf-border);
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.tf-side-title {
    padding: 14px 18px; font-size: 13px; font-weight: 600; color: var(--strong);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.tf-side-title i { color: var(--tf-accent); }
.tf-side-body {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 8px 12px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 11px; line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.tf-side-body::-webkit-scrollbar { width: 8px; }
.tf-side-body::-webkit-scrollbar-track { background: transparent; }
.tf-side-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tf-side-body::-webkit-scrollbar-thumb:hover { background: var(--border); }
.tf-log {
    display: flex; gap: 8px; padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}
.tf-log .t { color: var(--text-hint); flex-shrink: 0; }
.tf-log .lv { font-weight: 600; flex-shrink: 0; min-width: 40px; }
.tf-log .msg { flex: 1; color: var(--text); word-break: break-all; }
.tf-log-sys  .lv { color: #e0a13a; }
.tf-log-info .lv { color: #e0a13a; }
.tf-log-ok   .lv { color: #4dbfa8; }
.tf-log-warn .lv { color: #e8c073; }
.tf-log-err  .lv { color: #e07b63; }

/* ------------------ shot thumb enhancements ------------------ */
.tf-shot-thumb { position: relative; }
.tf-shot-thumb.is-clickable { cursor: zoom-in; }
.tf-shot-thumb.is-clickable:hover .tf-thumb-zoom,
.tf-shot-thumb.is-clickable:hover .tf-thumb-play { opacity: 1; }
.tf-thumb-zoom, .tf-thumb-play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 28px; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .2s;
    pointer-events: none;
}
.tf-thumb-play { opacity: 0.7; background: transparent; }
.tf-shot-thumb.is-clickable:hover .tf-thumb-play { background: rgba(0,0,0,0.35); }
.tf-shot-loading { color: var(--text-secondary); font-size: 12px; text-align: center; padding: 20px; }
.tf-shot-loading i { font-size: 22px; margin-bottom: 6px; display: block; }
.tf-shot-empty.tf-shot-fail { color: #e07b63; }
.tf-shot-card.is-fail { border-color: #e07b63; }
.tf-shot-card.is-busy { opacity: 0.85; }
.tf-shot-error {
    background: rgba(224,123,99,.13); border: 1px solid #dc2626; color: #e07b63;
    padding: 6px 10px; border-radius: 6px; font-size: 11px; line-height: 1.5;
    display: flex; gap: 6px; align-items: flex-start;
}
.tf-badge.fail { background: rgba(224,123,99,.13); color: #e07b63; }

/* ------------------ Modal / Lightbox ------------------ */
.tf-modal { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; }
.tf-modal-back { position: absolute; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }
.tf-modal-body {
    position: relative; background: var(--bg-white); border: 1px solid var(--border); border-radius: 12px;
    max-width: 92vw; max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.tf-modal-lg { width: 1200px; }
.tf-modal-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.tf-modal-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--strong); font-weight: 600; font-size: 15px; }
.tf-detail-title {
    flex: 1; background: var(--bg-warm) !important; border: 1px solid var(--border) !important;
    color: var(--strong) !important; padding: 6px 10px !important; border-radius: 6px; font-size: 14px; min-width: 0;
}
.tf-detail-status {
    font-size: 11px; padding: 3px 10px; border-radius: 10px; background: var(--border);
    color: var(--text); white-space: nowrap; display: inline-flex; gap: 5px; align-items: center;
}
.tf-detail-status.image_processing,
.tf-detail-status.video_processing { background: var(--bg-warm); color: #e0a13a; }
.tf-detail-status.fail { background: rgba(224,123,99,.13); color: #e07b63; }
.tf-detail-status.idle { background: rgba(77,191,168,.12); color: #4dbfa8; }
.tf-modal-close {
    width: 34px; height: 34px; border-radius: 6px; background: var(--border); border: 1px solid var(--border);
    color: var(--strong); cursor: pointer; font-size: 14px;
}
.tf-modal-close:hover { background: var(--border); }
.tf-modal-content { flex: 1; overflow: auto; padding: 18px; min-height: 0; }

.tf-shot-detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; min-height: 0; }
.tf-detail-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tf-detail-media {
    background: var(--bg-warm); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.tf-detail-media video, .tf-detail-media > img { max-width: 100%; }
.tf-detail-media > img { cursor: zoom-in; border-radius: 6px; }
.tf-detail-thumb { width: 140px; }
.tf-detail-thumb img { width: 100%; border-radius: 6px; cursor: zoom-in; border: 1px solid var(--border); }
.tf-detail-empty {
    padding: 60px 20px; text-align: center; color: var(--text-hint);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: var(--bg-warm); border: 1px dashed var(--border); border-radius: 8px;
}
.tf-detail-empty i { font-size: 32px; opacity: 0.4; }
.tf-detail-error {
    background: rgba(224,123,99,.13); border: 1px solid #dc2626; color: #e07b63;
    padding: 8px 12px; border-radius: 6px; font-size: 12px;
    display: flex; gap: 8px; align-items: flex-start;
}
.tf-detail-media-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* 详情弹窗内的按钮在深色背景下的清晰样式 */
.tf-modal .tf-detail-media-actions .tf-btn {
    background: var(--border); color: var(--strong); border-color: var(--border);
}
.tf-modal .tf-detail-media-actions .tf-btn:hover:not(:disabled) {
    background: var(--border); color: var(--strong); border-color: var(--tf-primary, #c8791f);
}
.tf-modal .tf-detail-media-actions .tf-btn.ghost {
    background: var(--bg-warm); color: var(--strong); border-color: var(--border);
}
.tf-modal .tf-detail-media-actions .tf-btn.ghost:hover:not(:disabled) {
    background: var(--border); color: var(--strong); border-color: var(--tf-primary, #c8791f);
}
.tf-modal .tf-detail-media-actions .tf-btn.primary {
    /* primary 保持原有渐变色，确保高对比度 */
    color: var(--strong);
}
.tf-detail-right {
    display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-y: auto; max-height: 72vh;
    padding-right: 6px;
}
.tf-detail-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.tf-detail-right textarea,
.tf-detail-right input {
    width: 100%; background: var(--bg-warm); border: 1px solid var(--border); border-radius: 6px;
    color: var(--strong); padding: 8px 10px; font-size: 13px; line-height: 1.6; font-family: inherit;
    resize: vertical;
}
.tf-detail-right textarea:focus,
.tf-detail-right input:focus { outline: none; border-color: var(--tf-primary, #c8791f); }
.tf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tf-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; background: var(--bg-warm); border: 1px solid var(--border); border-radius: 14px;
    font-size: 11px; color: var(--text); cursor: pointer;
}
.tf-chip input { margin: 0; }
.tf-muted { color: var(--text-hint); font-size: 12px; }
.tf-detail-hint {
    margin-top: 10px; padding: 8px 10px; background: var(--bg-warm); border-radius: 6px;
    color: #e0a13a; font-size: 11px; line-height: 1.6;
    display: flex; gap: 6px; align-items: flex-start;
}

/* Lightbox */
.tf-lightbox {
    position: fixed; inset: 0; z-index: 10100; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.9);
}
.tf-lightbox-back { position: absolute; inset: 0; cursor: zoom-out; }
.tf-lightbox > img {
    position: relative; max-width: 94vw; max-height: 94vh; object-fit: contain; cursor: zoom-out;
}
.tf-lightbox-close { position: absolute !important; top: 16px; right: 16px; z-index: 2; }

/* ------------------ responsive ------------------ */
@media (max-width: 1200px) {
    .tf-body { grid-template-columns: 160px 1fr; }
    .tf-shot-detail-grid { grid-template-columns: 1fr; }
    .tf-modal-lg { width: 94vw; }
}

/* ============================================================================
 *  资产 Tabs（角色 / 场景 / 道具） + 素材库
 * ========================================================================== */
.tf-asset-tabs {
    display: inline-flex; gap: 6px; padding: 4px; margin-bottom: 14px;
    background: var(--bg-warm); border: 1px solid var(--border); border-radius: 10px;
}
.tf-asset-tab {
    background: transparent; border: 1px solid transparent;
    color: var(--text-secondary); padding: 7px 14px; font-size: 13px; cursor: pointer;
    border-radius: 7px; display: inline-flex; align-items: center; gap: 6px;
    font-family: inherit; transition: all 0.15s;
}
.tf-asset-tab:hover { color: var(--strong); background: var(--bg-white); }
.tf-asset-tab.is-active {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #ffffff;
}
.tf-asset-tab-badge {
    background: rgba(255,255,255,0.15); color: inherit;
    padding: 1px 7px; border-radius: 8px; font-size: 11px;
}
.tf-asset-tab.is-active .tf-asset-tab-badge { background: rgba(255,255,255,0.25); }

/* 素材库 Modal */
.tf-lib-toolbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-warm);
    position: sticky; top: 0; z-index: 2;
}
.tf-lib-filter-tabs { display: inline-flex; gap: 4px; }
.tf-lib-filter {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-secondary); padding: 6px 12px; border-radius: 6px;
    font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
    font-family: inherit; transition: all 0.15s;
}
.tf-lib-filter span {
    background: var(--border); color: var(--text); padding: 0 6px; border-radius: 8px;
    font-size: 10px;
}
.tf-lib-filter:hover { color: var(--strong); border-color: var(--tf-primary, #c8791f); }
.tf-lib-filter.is-active {
    background: linear-gradient(135deg, var(--tf-primary, #c8791f), var(--tf-accent, #c8791f));
    color: #ffffff; border-color: transparent;
}
.tf-lib-filter.is-active span { background: rgba(255,255,255,0.25); color: #fff; }
.tf-lib-search {
    flex: 1; min-width: 220px;
    background: var(--bg-white); color: var(--strong); border: 1px solid var(--border);
    border-radius: 6px; padding: 7px 12px; font-size: 13px; outline: none;
    font-family: inherit;
}
.tf-lib-search:focus { border-color: var(--tf-primary, #c8791f); }

.tf-lib-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px; padding: 18px; max-height: 70vh; overflow-y: auto;
}
.tf-lib-card {
    background: var(--bg-white); border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; display: flex; flex-direction: column;
    transition: all 0.15s;
}
.tf-lib-card:hover { border-color: var(--tf-primary, #c8791f); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(200,121,31,0.2); }
.tf-lib-cover {
    position: relative; aspect-ratio: 1/1; background: var(--bg-warm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); font-size: 28px;
}
.tf-lib-cover img { width: 100%; height: 100%; object-fit: cover; }
.tf-lib-type-badge {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0,0,0,0.7); color: #fff;
    padding: 3px 8px; border-radius: 4px; font-size: 11px;
    display: inline-flex; align-items: center; gap: 4px;
}
.tf-lib-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tf-lib-name {
    color: var(--strong); font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tf-lib-meta { display: flex; justify-content: space-between; font-size: 10px; }
.tf-lib-actions { display: flex; gap: 4px; margin-top: 4px; }
.tf-lib-actions .tf-btn.xs {
    flex: 1; padding: 4px 6px; font-size: 11px; justify-content: center;
}
.tf-lib-actions .tf-btn.xs:not(.primary):not(.danger) { flex: 0 0 auto; }
.tf-btn.xs {
    padding: 3px 8px; font-size: 11px; border-radius: 4px;
}
.tf-btn.danger { color: #e07b63 !important; }
.tf-btn.danger:hover:not(:disabled) {
    background: rgba(220,38,38,0.1) !important;
    border-color: rgba(220,38,38,0.3) !important;
}

/* ============================================================
 * Step 2 · 素材详情页（三栏：左表单 / 中视图 / 右版本记录）
 * 参考阅文漫剧助手的角色详情编辑设计
 * ============================================================ */

/* 卡片封面悬停浮标（"点击进入详情"提示） */
.tf-char-cover { position: relative; cursor: pointer; transition: box-shadow .15s ease; }
.tf-char-cover:hover { box-shadow: 0 0 0 2px rgba(200,121,31, .6); }
.tf-detail-entry {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0, 0, 0, .55); color: #fff;
    padding: 2px 8px; border-radius: 10px;
    font-size: 11px; display: inline-flex; align-items: center; gap: 4px;
    opacity: 0; transition: opacity .15s ease;
    pointer-events: none;
}
.tf-char-cover:hover .tf-detail-entry { opacity: 1; }

/* 详情页三栏主布局 */
.tf-item-detail {
    display: grid; grid-template-columns: 340px minmax(0, 1fr) 260px;
    gap: 0;
    background: var(--tf-bg, #ffffff);
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 10px;
    overflow: hidden;
    min-height: calc(100vh - 260px);
}

/* 顶部返回 */
.tf-id-back {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--tf-border, var(--border));
    color: var(--tf-text, #1f2333); cursor: pointer;
    font-size: 13px; font-weight: 500;
}
.tf-id-back:hover { background: var(--tf-bg-alt, var(--border)); }
.tf-id-back i { opacity: .75; }

/* 左栏：表单 + 底部生成按钮 */
.tf-id-left {
    display: flex; flex-direction: column;
    border-right: 1px solid var(--tf-border, var(--border));
    background: var(--tf-bg, #ffffff);
}
.tf-id-left-body {
    flex: 1; overflow-y: auto;
    padding: 14px 16px;
}
.tf-id-left-body::-webkit-scrollbar { width: 6px; }
.tf-id-left-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tf-id-section-title {
    font-size: 12px; font-weight: 600;
    color: var(--text-secondary); letter-spacing: .5px; text-transform: uppercase;
    margin: 14px 0 10px; padding-bottom: 6px;
    border-bottom: 1px dashed var(--tf-border, var(--border));
}
.tf-id-section-title:first-child { margin-top: 0; }

.tf-id-field { margin-bottom: 12px; }
.tf-id-field label {
    display: block; font-size: 12px;
    color: var(--text); margin-bottom: 5px; font-weight: 500;
}
.tf-id-field input,
.tf-id-field textarea,
.tf-id-field select {
    width: 100%; padding: 7px 10px;
    background: var(--tf-bg-alt, var(--border));
    border: 1px solid var(--tf-border, var(--border));
    color: var(--tf-text, #1f2333);
    border-radius: 6px; font-size: 12px;
    font-family: inherit; box-sizing: border-box;
}
.tf-id-field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.tf-id-field input:focus,
.tf-id-field textarea:focus,
.tf-id-field select:focus {
    outline: none; border-color: #c8791f;
}
.tf-id-field-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 12px;
}
.tf-id-field-row .tf-id-field { margin-bottom: 0; }
.tf-id-field-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text); margin-bottom: 5px;
}
.tf-id-field-head .tf-id-field-actions { display: flex; gap: 10px; font-size: 11px; color: var(--text-secondary); }
.tf-id-field-head .tf-id-field-actions span { cursor: pointer; }
.tf-id-field-head .tf-id-field-actions span:hover { color: var(--strong); }
.tf-id-field-hint { color: var(--text-secondary); font-weight: 400; font-size: 11px; }

/* 文生图 / 参考生图 Tab */
.tf-id-genmode {
    display: flex; gap: 0; margin-bottom: 12px;
    background: var(--tf-bg-alt, var(--border)); border-radius: 6px; padding: 2px;
}
.tf-id-genmode-tab {
    flex: 1; text-align: center;
    padding: 7px 10px; font-size: 12px;
    color: var(--text-secondary); cursor: pointer; border-radius: 5px;
    transition: background .15s ease;
    user-select: none;
}
.tf-id-genmode-tab:hover:not(.is-disabled):not(.is-active) {
    background: rgba(200,121,31,.08); color: var(--text);
}
.tf-id-genmode-tab.is-active {
    background: linear-gradient(90deg, #c8791f, #e0a13a);
    color: #ffffff; font-weight: 600;
    box-shadow: 0 2px 6px rgba(200,121,31,.3);
}
.tf-id-genmode-tab.is-disabled { opacity: .45; cursor: not-allowed; }
.tf-id-genmode-tab i { margin-right: 4px; }

/* 参考图格子 */
.tf-id-refs {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 6px; margin-top: 6px;
}
.tf-id-ref-card {
    aspect-ratio: 1 / 1; background: var(--tf-bg-alt, var(--border));
    border: 1px dashed var(--tf-border, var(--border));
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); font-size: 16px;
    overflow: hidden; position: relative;
    cursor: pointer;
}
.tf-id-ref-card img { width: 100%; height: 100%; object-fit: cover; }
.tf-id-ref-card:hover { border-color: #c8791f; color: var(--strong); }
.tf-id-ref-card.add { border-style: dashed; }
.tf-id-ref-card .remove {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0,0,0,.65); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; cursor: pointer;
    opacity: 0; transition: opacity .15s ease;
}
.tf-id-ref-card:hover .remove { opacity: 1; }
.tf-id-ref-card .remove:hover { background: #dc2626; }
.tf-id-hint {
    font-size: 11px; color: var(--text-hint); margin-top: 6px; line-height: 1.5;
}
.tf-id-hint code {
    background: rgba(255,255,255,.05); padding: 1px 4px;
    border-radius: 3px; font-size: 10px; color: var(--text);
}
.tf-id-hint-warn {
    font-size: 11px; color: #e8c073;
    background: rgba(255, 176, 32, .08);
    border: 1px solid rgba(255, 176, 32, .25);
    padding: 6px 10px; border-radius: 6px;
    margin-top: 8px; line-height: 1.5;
}
.tf-id-hint-warn i { margin-right: 4px; }

/* 提示词工程入口条 */
.tf-id-pe-bar {
    margin-top: 6px; padding: 10px;
    background: linear-gradient(90deg, rgba(200,121,31,.06), rgba(200,121,31,.02));
    border: 1px solid rgba(200,121,31,.18); border-radius: 6px;
    font-size: 11px; color: var(--text);
    display: flex; flex-direction: column; gap: 8px;
}
.tf-id-pe-bar > span { line-height: 1.55; }
.tf-id-pe-bar strong { color: #c8791f; }

/* 左栏底部动作 */
.tf-id-left-footer {
    padding: 12px 14px; border-top: 1px solid var(--tf-border, var(--border));
    display: flex; gap: 8px;
    background: var(--tf-bg, #ffffff);
}
.tf-id-left-footer .tf-btn { flex: 1; }
.tf-id-left-footer .tf-btn.primary {
    flex: 2;
}

/* 中栏：大图 + 视图集合 */
.tf-id-center {
    display: flex; flex-direction: column;
    background: var(--bg-white); padding: 14px 18px; min-width: 0;
}
.tf-id-center-head {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 10px;
}
.tf-id-center-title {
    font-size: 15px; font-weight: 600;
    color: var(--strong);
}
.tf-id-center-actions { display: flex; gap: 6px; }
.tf-id-tool-btn {
    width: 30px; height: 30px;
    border-radius: 6px;
    background: var(--tf-bg-alt, var(--border));
    border: 1px solid var(--tf-border, var(--border));
    color: var(--text); cursor: pointer;
    font-size: 12px;
}
.tf-id-tool-btn:hover { background: var(--border); color: var(--strong); }

.tf-id-canvas {
    flex: 1; min-height: 320px;
    background: var(--bg-warm); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.tf-id-canvas img, .tf-id-canvas video {
    max-width: 100%; max-height: 100%; display: block;
}
.tf-id-canvas .placeholder {
    color: var(--text-hint); font-size: 13px; text-align: center;
}
.tf-id-canvas .placeholder i {
    font-size: 48px; margin-bottom: 10px; display: block;
}
.tf-id-canvas .loading {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55); color: #fff;
    display: flex; align-items: center; justify-content: center;
    gap: 8px; font-size: 13px;
}

.tf-id-views {
    margin-top: 12px;
    background: var(--tf-bg, #ffffff);
    border: 1px solid var(--tf-border, var(--border));
    border-radius: 8px;
    padding: 10px 12px;
}
.tf-id-views-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text-secondary); margin-bottom: 8px;
}
.tf-id-views-head i { margin-right: 4px; }
.tf-id-views-actions { display: flex; gap: 14px; }
.tf-id-views-actions span {
    cursor: pointer; font-size: 11px;
    display: inline-flex; align-items: center; gap: 4px;
}
.tf-id-views-actions span:hover { color: var(--strong); }

.tf-id-views-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}
.tf-id-view-card {
    background: var(--tf-bg-alt, var(--border));
    border: 2px solid transparent;
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    cursor: pointer; overflow: hidden;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    position: relative;
    transition: border-color .15s ease;
}
.tf-id-view-card:hover { border-color: #e0a13a; }
.tf-id-view-card.is-active { border-color: #c8791f; }
.tf-id-view-card.is-empty { background: var(--bg-white); }
.tf-id-view-card .cover {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
}
.tf-id-view-card .label {
    position: relative; z-index: 1;
    padding: 2px 6px; margin: 0 4px 4px;
    background: rgba(0,0,0,.65); color: #fff;
    border-radius: 3px; font-size: 11px;
}
.tf-id-view-card.is-empty .label {
    background: transparent; color: var(--text);
    margin-bottom: 8px;
}
.tf-id-view-card .ph-icon {
    font-size: 24px; color: var(--border);
    margin-bottom: 4px; margin-top: auto;
}
.tf-id-view-card.add {
    background: transparent;
    border: 1px dashed var(--tf-border, var(--border));
    color: var(--text-secondary);
}
.tf-id-view-card.add:hover { border-color: #c8791f; color: var(--strong); }
.tf-id-view-card .loading {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}

/* 右栏：版本记录 */
.tf-id-right {
    border-left: 1px solid var(--tf-border, var(--border));
    background: var(--bg-white);
    padding: 14px 12px;
    overflow-y: auto;
}
.tf-id-right::-webkit-scrollbar { width: 6px; }
.tf-id-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tf-id-right-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; font-weight: 600; color: var(--strong);
    margin-bottom: 12px;
}
.tf-id-right-head i { margin-right: 5px; opacity: .75; }
.tf-id-right-count {
    background: rgba(200,121,31,.15);
    color: #c8791f;
    padding: 1px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
}
.tf-id-version-list {
    display: flex; flex-direction: column; gap: 10px;
}
.tf-id-version-item {
    background: var(--tf-bg-alt, var(--border));
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 6px; cursor: pointer;
    transition: border-color .15s ease;
}
.tf-id-version-item:hover { border-color: #e0a13a; }
.tf-id-version-item.is-active { border-color: #c8791f; }
.tf-id-version-item img {
    width: 100%; aspect-ratio: 16/9;
    object-fit: cover; border-radius: 5px;
    background: var(--bg-warm);
}
.tf-id-version-item .no-img {
    width: 100%; aspect-ratio: 16/9;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-warm); border-radius: 5px;
    color: var(--border); font-size: 24px;
}
.tf-id-version-item .meta {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
    padding: 5px 2px 0;
    font-size: 10px; color: var(--text-secondary);
}
.tf-id-version-item .meta .tag {
    background: rgba(200,121,31,.15); color: #c8791f;
    padding: 1px 6px; border-radius: 3px;
}
.tf-id-version-item .meta .tag.mode-refs {
    background: rgba(255,176,32,.15); color: #e8c073;
}
.tf-id-version-item .meta .tag.mode-text {
    background: rgba(16,185,129,.15); color: #4dbfa8;
}
.tf-id-version-item .meta .time { margin-left: auto; opacity: .75; }
.tf-id-version-empty {
    color: var(--text-hint); font-size: 12px;
    text-align: center; padding: 40px 10px;
}
.tf-id-version-empty i {
    font-size: 28px; display: block;
    margin-bottom: 10px; opacity: .5;
}
.tf-id-version-empty .sub { font-size: 10px; margin-top: 4px; opacity: .7; }

/* 响应式：窄屏堆叠 */
@media (max-width: 1200px) {
    .tf-item-detail { grid-template-columns: 300px minmax(0,1fr) 220px; }
}
@media (max-width: 960px) {
    .tf-item-detail { grid-template-columns: 1fr; grid-auto-rows: auto; min-height: 0; }
    .tf-id-left, .tf-id-center, .tf-id-right {
        border-right: none; border-left: none;
        border-bottom: 1px solid var(--tf-border, var(--border));
    }
}

/* ============================================================================
 * 浮动运行日志抽屉（替换原 tf-side 固定栏）
 * ========================================================================== */

/* 圆形触发按钮（右下角） */
.tf-log-fab {
    position: fixed;
    right: 24px; bottom: 24px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c8791f, #e0a13a);
    color: #ffffff; border: none;
    box-shadow: 0 6px 20px rgba(200,121,31,.35), 0 2px 6px rgba(0,0,0,.3);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    z-index: 1200;
    transition: transform .2s ease, box-shadow .2s ease;
}
.tf-log-fab:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 28px rgba(200,121,31,.5), 0 2px 8px rgba(0,0,0,.4);
}
.tf-log-fab.has-err {
    background: linear-gradient(135deg, #dc2626, #dc2626);
    box-shadow: 0 6px 20px rgba(220,38,38,.4);
    animation: tfLogFabPulse 2s ease-in-out infinite;
}
@keyframes tfLogFabPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(220,38,38,.4); }
    50%      { box-shadow: 0 6px 28px rgba(220,38,38,.7); }
}

/* 徽标 */
.tf-log-fab-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 20px; height: 20px;
    padding: 0 5px;
    background: #dc2626; color: #ffffff;
    border-radius: 10px;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-warm);
    box-sizing: border-box;
}
.tf-log-fab-badge.dim {
    background: #9aa0ac;
}

/* 抽屉浮层 */
.tf-log-drawer {
    position: fixed;
    right: 24px; bottom: 90px;
    width: 440px; max-width: calc(100vw - 48px);
    height: 520px; max-height: calc(100vh - 140px);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.3);
    display: flex; flex-direction: column;
    overflow: hidden;
    z-index: 1201;
    transform: translateY(12px) scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
}
.tf-log-drawer.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.tf-log-drawer-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(200,121,31,.08), transparent);
    font-size: 13px; font-weight: 600; color: var(--strong);
}
.tf-log-drawer-head em {
    font-style: normal;
    margin-left: 6px;
    font-size: 11px; color: var(--text-secondary);
    background: rgba(255,255,255,.05);
    padding: 1px 6px; border-radius: 8px;
}
.tf-log-drawer-actions { display: flex; gap: 4px; }
.tf-log-drawer-actions button {
    width: 28px; height: 28px;
    background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 6px;
    cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s ease;
}
.tf-log-drawer-actions button:hover {
    background: var(--border); color: var(--strong); border-color: var(--border);
}

.tf-log-drawer-body {
    flex: 1; overflow-y: auto;
    padding: 10px 14px;
    font-family: 'Menlo','Monaco','Consolas',monospace;
    font-size: 11.5px;
}
.tf-log-drawer-body::-webkit-scrollbar { width: 6px; }
.tf-log-drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* 小屏下抽屉全宽底抽屉 */
@media (max-width: 768px) {
    .tf-log-drawer {
        right: 12px; left: 12px; bottom: 88px;
        width: auto; height: 60vh;
    }
    .tf-log-fab { right: 16px; bottom: 16px; }
}
