/* ===== 批量生图工作台样式 ===== */

.batch-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 顶部导航 */
.batch-topbar {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.batch-topbar h5 { font-size: 1rem; }
.batch-topbar .badge { font-size: 0.68rem; padding: 4px 8px; }

/* 三栏布局 */
.batch-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 列宽完全由后台百分比控制，CSS 不设固定宽度 */
.batch-left-panel {
    border-right: 1px solid #e9ecef;
    padding: 12px;
    overflow-y: auto;
    background: #fafbfc;
}

.batch-center-panel {
    min-width: 0;
    max-width: 100%;
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid #e9ecef;
}

.batch-right-panel {
    padding: 12px;
    overflow-y: auto;
    background: #fafbfc;
}

/* 区块通用 */
.batch-section {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.batch-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #495057;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.batch-section-title i { color: #0d6efd; font-size: 0.85rem; }

/* 工具切换按钮列表 */
.batch-tool-list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
}
.batch-tool-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}
.batch-tool-item:hover {
    background: #f8f9fa;
    border-color: #0d6efd;
}
.batch-tool-item.active {
    background: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
    font-weight: 500;
}
.batch-tool-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}
.batch-tool-name {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    color: inherit;
}
.batch-tool-item.active .batch-tool-name {
    color: #0d6efd;
    font-weight: 600;
}

.batch-label-sm {
    font-size: 0.72rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
}

.batch-textarea {
    border: 1px solid #ced4da;
    border-radius: 5px;
    width: 100%;
    resize: vertical;
    font-size: 0.75rem;
    padding: 6px 8px;
}

/* /pro 页未引入 panels.css，这里补上 xs 提示字的小字号定义 */
.xs {
    font-size: 0.68rem;
}

.batch-announcement {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 0.68rem;
    color: #664d03;
    margin-bottom: 8px;
}

/* 生成模式按钮 */
.batch-mode-btn {
    flex: 1;
    text-align: center;
    padding: 6px;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s;
}
.batch-mode-btn:hover { border-color: #0d6efd; }
.batch-mode-btn.active { border-color: #0d6efd; background: #e7f1ff; }
.batch-mode-btn div:first-child { font-size: 1rem; }
.batch-mode-btn .xs { font-size: 0.55rem; color: #6c757d; }

/* 模板卡片 */
.batch-template-card {
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 6px;
    background: #fff;
    position: relative;
}
.batch-template-card:hover { border-color: #0d6efd; }
.batch-template-card.selected { border-color: #0d6efd; background: #e7f1ff; }
.batch-template-card .thumb-row { display: flex; gap: 3px; margin-top: 5px; }
.batch-template-card .thumb {
    width: 28px; height: 28px; border-radius: 3px;
    background: #e9ecef; display: flex; align-items: center;
    justify-content: center; font-size: 0.45rem; color: #adb5bd; overflow: hidden;
}
.batch-template-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.batch-template-card .delete-btn {
    position: absolute; top: 5px; right: 5px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; border: 1px solid #dee2e6;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.45rem; color: #adb5bd; cursor: pointer;
    transition: all 0.15s;
}
.batch-template-card .delete-btn:hover { background: #dc3545; color: #fff; border-color: #dc3545; }

/* 模型选择 */
.batch-model-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}
.batch-model-option {
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 3px 2px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.batch-model-option:hover { border-color: #0d6efd; }
.batch-model-option.selected { border-color: #0d6efd; background: #e7f1ff; }
.batch-model-option .model-icon { font-size: 0.85rem; margin-bottom: 0; }
.batch-model-option .model-name { font-size: 0.65rem; font-weight: 600; color: #495057; }
.batch-model-option .model-tag { font-size: 0.55rem; color: #adb5bd; }

/* 图片尺寸行（比例/尺寸/4K 内联） */
.batch-size-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.batch-size-row .form-select {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    padding: 4px 6px;
}
.batch-4k-toggle {
    font-size: 0.68rem;
    color: #495057;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    cursor: pointer;
}

/* 权重滑块 */
.batch-weight-slider {
    height: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
    outline: none;
}
.batch-weight-slider.product::-webkit-slider-runnable-track { background: linear-gradient(90deg, #cfe2ff, #0d6efd); border-radius: 2px; }
.batch-weight-slider.product::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: #0d6efd; border-radius: 50%; box-shadow: 0 0 0 2px rgba(13,110,253,0.2); }
.batch-weight-slider.reference::-webkit-slider-runnable-track { background: linear-gradient(90deg, #d1e7dd, #198754); border-radius: 2px; }
.batch-weight-slider.reference::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: #198754; border-radius: 50%; box-shadow: 0 0 0 2px rgba(25,135,84,0.2); }
.batch-weight-labels { display: flex; justify-content: space-between; font-size: 0.6rem; color: #adb5bd; margin-top: 1px; }
.batch-badge-weight { font-size: 0.65rem; padding: 2px 6px; border-radius: 5px; min-width: 18px; text-align: center; font-weight: 700; }
.batch-badge-product { background: #cfe2ff; color: #084298; }
.batch-badge-reference { background: #d1e7dd; color: #0f5132; }

/* 风格标签 */
.batch-style-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.batch-style-tag {
    padding: 4px 8px; border-radius: 8px; font-size: 0.65rem;
    border: 1px solid #dee2e6; cursor: pointer; background: #fff; transition: all 0.15s;
}
.batch-style-tag:hover { border-color: #0d6efd; }
.batch-style-tag.active { background: #0d6efd; color: #fff; border-color: #0d6efd; }

/* 快捷风格选择弹窗卡片 */
.batch-style-card {
    border: 1px solid #dee2e6; border-radius: 6px; padding: 8px 10px;
    cursor: pointer; background: #fff; transition: all 0.15s;
}
.batch-style-card:hover { border-color: #198754; }
.batch-style-card.active { background: #198754; color: #fff; border-color: #198754; }
.batch-style-card-desc { font-size: 0.8rem; color: #6c757d; margin-top: 3px; max-height: 3.6em; overflow: hidden; }
.batch-style-card.active .batch-style-card-desc { color: rgba(255,255,255,.85); }

/* 上传区域 */
.batch-upload-area {
    border: 2px dashed #ced4da;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
}
.batch-upload-area:hover { border-color: #0d6efd; background: #e7f1ff; }

/* 正方形上传区域（产品图片） */
.batch-upload-square {
    position: relative;
    aspect-ratio: 1;
    border: 2px dashed #ced4da;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.batch-upload-square:hover { border-color: #0d6efd; background: #e7f1ff; }
.batch-upload-placeholder {
    text-align: center;
    padding: 10px;
}
.batch-upload-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* 顶部两列布局：产品图片 + 参考图区域（固定高度，不随内容变化） */
.batch-top-row {
    align-items: stretch !important;
    height: 160px;
    flex-shrink: 0;
    overflow: hidden;
}

/* 产品图/参考图左侧竖排名称 */
.batch-img-label {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 0.55rem;
    font-weight: 600;
    color: #495057;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    padding: 4px 0;
}

/* 左侧：产品图片上传（160x160 正方形） */
.batch-product-col {
    width: 160px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* 左侧上传区域：与整行 160px 严格等高，不再依赖父容器高度与 aspect-ratio */
.batch-product-col .batch-upload-square {
    width: 100%;
    height: 160px;
    flex: 0 0 160px;
    min-height: 0;
    min-width: 0;
    aspect-ratio: auto;
    box-sizing: border-box;
}

/* 右侧：参考图区域（虚线边框，按钮默认居中） */
.batch-ref-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* 与产品图框严格等高，保证两个虚线框高度一致、上下对齐 */
    height: 160px;
    box-sizing: border-box;
    border: 2px dashed #ced4da;
    border-radius: 6px;
    background: #fafbfc;
    overflow: hidden;
}

/* 按钮：默认在框内居中 */
.batch-ref-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* 无参考图时：单个添加按钮（正方形） */
.batch-ref-add-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    box-sizing: border-box;
    font-size: 0.7rem;
    padding: 10px;
    border-radius: 8px;
    border: 2px dashed #ced4da;
    background: #fafbfc;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
}
.batch-ref-add-single:hover {
    border-color: #0d6efd;
    background: #e7f1ff;
    color: #0d6efd;
}
.batch-ref-add-single i {
    font-size: 1.4rem;
    line-height: 1;
}
.batch-ref-add-single span {
    font-size: 0.6rem;
    line-height: 1.2;
}

/* 有参考图时：隐藏按钮，显示参考图网格 */
.batch-top-row.has-images .batch-ref-actions {
    display: none;
}

.batch-top-row.has-images .batch-ref-col {
    align-items: stretch;
    justify-content: flex-start;
    border: none;
    background: none;
}

.batch-top-row.has-images .batch-ref-grid {
    flex: 1;
    /* 与产品图框严格等高，保证两个虚线框高度一致、上下对齐 */
    height: 160px;
    box-sizing: border-box;
    border: 2px dashed #ced4da;
    border-radius: 6px;
    background: #fafbfc;
}

/* 添加参考图片弹窗 - 固定大小 */
#addRefModal .modal-dialog {
    width: 720px;
    max-width: 90vw;
    margin: 1.75rem auto;
}
#addRefModal .modal-content {
    width: 720px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
#addRefModal .modal-body {
    padding: 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#addRefModal .modal-footer {
    flex-shrink: 0;
}
#addRefModal .nav-tabs {
    border-bottom: 1px solid #e9ecef;
    padding: 8px 12px 0;
}
#addRefModal .nav-link {
    font-size: 0.75rem;
    padding: 6px 12px;
    color: #6c757d;
    border: none;
    border-bottom: 2px solid transparent;
}
#addRefModal .nav-link.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
    font-weight: 600;
}
#addRefModal .tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
}
#addRefModal .tab-pane {
    min-height: 100%;
}
#modalGalleryCategories .btn {
    font-size: 0.6rem;
    padding: 3px 8px;
}

/* 图库图片已选标识 */
.gallery-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #198754;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    z-index: 2;
}

/* 模板已选标识 */
.template-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #198754;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    z-index: 2;
}

/* 弹窗内图片比例修复 */
/* 图库图片：直接子元素 img，填满卡片 */
#modalGalleryList .batch-picker-card > img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 !important;
    object-fit: cover !important;
    border-radius: 4px !important;
}

/* 模板缩略图：嵌套在 .d-flex 容器内，固定 28x28 */
#modalSystemTemplateList .batch-picker-card .d-flex img,
#modalUserTemplateList .batch-picker-card .d-flex img {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    flex-shrink: 0 !important;
    object-fit: cover !important;
    border-radius: 3px !important;
}

/* 所有弹窗卡片：防止内容溢出 */
#modalGalleryList .batch-picker-card,
#modalSystemTemplateList .batch-picker-card,
#modalUserTemplateList .batch-picker-card {
    overflow: hidden !important;
}

/* 弹窗内模板卡片样式 */
#modalSystemTemplateList .batch-picker-card,
#modalUserTemplateList .batch-picker-card {
    padding: 6px;
    margin-bottom: 6px;
}
#modalSystemTemplateList .batch-picker-card .small,
#modalUserTemplateList .batch-picker-card .small {
    font-size: 0.65rem;
}
#modalSystemTemplateList .batch-picker-card .xs,
#modalUserTemplateList .batch-picker-card .xs {
    font-size: 0.55rem;
}
#modalSystemTemplateList .batch-picker-card .thumb-row,
#modalUserTemplateList .batch-picker-card .thumb-row {
    margin-top: 4px;
}
#modalSystemTemplateList .batch-picker-card .thumb-row img,
#modalUserTemplateList .batch-picker-card .thumb-row img {
    width: 28px !important;
    height: 28px !important;
    object-fit: cover !important;
    border-radius: 3px !important;
}

/* 参考图末尾的+按钮 */
.batch-ref-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    width: 100px;
    min-width: 100px;
    box-sizing: border-box;
    border: 2px dashed #ced4da;
    border-radius: 6px;
    background: #fafbfc;
    cursor: pointer;
    transition: all 0.2s;
    color: #6c757d;
    flex-shrink: 0;
}
.batch-ref-add-btn:hover {
    border-color: #0d6efd;
    background: #e7f1ff;
    color: #0d6efd;
}
.batch-ref-add-btn i {
    font-size: 1.5rem;
    line-height: 1;
}
.batch-ref-add-btn span {
    font-size: 0.6rem;
    line-height: 1.2;
}

/* 另存为模板按钮：与"添加"按钮尺寸完全一致（同一套 .batch-ref-add-btn 尺寸） */
#saveRefsAsTemplateBtn {
    border-color: #198754;
    color: #198754;
}
#saveRefsAsTemplateBtn:hover {
    border-color: #198754;
    background: #d1e7dd;
    color: #198754;
}
.batch-ref-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 60px;
    height: 60px;
    font-size: 0.55rem;
    padding: 4px;
    white-space: nowrap;
    border-radius: 6px;
}
.batch-ref-btn i {
    font-size: 1rem;
}

/* 右侧：参考图水平一行，左右滑动 */
.batch-ref-grid {
    display: none;
    gap: 6px;
    height: 100%;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    padding: 4px;
}

.batch-top-row.has-images .batch-ref-grid {
    display: flex;
}
.batch-ref-grid .batch-ref-cell {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    min-height: 0;
    min-width: 0;
}
.batch-ref-grid .batch-ref-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain !important;
    display: block;
}

/* 项目选择 */
.batch-project-select {
    border: 1px solid #ced4da;
    border-radius: 5px;
    padding: 5px 7px;
    font-size: 0.65rem;
    width: 100%;
    background: #fff;
}

/* Prompt 预览 */
.batch-prompt-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 8px;
    font-size: 0.55rem;
    color: #495057;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* 统计 */
.batch-stats-row { display: flex; gap: 6px; margin-bottom: 8px; }
.batch-stat-item { flex: 1; background: #f8f9fa; border-radius: 5px; padding: 6px; text-align: center; }
.batch-stat-item .batch-stat-val { font-size: 0.9rem; font-weight: 700; color: #212529; }
.batch-stat-item .batch-stat-label { font-size: 0.6rem; color: #6c757d; }

/* 进度条（隐藏，改用按钮背景） */
.batch-progress-wrap { display: none; }

/* 结果网格：默认一行5个，多图时自动换行 */
.batch-result-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-top: 6px;
}
.batch-result-cell .cell-label {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    font-weight: 600;
    color: #6c757d;
}
.batch-result-cell {
    aspect-ratio: 1;
    border-radius: 5px;
    border: 2px dashed #dee2e6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: #adb5bd;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

/* 按钮背景色作为进度条 */
#startBatchBtn, #cancelBatchBtn {
    position: relative;
    overflow: hidden;
}
#startBatchBtn::before, #cancelBatchBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: rgba(0,0,0,0.15);
    transition: width 0.5s;
    z-index: 0;
}
#startBatchBtn > *, #cancelBatchBtn > * {
    position: relative;
    z-index: 1;
}

/* 结果网格：默认一行5个，多图时自动换行 */
.batch-result-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-top: 6px;
}
.batch-result-cell .cell-label {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.45rem;
    font-weight: 600;
    color: #6c757d;
}
.batch-result-cell {
    aspect-ratio: 1;
    border-radius: 5px;
    border: 2px dashed #dee2e6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.45rem;
    color: #adb5bd;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.batch-result-cell.waiting { border-style: dashed; border-color: #dee2e6; }
.batch-result-cell.generating { border-style: solid; border-color: #0d6efd; background: #e7f1ff; color: #0d6efd; }
.batch-result-cell.done { border-style: solid; border-color: #198754; background: #f8f9fa; }
.batch-result-cell.done img { width: 100%; height: 100%; object-fit: contain; border-radius: 3px; }
.batch-result-cell.failed { border-style: solid; border-color: #dc3545; background: #fff5f5; color: #dc3545; }
.batch-result-cell .cell-num { position: absolute; top: 2px; left: 3px; font-size: 0.4rem; font-weight: 600; }
/* 完成格子右上角：申请退积分悬停按钮 */
.batch-result-cell .batch-refund-btn {
    position: absolute; top: 2px; right: 2px; z-index: 5;
    display: none; align-items: center; gap: 2px;
    padding: 1px 5px; font-size: 0.45rem; line-height: 1.4;
    color: #fff; background: rgba(220, 53, 69, 0.85);
    border: none; border-radius: 3px; cursor: pointer;
}
.batch-result-cell:hover .batch-refund-btn { display: inline-flex; }
.batch-result-cell .batch-refund-btn.applied { display: inline-flex; }
.batch-result-cell .batch-refund-btn:hover { background: #dc3545; }
.batch-result-cell .batch-refund-btn:disabled { opacity: 0.85; cursor: default; background: rgba(25, 135, 84, 0.85); }
.batch-result-cell .spinner-sm {
    width: 14px; height: 14px;
    border: 2px solid #0d6efd; border-top-color: transparent;
    border-radius: 50%; animation: batchSpin 0.8s linear infinite;
}
@keyframes batchSpin { to { transform: rotate(360deg); } }

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
    .batch-left-panel { width: 190px; min-width: 190px; }
    .batch-right-panel { width: 300px; min-width: 300px; }
    .batch-result-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
    .batch-layout { flex-direction: column; overflow-y: auto; }
    .batch-left-panel { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid #e9ecef; }
    .batch-center-panel { border-right: none; border-bottom: 1px solid #e9ecef; }
    .batch-right-panel { width: 100%; min-width: 100%; }
    .batch-result-grid { grid-template-columns: repeat(5, 1fr); }
    .batch-template-list { display: flex; gap: 6px; overflow-x: auto; flex-wrap: nowrap; }
    .batch-template-card { min-width: 150px; flex-shrink: 0; }
}

@media (max-width: 768px) {
    .batch-result-grid { grid-template-columns: repeat(4, 1fr); }
    .batch-model-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== 弹窗宽度 ===== */
.batch-wide-modal {
    max-width: 50vw;
    min-width: 600px;
    width: auto;
}
@media (max-width: 768px) {
    .batch-wide-modal {
        max-width: 95vw;
        min-width: auto;
    }
}

/* ==================== 批量任务历史缩略图 ==================== */

.batch-history-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.batch-history-thumbs img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #e5e5e5;
    transition: transform .15s ease;
}

.batch-history-thumbs img:hover {
    transform: scale(1.08);
    border-color: #ffc107;
}

/* 缩略图 hover 分享按钮 */
.batch-thumb-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
}
.batch-thumb-share {
    position: absolute;
    top: 2px;
    right: 2px;
    border: none;
    border-radius: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.5rem;
    width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}
.batch-thumb-wrap:hover .batch-thumb-share { display: flex; }
.batch-thumb-share:hover { background: #0d6efd; }
.batch-thumb-share.shared { background: #198754; display: flex; }

.batch-history-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 44px;
    padding: 0 5px;
    font-size: 0.6rem;
    color: #6c757d;
    background: #f1f3f5;
    border-radius: 4px;
    cursor: pointer;
}

.batch-history-more:hover {
    background: #e9ecef;
    color: #212529;
}

.batch-history-expand {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}

.batch-history-expand img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #e5e5e5;
    transition: transform .15s ease;
}

.batch-history-expand img:hover {
    transform: scale(1.08);
    border-color: #ffc107;
}

/* ==================== 左栏项目列表 ==================== */

.batch-project-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.batch-project-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.batch-project-item:hover {
    border-color: #0d6efd;
    background: #f8f9ff;
}
.batch-project-item.selected {
    border-color: #0d6efd;
    background: #e7f1ff;
}
.batch-project-item.pinned .batch-project-name {
    font-weight: 700;
}
.batch-project-item .pin-flag {
    font-size: 0.68rem;
    color: #fd7e14;
    flex-shrink: 0;
}
.batch-project-name {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    color: #343a40;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.batch-project-item.selected .batch-project-name {
    color: #0d6efd;
    font-weight: 600;
}
.batch-project-item:hover {
    border-color: #0d6efd;
    background: #f8f9ff;
}
.batch-project-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}
.batch-project-item:hover .batch-project-actions {
    display: flex;
}
.batch-project-actions i {
    font-size: 0.65rem;
    color: #adb5bd;
    padding: 3px;
    border-radius: 3px;
    transition: all 0.15s;
}
.batch-project-actions i:hover {
    color: #0d6efd;
    background: #e7f1ff;
}
.batch-project-actions i.action-delete:hover {
    color: #dc3545;
    background: #fff5f5;
}
.batch-project-actions i.active {
    color: #fd7e14;
}

/* 阶段2开关行 */
.stage2-toggle-row {
    padding: 6px 0;
}
.stage2-toggle-row .form-check-label {
    white-space: nowrap;
    font-size: 0.72rem;
}
.stage2-toggle-row .small {
    font-size: 0.72rem;
    font-weight: 600;
}

/* 项目未选择时的浮动引导 */
.batch-guide-tooltip {
    position: fixed;
    z-index: 10060;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #212529;
    color: #fff;
    font-size: 0.62rem;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    animation: guideFadeIn 0.3s ease;
}
.batch-guide-tooltip .guide-arrow {
    font-size: 0.8rem;
    animation: guideBounce 1s infinite;
}
@keyframes guideFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes guideBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.batch-guide-highlight {
    outline: 2px dashed #0d6efd !important;
    outline-offset: 2px;
    animation: guidePulse 1.5s infinite;
}
@keyframes guidePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13,110,253,0.35); }
    50% { box-shadow: 0 0 0 6px rgba(13,110,253,0); }
}

/* ==================== 中栏参考图网格 ==================== */

.batch-ref-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}
.batch-ref-cell {
    position: relative;
    aspect-ratio: 1;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
}
.batch-ref-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.batch-ref-cell .ref-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.batch-ref-cell:hover .ref-delete { opacity: 1; }
.batch-ref-cell .ref-delete:hover { background: #dc3545; }
.batch-ref-cell .ref-index {
    position: absolute;
    bottom: 2px;
    left: 3px;
    font-size: 0.55rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.batch-ref-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 14px 6px;
    color: #adb5bd;
    font-size: 0.6rem;
    border: 1px dashed #dee2e6;
    border-radius: 6px;
}

/* ==================== 模板选择弹窗卡片 ==================== */

.batch-picker-card {
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    height: 100%;
    overflow: hidden;
}
.batch-picker-card:hover { border-color: #0d6efd; }
.batch-picker-card.selected { border-color: #0d6efd; background: #e7f1ff; }

/* ==================== 历史轮次 ==================== */

.batch-history-round {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 6px;
    overflow: hidden;
    background: #fff;
}
.batch-history-round-head {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.68rem;
}
.batch-history-round-no {
    font-weight: 700;
    color: #0d6efd;
    flex-shrink: 0;
}
.batch-history-round-tpl {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #495057;
}
.batch-history-round-body {
    padding: 5px;
}

/* ==================== 结果格动效 ==================== */

/* 生成中：旋转进度环 + 阶段文字 */
.batch-cell-ring {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: conic-gradient(#0d6efd calc(var(--p, 0) * 1%), #e9ecef 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.batch-cell-ring::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
}
.batch-cell-stage {
    margin-top: 2px;
    font-size: 0.5rem;
    line-height: 1.1;
    text-align: center;
}

/* 完成：弹出动画 */
.batch-result-cell.done img {
    animation: cellPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cellPop {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

/* 失败：抖动动画 */
.batch-result-cell.failed {
    animation: cellShake 0.4s ease;
}
@keyframes cellShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* 生成中格子呼吸流光 */
.batch-result-cell.generating {
    position: relative;
    overflow: hidden;
}
.batch-result-cell.generating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, transparent, rgba(13,110,253,0.12), transparent);
    animation: cellFlow 1.6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes cellFlow {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==================== 生成按钮动画 ==================== */

#startBatchBtn.batch-btn-loading {
    position: relative;
    overflow: hidden;
    pointer-events: none;
    animation: btnPulse 1.2s ease-in-out infinite;
}
#startBatchBtn.batch-btn-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: btnSweep 1.3s ease-in-out infinite;
    pointer-events: none;
}
@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13,110,253,0.45); }
    50% { box-shadow: 0 0 0 7px rgba(13,110,253,0); }
}
@keyframes btnSweep {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

/* ==================== 生成预览吸顶栏（右栏头部） ==================== */

.batch-generate-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    margin-bottom: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

/* ==================== 实时状态行 ==================== */

.batch-live-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: #0d6efd;
    margin-top: 5px;
    min-height: 16px;
}
.batch-live-status .live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0d6efd;
    flex-shrink: 0;
    animation: liveBlink 1s ease-in-out infinite;
}
@keyframes liveBlink {
    0%, 100% { opacity: 0.25; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* ==================== 结果格状态动效（补充） ==================== */

/* 排队中：呼吸动效，让等待的格子看起来是活的 */
.batch-result-cell.waiting {
    animation: cellBreathe 2s ease-in-out infinite;
}
.batch-result-cell.waiting .queue-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #adb5bd;
    margin-bottom: 3px;
    animation: queueDot 1.2s ease-in-out infinite;
}
@keyframes cellBreathe {
    0%, 100% { border-color: #dee2e6; background: #fff; }
    50% { border-color: #c7d6f5; background: #f8faff; }
}
@keyframes queueDot {
    0%, 100% { transform: scale(0.7); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* 生成中：进度环放大一点，阶段文字更清晰 */
.batch-cell-ring {
    width: 24px;
    height: 24px;
}
.batch-cell-ring::after {
    width: 15px;
    height: 15px;
}
.batch-cell-stage {
    font-size: 0.52rem;
    font-weight: 600;
    color: #0d6efd;
}
/* ==================== 产品图悬停操作条（浮动在图片上层，不改变图片尺寸，与 /ai 一致） ==================== */

.product-hover-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40px;
    display: flex;
    z-index: 3;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}

/* 仅已上传（has-image）且悬停时浮现 */
.batch-upload-square.has-image:hover .product-hover-bar {
    opacity: 1;
    visibility: visible;
}

/* 操作条按钮：各约占一半宽度（约 80x40px），点击目标大 */
.product-bar-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.65rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s;
}
.product-bar-btn + .product-bar-btn {
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}
.product-bar-btn i {
    font-size: 0.85rem;
}
.product-bar-btn:hover {
    background: rgba(13, 110, 253, 0.85);
}
.product-bar-btn.product-bar-btn-danger:hover {
    background: rgba(220, 53, 69, 0.9);
}
