* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #eee;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 30px 32px;
    background: white;
    min-height: 100vh;
}

h1 {
    font-size: 22px;
    color: #222;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 2px solid #4a90d9;
}

h2 { font-size: 15px; color: #333; margin: 0; }

/* ---- 分区 ---- */
.config-section, .batch-section, .form-section {
    margin-bottom: 22px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.section-desc {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
}

.hint {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

/* ---- 配置行 ---- */
.config-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.config-row:last-child { margin-bottom: 0; }

.config-field { flex: 1; }

.config-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.config-field select,
.config-field input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    background: #fafafa;
}

.config-field select:focus,
.config-field input:focus {
    outline: none;
    border-color: #4a90d9;
    background: white;
}

.config-model {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 0;
}

.model-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.model-header-row label {
    margin-bottom: 0;
    white-space: nowrap;
}

.video-model-inline {
    display: flex;
    gap: 10px;
}

.vmi-opt {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
}

.vmi-opt input[type="radio"] {
    margin: 0;
    vertical-align: middle;
    flex-shrink: 0;
}

.config-model select { width: 180px; }

.api-key-input { flex: 1; }

.api-key-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.show-key-label {
    font-size: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    color: #666;
}

/* ---- 高级设置 ---- */
.advanced-details {
    margin-top: 8px;
    font-size: 12px;
    color: #999;
}

.advanced-details summary {
    cursor: pointer;
    color: #888;
}

.advanced-body {
    margin-top: 10px;
    padding: 12px;
    background: #f8f8f8;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.adv-row { display: flex; gap: 12px; }

.adv-field { flex: 1; }

.adv-field label {
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
    display: block;
}

.adv-field input {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.hint { font-size: 11px; color: #aaa; margin-top: 4px; }

/* ---- KPI + 镜头 ---- */
.kpi-row { display: flex; gap: 10px; }

.kpi-field { flex: 1; }

.kpi-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 3px;
}

.kpi-field input {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.kpi-field input:focus { outline: none; border-color: #4a90d9; }

/* 创意参数折叠 */
.creative-details {
    margin-top: 10px;
    font-size: 12px;
}

.creative-details summary {
    cursor: pointer;
    color: #888;
    font-weight: 500;
    padding: 4px 0;
}

.creative-body {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid #e8e8e8;
}

/* 输出数量 */
.output-count-wrap { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.count-input {
    width: 52px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.count-label { font-size: 11px; color: #888; white-space: nowrap; }

/* ---- 垫图 ---- */
.ref-section {
    padding: 0 0 10px 0;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 20px;
}

.ref-toggle-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.ref-main-toggle {
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ref-sub-options { display: flex; gap: 14px; align-items: center; }

.ref-radio {
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    color: #666;
}

/* ---- 批量行 ---- */
.batch-row { margin-bottom: 8px; }

.batch-row-fields {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    position: relative;
}

.batch-row-fields label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    margin-bottom: 3px;
}

.batch-row-fields input,
.batch-row-fields textarea,
.batch-row-fields select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    font-family: inherit;
}

.batch-row-fields input:focus,
.batch-row-fields textarea:focus,
.batch-row-fields select:focus {
    outline: none;
    border-color: #4a90d9;
}

.batch-row-fields textarea { resize: vertical; }

.brf-label { flex: 0 0 80px; }
.brf-lang { flex: 0 0 130px; }
.brf-person { flex: 1; }
.brf-scene { flex: 1; }
.brf-script { flex: 1; }

.char-person-disabled { opacity: 0.4; pointer-events: none; }

.remove-btn {
    flex: 0 0 26px;
    width: 26px; height: 26px;
    padding: 0;
    margin: 18px 0 0 0;
    background: #f5f5f5;
    color: #999;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.remove-btn:hover { background: #fee; color: #c0392b; border-color: #f5c6cb; }

.add-row-btn {
    width: auto;
    padding: 6px 16px;
    margin: 4px 0 0 0;
    background: white;
    color: #4a90d9;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.add-row-btn:hover { background: #f0f6ff; border-color: #4a90d9; }

.row-count {
    font-size: 12px;
    color: #888;
    background: #f0f0f0;
    padding: 2px 10px;
    border-radius: 8px;
}

/* ---- 按钮 ---- */
button:not(.add-row-btn):not(.copy-btn-small):not(.remove-btn):not(.abort-btn) {
    display: block;
    width: 100%;
    padding: 13px;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin: 22px 0;
    transition: background 0.2s;
}

button:hover:not(.add-row-btn):not(.copy-btn-small):not(.remove-btn):not(.abort-btn) { background: #357abd; }

button:disabled:not(.add-row-btn):not(.copy-btn-small):not(.remove-btn):not(.abort-btn) { background: #a0b8d0; cursor: not-allowed; }

/* ---- 进度 ---- */
#progress-area { margin: 14px 0; padding: 14px; background: #f8f8f8; border-radius: 6px; border: 1px solid #e0e0e0; }

.progress-bar-bg { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }

.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #4a90d9, #5cb85c); border-radius: 3px; transition: width 0.3s ease; }

.progress-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

.progress-text { font-size: 12px; color: #888; }

.abort-btn {
    width: auto;
    padding: 5px 14px;
    background: white;
    color: #d9534f;
    border: 1px solid #d9534f;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
}

.abort-btn:hover { background: #fef2f2; }

/* ---- 结果 ---- */
.result-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.result-actions { display: flex; align-items: center; gap: 8px; }

.result-count { font-size: 12px; color: #888; background: #f0f0f0; padding: 3px 10px; border-radius: 8px; }

.results-table-wrap { overflow-x: auto; border: 1px solid #e0e0e0; border-radius: 5px; }

.results-table { width: 100%; border-collapse: collapse; font-size: 12px; }

.results-table th {
    background: #f5f5f5;
    color: #444;
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}


.results-table td { padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: top; }

.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: #fafafa; }

.col-num { width: 34px; text-align: center; }
.col-char { width: 64px; }
.col-script { width: 64px; }
.col-model { width: 60px; }
.col-seg { width: 36px; text-align: center; }
.col-var { width: 36px; text-align: center; color: #999; }
.col-copy { width: 50px; text-align: center; }

.model-badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.model-veo { background: #e8f0fe; color: #1a56db; }
.model-jimeng { background: #e6f7ed; color: #0e7c3d; }

.prompt-preview {
    max-height: 80px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8f8f8;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #eee;
    margin: 0;
    cursor: pointer;
    transition: max-height 0.2s;
}

.prompt-preview:hover { max-height: 400px; background: #fefefe; border-color: #ddd; }

.copy-btn-small {
    width: auto;
    padding: 4px 12px;
    background: white;
    color: #4a90d9;
    border: 1px solid #4a90d9;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin: 0;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-block;
}

.copy-btn-small:hover { background: #4a90d9; color: white; }

/* ---- 错误提示 ---- */
.error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 580px;
    background: #fef2f2;
    color: #c0392b;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 12px 18px;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
    line-height: 1.5;
}

/* ---- 响应式 ---- */
@media (max-width: 700px) {
    .container { padding: 14px; }
    .config-row { flex-direction: column; gap: 8px; }
    .config-model { flex-direction: column; align-items: stretch; }
    .model-header-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .config-model select { width: 100%; }
    .kpi-row { flex-direction: column; gap: 6px; }
    .adv-row { flex-direction: column; gap: 8px; }
    .batch-row-fields { flex-direction: column; gap: 6px; }
    .brf-label, .brf-lang { flex: none; width: 100%; }
    .brf-person, .brf-scene, .brf-script { flex: none; width: 100%; }
    .remove-btn { position: absolute; top: 6px; right: 6px; margin: 0; }
    .ref-toggle-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .ref-sub-options { flex-direction: column; align-items: flex-start; gap: 3px; padding-left: 20px; }
    .results-table { font-size: 11px; }
    .results-table th, .results-table td { padding: 6px; }
    .error-toast { left: 10px; right: 10px; transform: none; max-width: none; }
}
