/* ===== 工具类 (Utility Classes) ===== */

/* 渐变背景 */
.btn-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

/* 悬浮提升效果 */
.btn-hover-lift:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Flex居中 */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 内联Flex居中 */
.flex-inline-center {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 文本截断 */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 圆形操作图标 */
.action-icon-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.2s ease, transform 0.15s ease;
    pointer-events: auto;
    flex-shrink: 0;
}

.action-icon-circle:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.action-icon-circle.delete:hover {
    background: rgba(220, 53, 69, 0.9);
}

.action-icon-circle.edit:hover {
    background: rgba(40, 167, 69, 0.9);
}

/* 模态框覆盖层 */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 模态框头部 */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(122, 182, 255, .08));
}

/* 模态框关闭按钮 */
.modal-close-btn {
    background: none;
    border: 1px solid var(--border-color, rgba(122, 182, 255, .12));
    color: var(--text-secondary, #8899aa);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: .15s;
}

.modal-close-btn:hover {
    background: rgba(122, 182, 255, .1);
    color: var(--text-primary, #eef3f8);
}

/* 缩略图容器 */
.thumb-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    width: 100%;
    background: rgba(8, 12, 17, .62);
    overflow: hidden;
}

.thumb-container img,
.thumb-container video {
    display: block;
    height: 100%;
    object-fit: cover;
}

/* 次要渐变背景 (青色) */
.btn-gradient-secondary {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff;
}

/* 徽章样式 */
.badge-gradient {
    bottom: 4px;
    right: 4px;
    z-index: 2;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff;
    line-height: 1.4;
}

/* 圆形徽章 */
.badge-circle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(0,0,0,.28);
    z-index: 11;
    pointer-events: none;
}

body {
    margin: 0;
    padding: 0;
    color: #333333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    overflow-y: auto;
    box-sizing: border-box;
}

.container {
    width: 600px;
    margin: 0;
    padding: 15px;
}

.form-container {
    padding: 20px;
    background: rgb(255, 255, 255);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
}

/* 作者信息样式 */
.author-left {
    display: flex;
    align-items: center;
}

.author-right {
    display: flex;
    align-items: center;
}

/* 参数列表样式 */
.params-list {
    margin: 0;
    padding: 0;
}

/* 状态样式 */
.detail-status {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 15px;
}

.status-pending {
    background: rgba(102, 126, 234, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.status-failed {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* 图片占位符样式 */
.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    color: #999;
    font-size: 14px;
    border-radius: 10px;
}

.form-group {
    margin-bottom: 10px;
}

/* 当form-group包含3个及以上图片组件时，使用grid布局一行显示五个 */
.form-group.has-multiple-uploads {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.form-group.has-multiple-uploads>label {
    grid-column: 1 / -1;
}

.form-group.has-multiple-uploads .uploads-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    grid-column: 1 / -1;
}

/* 每个图片上传项的包裹容器 */
.upload-item-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 140px;
    /* 确保容器有足够高度 */
}

.upload-item-wrapper .file-upload-container {
    flex: 1;
    /* 占满可用空间 */
}

.upload-item-wrapper label {
    font-size: 14px;
    color: #667eea;
    margin-bottom: 0;
}

.form-group label {
    position: relative;
    display: flex;
    color: #667eea;
}

.form-control {
    width: calc(100% - 32px);
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #ffffff;
    color: #333333;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* textarea自动高度调整样式 */
.form-control[type="textarea"],
textarea.form-control {
    resize: none;
    /* 禁用手动调整大小 */
    transition: height 0.2s ease;
    /* 平滑的高度变化动画 */
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #ffffff;
    color: #333333;
    transition: all 0.3s ease;
}

.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* 按钮loading动画 */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: #667eea;
    font-size: 18px;
    font-weight: 600;
}

.result-container {
    width: 100%;
    min-height: fit-content;
    margin: auto 0;
    margin-top: 15px;
    padding: 20px;
    background: rgb(255, 255, 255);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-right: 15px;
    text-align: center;
}

.result-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* 自定义单选项样式 */
.custom-radio-container {
    display: grid;
    gap: 5px;
    grid-template-columns: repeat(4, auto);
}

.custom-radio-option {
    position: relative;
}

.custom-radio-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #ffffff;
    transition: all 0.3s ease;
    position: relative;
}

.custom-radio-label:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.custom-radio-option input[type="radio"]:checked+.custom-radio-label {
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.custom-radio-option input[type="radio"]:checked+.custom-radio-label span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.custom-radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-preview-img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 7px;
}

/* 有预览图时的文本样式 */
.custom-radio-label:has(.radio-preview-img) span {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    background-color: #00000095;
    color: #ffffff;
    border-radius: 0 0 7px 7px;
    text-align: center;
}

/* 无预览图时的文本样式 */
.custom-radio-label:not(:has(.radio-preview-img)) span {
    position: static;
    color: #333;
    text-align: center;
    padding: 8px;
    width: calc(100% - 16px);
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    border-radius: 7px;
    transition: all 0.3s ease;
}

/* 无预览图时选中状态的文本样式 */
.custom-radio-option input[type="radio"]:checked+.custom-radio-label:not(:has(.radio-preview-img)) span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

/* 任务状态样式 */
.task-status {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.status-badge.pending {
    background: #ffc107;
}

.status-badge.processing {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.status-badge.queued {
    background: rgba(102, 126, 234, 0.9);
}

.status-badge.running {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.status-badge.completed {
    background: #28a745;
}

.status-badge.failed {
    background: #dc3545;
}

.countdown-display {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 0 2px;
    max-width: 100%;
}

.countdown-progress-bar-wrap {
    width: 100%;
    height: 4px;
    background: rgba(102, 126, 234, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.countdown-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.8s ease;
    min-width: 4px;
}

.countdown-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.countdown-progress-pct {
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    min-width: 32px;
    text-align: right;
}

.countdown-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(102, 126, 234, 0.25);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: countdown-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.countdown-est-line {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: 2px;
    line-height: 1.3;
}

@keyframes countdown-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}



.countdown-display.error {
    display: none;
}

#checkStatusBtn {
    margin-top: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

#checkStatusBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid transparent;
    font-weight: 500;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* 现代化文件上传组件样式 */
.file-upload-container {
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: 15px;
}

.file-upload-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-input {
    display: none;
}

.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px dashed #ddd;
    border-radius: 16px;
    background: var(--bg-tertiary);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    height: 100px;
    border-radius: 10px;
}

.file-upload-wrapper:hover .file-upload-area {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.file-upload-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.file-upload-status.success {
    position: absolute;
    right: 5px;
    top: 5px;
    color: white;
    background: rgba(102, 126, 234, 0.9);
    font-size: 10px;
    border-radius: 10px;
    height: 15px;
    width: 15px;
    line-height: 15px;
    text-align: center;
}

.file-upload-wrapper:hover .file-upload-icon {
    opacity: 1;
    transform: scale(1.1);
}

.file-upload-text {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    transition: color 0.3s ease;
}

.file-upload-hint {
    display: none;
    font-size: 14px;
    color: #999;
    text-align: center;
    line-height: 1.4;
}

.file-upload-wrapper:hover .file-upload-text {
    color: #764ba2;
}

/* 文件预览样式 */
.file-preview-container {
    position: relative;
    margin-top: 16px;
    animation: fadeInUp 0.3s ease;
    text-align: center;
    align-items: center;
    flex-direction: column;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-preview {
    max-width: 100%;
    max-height: 360px;
}

.file-preview:hover {
    transform: scale(1.02);
}

/* 上传区域内预览样式 */
.file-upload-area.has-file {
    padding: 0;
    border: 2px solid #667eea;
    position: relative;
    overflow: visible;
    height: 116px;
}

.file-upload-area.has-file .file-upload-icon,
.file-upload-area.has-file .file-upload-text,
.file-upload-area.has-file .file-upload-hint {
    display: none;
}

.file-upload-area .preview-image {
    max-width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* 关闭按鈕（右上角，一半在外） */
.file-upload-area .upload-close-btn {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 16px;
    height: 16px;
    background: rgba(220, 53, 69, 0.88);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 0;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.file-upload-area .upload-close-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.15);
}

/* 音频控件样式 */
.file-upload-area audio {
    width: 100%;
    margin: 10px 0;
}

/* 视频控件样式 */
.file-upload-area video {
    border-radius: 14px;
}

/* 蒙版编辑按钮样式 */
.file-upload-area .edit-mask-btn:hover {
    background: rgba(118, 75, 162, 1) !important;
    transform: translateY(-1px);
}

.upload-progress {
    width: 100%;
    height: 8px;
    background: linear-gradient(145deg, rgba(20, 30, 40, 0.8) 0%, rgba(30, 40, 50, 0.8) 100%);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 15px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 150, 255, 0.8), rgba(0, 100, 200, 0.8));
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.5);
}

.upload-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}



.upload-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 14px;
    font-weight: 600;
    justify-content: center;
}

.upload-status.success {
    color: #00ff88;
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.6);
}

.upload-status.error {
    color: #ff6666;
    text-shadow: 0 0 5px rgba(255, 102, 102, 0.6);
}

.upload-status.uploading {
    color: #00ccff;
    text-shadow: 0 0 5px rgba(0, 204, 255, 0.6);
}

.status-icon {
    width: 18px;
    height: 18px;
    filter: drop-shadow(0 0 3px currentColor);
}

/* 标签切换功能样式 */
.tab-container {
    margin-bottom: 20px;
}

.tab-header {
    display: flex;
    margin-top: 20px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: rgba(102, 126, 234, 0.05);
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #764ba2;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* 随机按钮样式 */
.label-with-random {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

/* Chat UI 中随机按钮行 */
.chat-random-row {
    display: flex;
    justify-content: flex-end;
    position: absolute;
    bottom: 72px;
    right: 25px;
}

.random-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.random-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.random-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.random-btn img {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
    display: block;
}

.tab-content {
    position: relative;
}

.tab-panel {
    display: none;
    animation: fadeInTab 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 编辑蒙版按钮样式 */
.edit-mask-btn {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.8) 0%, rgba(0, 100, 200, 0.8) 100%);
    border: 1px solid rgba(0, 150, 255, 0.5);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 0 5px rgba(0, 150, 255, 0.8);
}

.edit-mask-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 150, 255, 0.4), 0 4px 12px rgba(0, 150, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-shadow: 0 0 8px rgba(0, 150, 255, 1);
}

.edit-mask-btn:active {
    transform: translateY(-1px);
}

/* 画笔编辑按鈕（左上角，一半在外，16px圆形） */
.file-upload-area .draw-edit-btn {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: rgba(102, 126, 234, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.file-upload-area .draw-edit-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.15);
}

/* 图片绘制模态框 */
#imgDrawModal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

#imgDrawModal .draw-modal-box {
    background: #1a1a2e;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    width: auto;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    border: 1px solid rgba(102, 126, 234, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#imgDrawModal .draw-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: rgba(102, 126, 234, 0.15);
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    flex-wrap: wrap;
    flex-shrink: 0;
}

#imgDrawModal .draw-toolbar label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    white-space: nowrap;
}

#imgDrawModal .draw-canvas-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    background: #111;
    cursor: crosshair;
}

#imgDrawModal canvas {
    display: block;
    touch-action: none;
}

#imgDrawModal .draw-actions {
    display: flex;
    gap: 10px;
    padding: 9px 14px;
    border-top: 1px solid rgba(102, 126, 234, 0.3);
    justify-content: flex-end;
    flex-shrink: 0;
    background: rgba(102, 126, 234, 0.1);
}

#imgDrawModal .draw-tool-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    white-space: nowrap;
}

#imgDrawModal .draw-tool-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

#imgDrawModal .draw-action-btn {
    padding: 7px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

#imgDrawModal .draw-action-btn.confirm {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

#imgDrawModal .draw-action-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#imgDrawModal .draw-action-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* 蒙版预览样式 */
.mask-preview {
    position: absolute;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.mask-param-info {
    background: linear-gradient(145deg, rgba(0, 150, 255, 0.2) 0%, rgba(0, 100, 200, 0.2) 100%);
    border: 1px solid rgba(0, 150, 255, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    color: #00ccff;
    text-shadow: 0 0 5px rgba(0, 204, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.2);
}

/* 文件类型图标 */
.file-type-icon {
    width: 48px;
    height: 48px;
    background: rgba(0, 150, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    position: relative;
}

.file-type-icon::before {
    content: '📁';
    font-size: 24px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.file-type-icon.image::before {
    content: '🖼️';
}

.file-type-icon.video::before {
    content: '🎬';
}

.file-type-icon.audio::before {
    content: '🎵';
}

/* 响应式设计 */
@media (max-width: 768px) {
    .custom-radio-option {
        font-size: 0.8rem;
    }

    .file-upload-area {
        padding: 10px;
    }

    .file-upload-icon {
        width: 45px;
        height: 45px;
    }

    .file-upload-text {
        font-size: 15px;
    }

    .file-upload-hint {
        font-size: 13px;
    }
}

/* 图片网格样式 */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 20px;
    /* 确保网格容器有明确的宽度 */
    width: 100%;
    /* 防止内容溢出 */
    overflow-x: hidden;
}

/* 表格式列表样式 */
.images-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    table-layout: fixed;
    /* 固定表格布局，确保列宽可控 */
}

.images-table-header {
    display: table-header-group;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.images-table-body {
    display: table-row-group;
}

.images-table-row {
    display: table-row;
    transition: background-color 0.2s ease;
}

.images-table-row:hover {
    background-color: var(--bg-tertiary);
}

.images-table-cell {
    display: table-cell;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.images-table-header .images-table-cell {
    padding: 12px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.table-image-preview {
    width: 100px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.table-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    min-width: 70px;
}

.table-task-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.table-created-at {
    font-size: 12px;
    color: var(--text-secondary);
}

.table-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.table-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.table-action-btn.delete {
    background: #dc3545;
    color: white;
}

.table-action-btn.share {
    background: #28a745;
    color: white;
}

.table-action-btn.retry {
    background: #ffc107;
    color: #212529;
}

.table-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 切换按钮样式 */
.view-toggle-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
}


.image-wrapper {
    display: flex;
    position: relative;
    overflow: hidden;
    border-radius: 7px;
    background: var(--bg-primary);
    justify-content: center;
}

.image-wrapper img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.image-wrapper:hover {
    transform: translateY(-2px);
}

.image-wrapper:hover img {
    transform: scale(1.03);
}

/* 任务说明样式（chat布局下隐藏） */
.task-description {
    display: none !important;
}

.share-btn,
.submit-card-btn,
.delete-btn {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.8) 0%, rgba(0, 100, 200, 0.8) 100%);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    color: #ffffff;
    font-weight: 500;
    transition: all 0.3s ease;
}

.share-btn:hover,
.submit-card-btn:hover,
.delete-btn:hover {
    transform: translateY(-1px);
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding-top: 15px;
}

.pagination-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #ffffff;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    min-width: 80px;
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.pagination-btn:disabled,
.pagination-btn.disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pagination-info {
    color: #667eea;
    font-weight: 600;
    font-size: 12px;
}

@media (max-width: 768px) {
    .task-description {
        padding: 12px;
        font-size: 13px;
        margin-bottom: 15px;
    }

    body {
        display: block;
    }

    .container {
        max-width: auto;
        width: auto;
        padding: 15px;
    }

    .form-container {
        padding: 15px;
    }

    /* 手机端隐藏功能标题 */
    #userInfoArea {
        display: none;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
        /* 确保在小屏幕上也能正确显示 */
        min-width: 0;
    }

    .image-wrapper img {
        max-height: 200px;
        border-radius: 8px;
    }

    .result-container {
        width: auto;
        margin-left: 15px;
        padding: 15px;
    }

    .pagination {
        gap: 8px;
    }
}

/* 暗黑主题样式 */
[data-theme="dark"] .container {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .form-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .form-control {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .form-select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .result-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .task-status {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
}

[data-theme="dark"] .custom-radio-label {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .custom-radio-label:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

[data-theme="dark"] .custom-radio-option input[type="radio"]:checked+.custom-radio-label {
    border: 2px solid var(--accent-primary);
    background: rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .custom-radio-option input[type="radio"]:checked+.custom-radio-label span {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #ffffff;
}

[data-theme="dark"] .custom-radio-label span {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .alert-success {
    background: rgba(40, 167, 69, 0.2);
    color: #4caf50;
    border: 1px solid rgba(40, 167, 69, 0.4);
}

[data-theme="dark"] .alert-danger {
    background: rgba(220, 53, 69, 0.2);
    color: #f44336;
    border: 1px solid rgba(220, 53, 69, 0.4);
}

[data-theme="dark"] .image-placeholder {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

[data-theme="dark"] .loading {
    background: rgba(26, 26, 26, 0.9);
    color: var(--accent-primary);
}

[data-theme="dark"] .status-pending {
    background: rgba(124, 138, 237, 0.2);
    color: var(--accent-primary);
}

[data-theme="dark"] .tab-header {
    background: var(--bg-secondary);
}

[data-theme="dark"] .tab-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
}

[data-theme="dark"] .tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #ffffff;
    border-bottom-color: var(--accent-primary);
}

[data-theme="dark"] .file-upload-area {
    border: 2px dashed var(--border-color);
}

[data-theme="dark"] .file-upload-wrapper:hover .file-upload-area {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

[data-theme="dark"] .file-upload-text {
    color: var(--text-primary);
}

[data-theme="dark"] .file-upload-hint {
    color: var(--text-secondary);
    display: none;
}

[data-theme="dark"] .status-failed {
    background: rgba(220, 53, 69, 0.2);
    color: #f44336;
    border: 1px solid rgba(220, 53, 69, 0.4);
}

/* 处理中状态的动态背景效果 */
.image-wrapper[data-status="pending"],
.image-wrapper[data-status="processing"],
.image-wrapper[data-status="running"] {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* 动态圆形背景 - 确保在所有元素之下 */
.image-wrapper[data-status="pending"]::before,
.image-wrapper[data-status="processing"]::before,
.image-wrapper[data-status="running"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--state-processing-bg), var(--state-processing-bg-soft));
    z-index: -10;
    pointer-events: none;
}

/* 模糊遮罩层 - 增加模糊效果 */
.image-wrapper[data-status="pending"]::after,
.image-wrapper[data-status="processing"]::after,
.image-wrapper[data-status="running"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--processing-bg-color, rgba(102, 126, 234, 0.08));
    z-index: -5;
    pointer-events: none;
}

/* 圆形动画 - 1秒循环，30帧流畅无缝循环 */
@keyframes floatingCircles {
    0% {
        --circle1-x: 20%;
        --circle1-y: 30%;
        --circle1-size: 25%;
        --circle2-x: 70%;
        --circle2-y: 60%;
        --circle2-size: 35%;
        --circle3-x: 50%;
        --circle3-y: 80%;
        --circle3-size: 30%;
    }

    3.33% {
        --circle1-x: 25%;
        --circle1-y: 25%;
        --circle1-size: 27%;
        --circle2-x: 75%;
        --circle2-y: 55%;
        --circle2-size: 33%;
        --circle3-x: 45%;
        --circle3-y: 75%;
        --circle3-size: 32%;
    }

    6.67% {
        --circle1-x: 32%;
        --circle1-y: 22%;
        --circle1-size: 29%;
        --circle2-x: 78%;
        --circle2-y: 48%;
        --circle2-size: 31%;
        --circle3-x: 42%;
        --circle3-y: 68%;
        --circle3-size: 34%;
    }

    10% {
        --circle1-x: 40%;
        --circle1-y: 20%;
        --circle1-size: 31%;
        --circle2-x: 80%;
        --circle2-y: 40%;
        --circle2-size: 29%;
        --circle3-x: 40%;
        --circle3-y: 60%;
        --circle3-size: 36%;
    }

    13.33% {
        --circle1-x: 48%;
        --circle1-y: 19%;
        --circle1-size: 33%;
        --circle2-x: 81%;
        --circle2-y: 32%;
        --circle2-size: 27%;
        --circle3-x: 39%;
        --circle3-y: 51%;
        --circle3-size: 38%;
    }

    16.67% {
        --circle1-x: 56%;
        --circle1-y: 19%;
        --circle1-size: 35%;
        --circle2-x: 80%;
        --circle2-y: 25%;
        --circle2-size: 25%;
        --circle3-x: 40%;
        --circle3-y: 42%;
        --circle3-size: 40%;
    }

    20% {
        --circle1-x: 64%;
        --circle1-y: 20%;
        --circle1-size: 37%;
        --circle2-x: 78%;
        --circle2-y: 19%;
        --circle2-size: 23%;
        --circle3-x: 42%;
        --circle3-y: 34%;
        --circle3-size: 42%;
    }

    23.33% {
        --circle1-x: 71%;
        --circle1-y: 22%;
        --circle1-size: 39%;
        --circle2-x: 75%;
        --circle2-y: 14%;
        --circle2-size: 21%;
        --circle3-x: 45%;
        --circle3-y: 27%;
        --circle3-size: 44%;
    }

    26.67% {
        --circle1-x: 77%;
        --circle1-y: 25%;
        --circle1-size: 41%;
        --circle2-x: 70%;
        --circle2-y: 10%;
        --circle2-size: 19%;
        --circle3-x: 49%;
        --circle3-y: 21%;
        --circle3-size: 46%;
    }

    30% {
        --circle1-x: 82%;
        --circle1-y: 30%;
        --circle1-size: 43%;
        --circle2-x: 64%;
        --circle2-y: 8%;
        --circle2-size: 17%;
        --circle3-x: 54%;
        --circle3-y: 16%;
        --circle3-size: 48%;
    }

    33.33% {
        --circle1-x: 85%;
        --circle1-y: 36%;
        --circle1-size: 45%;
        --circle2-x: 57%;
        --circle2-y: 7%;
        --circle2-size: 15%;
        --circle3-x: 60%;
        --circle3-y: 12%;
        --circle3-size: 50%;
    }

    36.67% {
        --circle1-x: 87%;
        --circle1-y: 43%;
        --circle1-size: 47%;
        --circle2-x: 49%;
        --circle2-y: 8%;
        --circle2-size: 18%;
        --circle3-x: 67%;
        --circle3-y: 10%;
        --circle3-size: 48%;
    }

    40% {
        --circle1-x: 87%;
        --circle1-y: 51%;
        --circle1-size: 45%;
        --circle2-x: 41%;
        --circle2-y: 10%;
        --circle2-size: 21%;
        --circle3-x: 74%;
        --circle3-y: 9%;
        --circle3-size: 46%;
    }

    43.33% {
        --circle1-x: 85%;
        --circle1-y: 59%;
        --circle1-size: 43%;
        --circle2-x: 33%;
        --circle2-y: 13%;
        --circle2-size: 24%;
        --circle3-x: 80%;
        --circle3-y: 10%;
        --circle3-size: 44%;
    }

    46.67% {
        --circle1-x: 82%;
        --circle1-y: 67%;
        --circle1-size: 41%;
        --circle2-x: 26%;
        --circle2-y: 17%;
        --circle2-size: 27%;
        --circle3-x: 85%;
        --circle3-y: 12%;
        --circle3-size: 42%;
    }

    50% {
        --circle1-x: 77%;
        --circle1-y: 74%;
        --circle1-size: 39%;
        --circle2-x: 20%;
        --circle2-y: 22%;
        --circle2-size: 30%;
        --circle3-x: 89%;
        --circle3-y: 16%;
        --circle3-size: 40%;
    }

    53.33% {
        --circle1-x: 71%;
        --circle1-y: 80%;
        --circle1-size: 37%;
        --circle2-x: 15%;
        --circle2-y: 28%;
        --circle2-size: 33%;
        --circle3-x: 91%;
        --circle3-y: 21%;
        --circle3-size: 38%;
    }

    56.67% {
        --circle1-x: 64%;
        --circle1-y: 85%;
        --circle1-size: 35%;
        --circle2-x: 12%;
        --circle2-y: 35%;
        --circle2-size: 36%;
        --circle3-x: 92%;
        --circle3-y: 27%;
        --circle3-size: 36%;
    }

    60% {
        --circle1-x: 56%;
        --circle1-y: 88%;
        --circle1-size: 33%;
        --circle2-x: 10%;
        --circle2-y: 43%;
        --circle2-size: 39%;
        --circle3-x: 91%;
        --circle3-y: 34%;
        --circle3-size: 34%;
    }

    63.33% {
        --circle1-x: 48%;
        --circle1-y: 90%;
        --circle1-size: 31%;
        --circle2-x: 9%;
        --circle2-y: 51%;
        --circle2-size: 42%;
        --circle3-x: 89%;
        --circle3-y: 42%;
        --circle3-size: 32%;
    }

    66.67% {
        --circle1-x: 40%;
        --circle1-y: 91%;
        --circle1-size: 29%;
        --circle2-x: 10%;
        --circle2-y: 59%;
        --circle2-size: 45%;
        --circle3-x: 85%;
        --circle3-y: 51%;
        --circle3-size: 30%;
    }

    70% {
        --circle1-x: 32%;
        --circle1-y: 90%;
        --circle1-size: 27%;
        --circle2-x: 12%;
        --circle2-y: 67%;
        --circle2-size: 43%;
        --circle3-x: 80%;
        --circle3-y: 60%;
        --circle3-size: 32%;
    }

    73.33% {
        --circle1-x: 25%;
        --circle1-y: 88%;
        --circle1-size: 25%;
        --circle2-x: 15%;
        --circle2-y: 74%;
        --circle2-size: 41%;
        --circle3-x: 74%;
        --circle3-y: 69%;
        --circle3-size: 34%;
    }

    76.67% {
        --circle1-x: 19%;
        --circle1-y: 85%;
        --circle1-size: 27%;
        --circle2-x: 19%;
        --circle2-y: 80%;
        --circle2-size: 39%;
        --circle3-x: 67%;
        --circle3-y: 77%;
        --circle3-size: 36%;
    }

    80% {
        --circle1-x: 14%;
        --circle1-y: 80%;
        --circle1-size: 29%;
        --circle2-x: 24%;
        --circle2-y: 85%;
        --circle2-size: 37%;
        --circle3-x: 60%;
        --circle3-y: 84%;
        --circle3-size: 38%;
    }

    83.33% {
        --circle1-x: 11%;
        --circle1-y: 74%;
        --circle1-size: 31%;
        --circle2-x: 30%;
        --circle2-y: 89%;
        --circle2-size: 35%;
        --circle3-x: 52%;
        --circle3-y: 90%;
        --circle3-size: 40%;
    }

    86.67% {
        --circle1-x: 9%;
        --circle1-y: 67%;
        --circle1-size: 33%;
        --circle2-x: 37%;
        --circle2-y: 91%;
        --circle2-size: 33%;
        --circle3-x: 44%;
        --circle3-y: 94%;
        --circle3-size: 38%;
    }

    90% {
        --circle1-x: 9%;
        --circle1-y: 59%;
        --circle1-size: 31%;
        --circle2-x: 45%;
        --circle2-y: 92%;
        --circle2-size: 31%;
        --circle3-x: 37%;
        --circle3-y: 97%;
        --circle3-size: 36%;
    }

    93.33% {
        --circle1-x: 11%;
        --circle1-y: 51%;
        --circle1-size: 29%;
        --circle2-x: 53%;
        --circle2-y: 91%;
        --circle2-size: 33%;
        --circle3-x: 30%;
        --circle3-y: 98%;
        --circle3-size: 34%;
    }

    96.67% {
        --circle1-x: 15%;
        --circle1-y: 42%;
        --circle1-size: 27%;
        --circle2-x: 61%;
        --circle2-y: 89%;
        --circle2-size: 35%;
        --circle3-x: 24%;
        --circle3-y: 97%;
        --circle3-size: 32%;
    }

    100% {
        --circle1-x: 20%;
        --circle1-y: 30%;
        --circle1-size: 25%;
        --circle2-x: 70%;
        --circle2-y: 60%;
        --circle2-size: 35%;
        --circle3-x: 50%;
        --circle3-y: 80%;
        --circle3-size: 30%;
    }
}

/* 主题色支持 */
:root {
    --state-idle-bg: rgba(102, 126, 234, 0.08);
    --state-idle-border: rgba(102, 126, 234, 0.24);
    --state-processing-bg: rgba(102, 126, 234, 0.18);
    --state-processing-bg-soft: rgba(118, 75, 162, 0.12);
    --state-processing-border: rgba(102, 126, 234, 0.38);
    --state-queued-bg: rgba(102, 126, 234, 0.10);
    --state-queued-border: rgba(102, 126, 234, 0.28);
    --state-failed-border: rgba(220, 53, 69, 0.32);
    --state-failed-text: #b4232f;
    --processing-bg-color: rgba(102, 126, 234, 0.08);
}

[data-theme="dark"] {
    --state-idle-bg: rgba(102, 126, 234, 0.10);
    --state-idle-border: rgba(146, 166, 255, 0.22);
    --state-processing-bg: rgba(102, 126, 234, 0.20);
    --state-processing-bg-soft: rgba(118, 75, 162, 0.16);
    --state-processing-border: rgba(146, 166, 255, 0.34);
    --state-queued-bg: rgba(102, 126, 234, 0.13);
    --state-queued-border: rgba(146, 166, 255, 0.26);
    --state-failed-border: rgba(248, 113, 113, 0.34);
    --state-failed-text: #f87171;
    --processing-bg-color: rgba(102, 126, 234, 0.10);
}

/* 历史上传模态框样式 */
/* ---- 快捷资源模态框样式（复刻自Canvas.php） ---- */
.template-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center
}

.template-modal.hidden {
    display: none
}

.template-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px)
}

.template-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(980px, calc(100vw - 20px));
    max-height: min(88vh, 820px);
    background: var(--bg-primary, #1a2332);
    border-radius: 18px;
    border: 1px solid var(--border-color, rgba(122, 182, 255, .12));
    box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.template-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(122, 182, 255, .08))
}

.template-modal-eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: rgba(122, 182, 255, .6);
    margin-bottom: 2px
}

.template-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #eef3f8)
}

.template-modal-close {
    background: none;
    border: 1px solid var(--border-color, rgba(122, 182, 255, .12));
    color: var(--text-secondary, #8899aa);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: .15s
}

.template-modal-close:hover {
    background: rgba(122, 182, 255, .1);
    color: var(--text-primary, #eef3f8)
}

.quick-resource-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 0 16px
}

.quick-resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    padding: 10px 16px 16px;
    max-height: min(64vh, 720px);
    overflow: auto
}

.quick-resource-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(122, 182, 255, .08);
    border-radius: 14px;
    background: rgba(255, 255, 255, .03);
    color: var(--text-primary, #eef3f8);
    cursor: pointer;
    transition: .16s ease;
    position: relative
}

.quick-resource-card:hover {
    transform: translateY(-2px);
    border-color: rgba(122, 182, 255, .26);
    background: rgba(255, 255, 255, .05)
}

.qr-portrait-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transform: scale(.8);
    transition: .18s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 210, 255, .3)
}

.quick-resource-card:hover .qr-portrait-btn {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1)
}

.qr-portrait-btn:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 3px 12px rgba(0, 210, 255, .5)
}

.quick-resource-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    width: 100%;
    border-radius: 12px;
    background: rgba(8, 12, 17, .62);
    overflow: hidden
}

.quick-resource-thumb img,
.quick-resource-thumb video {
    display: block;
    height: 100%;
    object-fit: cover
}

.quick-resource-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .06)
}

.quick-resource-audio svg {
    width: 20px;
    height: 20px;
    fill: currentColor
}

.quick-resource-name {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, #8899aa);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%
}

.quick-resource-label {
    display: block;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1.4;
    width: 100%;
    color: rgba(186, 198, 214, .88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.quick-resource-card.upload {
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(122, 182, 255, .08), rgba(255, 255, 255, .025))
}

.quick-resource-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .06);
    font-size: 36px;
    line-height: 1
}

.portrait-nav-bar .portrait-back-btn:hover {
    color: #7ab6ff;
    text-decoration: underline
}

.portrait-asset-pending {
    cursor: default !important;
    opacity: .7
}

.portrait-asset-pending:hover {
    transform: none !important;
    border-color: rgba(255, 255, 255, .08) !important;
    background: rgba(255, 255, 255, .03) !important
}

.portrait-thumb-dimmed {
    filter: brightness(.55) saturate(.5)
}

/* 人像素材操作按钮 */
.portrait-asset-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: inline-flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
    pointer-events: none
}

.quick-resource-card:hover .portrait-asset-actions {
    opacity: 1;
    pointer-events: auto
}

.portrait-action-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.2s ease, transform 0.15s ease;
    pointer-events: auto;
    flex-shrink: 0
}

.portrait-action-icon:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1)
}

.portrait-action-icon.delete:hover {
    background: rgba(220, 53, 69, 0.9)
}

.portrait-action-icon.edit:hover {
    background: rgba(40, 167, 69, 0.9)
}

@keyframes pgp-spin {
    to {
        transform: rotate(360deg)
    }
}

/* 3D导演台项目卡片样式 */
.director-project-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(122, 182, 255, .08);
    transition: .16s ease;
    cursor: pointer;
    position: relative
}

.director-project-card:hover {
    transform: translateY(-2px);
    border-color: rgba(122, 182, 255, .26);
    background: rgba(255, 255, 255, .05)
}

.director-project-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    width: 100%;
    background: rgba(8, 12, 17, .62);
    overflow: hidden
}

.director-project-thumb img {
    display: block;
    height: 100%;
    width: 100%;
    object-fit: cover
}

.director-project-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    padding-bottom: 6px;
    opacity: 0;
    transition: opacity .2s ease
}

.director-project-card:hover .director-project-overlay {
    opacity: 1
}

.director-project-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s ease
}

.director-use-btn {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff
}

.director-use-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 210, 255, .4)
}

.director-edit-btn {
    background: rgba(255, 255, 255, .25);
    color: #fff;
    backdrop-filter: blur(4px)
}

.director-edit-btn:hover {
    background: rgba(255, 255, 255, .4);
    transform: scale(1.05)
}

.director-project-name {
    padding: 0 8px 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary, #8899aa);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%
}

/* 3D导演台项目操作按钮（右上角） */
.director-project-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: inline-flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    pointer-events: none
}

.director-project-card:hover .director-project-actions {
    opacity: 1;
    pointer-events: auto
}

.director-action-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.2s ease, transform 0.15s ease;
    pointer-events: auto;
    flex-shrink: 0
}

.director-action-icon:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1)
}

.director-action-icon.delete:hover {
    background: rgba(220, 53, 69, 0.9)
}

.director-action-icon.edit:hover {
    background: rgba(40, 167, 69, 0.9)
}

/* 新建项目卡片样式 */
.director-new-project-card {
    border: 2px dashed rgba(122, 182, 255, .25);
    background: rgba(122, 182, 255, .03)
}

.director-new-project-card:hover {
    border-color: rgba(122, 182, 255, .5);
    background: rgba(122, 182, 255, .08);
    transform: translateY(-2px)
}

.director-new-thumb {
    background: rgba(122, 182, 255, .05)
}

.director-new-thumb svg {
    opacity: .5;
    transition: opacity .2s ease
}

.director-new-project-card:hover .director-new-thumb svg {
    opacity: .8
}

.director-new-project-card .director-project-name {
    color: rgba(122, 182, 255, .7);
    font-weight: 600;
    text-align: center
}

/* 3D导演台编辑模态框 */
.director-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center
}

.director-edit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(4px)
}

.director-edit-modal-dialog {
    position: relative;
    z-index: 1;
    width: 90vw;
    aspect-ratio: 16/9;
    max-height: 90vh;
    background: var(--bg-primary, #1a2332);
    border-radius: 18px;
    border: 1px solid var(--border-color, rgba(122, 182, 255, .12));
    box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.director-edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(122, 182, 255, .08))
}

.director-edit-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #eef3f8)
}

.director-edit-modal-close {
    background: none;
    border: 1px solid var(--border-color, rgba(122, 182, 255, .12));
    color: var(--text-secondary, #8899aa);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: .15s
}

.director-edit-modal-close:hover {
    background: rgba(122, 182, 255, .1);
    color: var(--text-primary, #eef3f8)
}

.director-edit-modal-body {
    flex: 1;
    overflow: hidden
}

.director-edit-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none
}

.flat-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(122, 182, 255, .18);
    background: transparent;
    color: var(--text-secondary, #8899aa);
    cursor: pointer;
    font-size: 12px;
    transition: .15s
}

.flat-btn:hover {
    background: rgba(122, 182, 255, .1);
    color: var(--text-primary, #eef3f8)
}

.flat-btn.active {
    background: rgba(122, 182, 255, .12);
    border-color: rgba(122, 182, 255, .3);
    color: #7ab6ff
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    color: var(--text-secondary, #8899aa);
    font-size: 12px;
    grid-column: 1/-1
}

.empty-state.small {
    padding: 20px 12px
}

/* 手机端适配 */
@media(max-width:768px) {
    .template-modal-dialog {
        width: calc(100vw - 12px);
        max-height: 90vh;
        border-radius: 14px
    }

    .template-modal-head {
        padding: 12px 14px
    }

    .template-modal-title {
        font-size: 15px
    }

    .quick-resource-tabs {
        gap: 6px;
        padding: 0 12px;
        margin-top: 10px
    }

    .flat-btn {
        padding: 4px 8px;
        font-size: 11px;
        gap: 3px
    }

    .flat-btn svg {
        width: 12px;
        height: 12px
    }

    .quick-resource-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
        padding: 8px 12px 12px;
    }

    .quick-resource-card {
        padding: 6px;
        border-radius: 10px
    }

    .quick-resource-thumb {
        height: 90px;
        border-radius: 8px
    }

    .quick-resource-name {
        font-size: 11px
    }

    .qr-portrait-btn {
        width: 20px;
        height: 20px;
        bottom: 4px;
        right: 4px
    }
}

/* ===== Chat-style Layout ===== */
html,
body {
    height: 100%;
}

body {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

#navWrapper {
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

#mainLayout {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: auto;
    min-height: 0;
}

/* 历史区域 */
#historyArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: calc(100% - 30px);
    margin: auto;
    position: relative;
}

/* 日期快速过滤标签 */
#historyDateFilter {
    position: fixed;
    top: 8px;
    align-self: flex-end;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px 10px 4px 8px;
    box-shadow: 0 2px 8px var(--shadow-medium);
    font-size: 12px;
    color: var(--accent-primary);
    backdrop-filter: blur(6px);
    pointer-events: auto;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}

#historyDateFilter:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 10px var(--shadow-heavy);
}

#historyDateFilter label {
    color: var(--accent-primary);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    opacity: 0.85;
    line-height: 1;
}

#historyDateInput {
    border: none;
    outline: none;
    background: transparent;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    color-scheme: light dark;
}

#historyDateInput::-webkit-calendar-picker-indicator {
    opacity: 0.55;
    cursor: pointer;
}

#historyDateInput::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* 暗黑主题下日历图标（color-scheme:dark 已让浏览器自动亮色渲染，无需额外 filter） */
[data-theme="dark"] #historyDateInput::-webkit-calendar-picker-indicator {
    opacity: 0.65;
}

#historyDateClear {
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 15px;
    line-height: 1;
    display: none;
    transition: color 0.15s;
}

#historyDateClear:hover {
    color: #f44336;
}

/* 暗黑主题下日期过滤标签 */
[data-theme="dark"] #historyDateFilter {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-medium);
}

[data-theme="dark"] #historyDateInput {
    color-scheme: dark;
}

#historyArea .images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
    width: 100%;
    align-content: start;
    flex: 1;
}

#historyArea .images-table {
    margin-top: 0;
}

/* 历史记录单列列表布局 */
#historyArea .history-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    margin: auto;
    align-content: start;
    flex: 1;
    /* padding-bottom 由 JavaScript 根据底部区域高度动态计算 */
}

/* 无记录空状态 */
.empty-state-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 220px);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.empty-state-bg-icon {
    position: absolute;
    width: 260px;
    height: 260px;
    object-fit: contain;
    opacity: 0.07;
    pointer-events: none;
    user-select: none;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    filter: var(--icon-filter, none);
}

.empty-state-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state-text {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    opacity: 0.85;
}

.empty-state-fore-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    filter: drop-shadow(0 6px 16px rgba(102, 126, 234, 0.4));
    animation: emptyIconFloat 3s ease-in-out infinite;
}

.empty-state-fore-icon svg {
    width: 68px;
    height: 68px;
    display: block;
}

@keyframes emptyIconFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.history-list-item {
    display: flex;
    border-radius: 0;
    overflow: visible;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s, background 0.3s;
    position: relative;
    min-height: 96px;
    gap: 8px;
    background: transparent;
}

.history-list-item.history-list-item-single {
    flex-direction: row;
}

.history-list-item.is-failed {
    min-height: 60px;
}

.history-list-item.is-failed .hist-thumb {
    cursor: default !important;
}

.hist-status-badge {
    display: none;
}

.history-list-item:hover {
    transform: none;
}

.history-list-item:hover .hist-thumb {
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.1);
}

.history-list-item:hover .hist-info {
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.1);
}

.hist-thumb {
    width: 200px;
    min-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s;
}

.history-list-item.history-list-item-batch-wide {
    flex-direction: column;
    gap: 6px;
}

.history-list-item.history-list-item-batch-wide .hist-thumb {
    width: 100%;
    min-width: 0;
}

.history-list-item.history-list-item-batch-wide .hist-info {
    width: 100%;
    box-sizing: border-box;
}

/* 多图横排容器 */
.hist-thumb-multi {
    display: flex;
    flex-direction: row;
    gap: 3px;
    width: 100%;
    height: 100%;
    align-items: stretch;
}

.hist-thumb-multi-item {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}

.hist-thumb-multi-item-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    text-align: center;
    background: var(--state-idle-bg, rgba(102, 126, 234, 0.08));
    color: var(--text-secondary);
    border: 1px dashed var(--state-idle-border, rgba(102, 126, 234, 0.22));
}

.hist-thumb-multi-item-placeholder .hist-thumb-multi-placeholder-index {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.hist-thumb-multi-item-placeholder .hist-thumb-multi-placeholder-status {
    font-size: 11px;
    line-height: 1.3;
}

.hist-thumb-multi-item-placeholder[data-batch-child-status="processing"],
.hist-thumb-multi-item-placeholder[data-batch-child-status="running"] {
    background: linear-gradient(135deg, var(--state-processing-bg), var(--state-processing-bg-soft));
    border-color: var(--state-processing-border);
}

.hist-thumb-multi-item-placeholder[data-batch-child-status="queued"],
.hist-thumb-multi-item-placeholder[data-batch-child-status="pending"] {
    background: var(--state-queued-bg);
    border-color: var(--state-queued-border);
}

.hist-thumb-multi-item-placeholder[data-batch-child-status="failed"],
.hist-thumb-multi-item-placeholder[data-batch-child-status="error"],
.hist-thumb-multi-item-placeholder[data-batch-child-status="cancelled"],
.hist-thumb-multi-item-placeholder[data-batch-child-status="timeout"] {
    background: var(--state-idle-bg, rgba(102, 126, 234, 0.08));
    border-color: var(--state-failed-border, rgba(239, 68, 68, 0.35));
}

.hist-thumb-multi-item-placeholder[data-batch-child-status="failed"] .hist-thumb-multi-placeholder-status,
.hist-thumb-multi-item-placeholder[data-batch-child-status="error"] .hist-thumb-multi-placeholder-status,
.hist-thumb-multi-item-placeholder[data-batch-child-status="cancelled"] .hist-thumb-multi-placeholder-status,
.hist-thumb-multi-item-placeholder[data-batch-child-status="timeout"] .hist-thumb-multi-placeholder-status {
    color: var(--state-failed-text, #dc3545);
}

.hist-thumb.batch-thumb-squares .hist-thumb-multi-item {
    aspect-ratio: 1 / 1;
}

.hist-thumb-multi-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 全局悬浮预览图组件 */
#globalImagePreview {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    max-width: 376px;
    display: none;
}

#globalImagePreview.visible {
    opacity: 1;
    transform: translateY(0);
    display: block;
}

#globalImagePreview.hiding {
    opacity: 0;
    transform: translateY(8px);
}

#globalImagePreview * {
    pointer-events: none;
}

#globalImagePreview img,
#globalImagePreview video {
    max-width: 360px;
    max-height: 360px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
    object-fit: contain;
}

#globalImagePreview .preview-audio {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#globalImagePreview .preview-audio img {
    width: 48%;
    height: auto;
    opacity: 0.7;
}

#globalImagePreview .preview-loading {
    width: 360px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.hist-info {
    flex: 1;
    padding: 8px 12px 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
    border-radius: 10px;
    transition: box-shadow 0.2s;
}

.hist-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 1px;
}

.hist-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.hist-time {
    font-size: 10px;
    color: var(--text-secondary);
    flex-shrink: 0;
    opacity: 0.8;
}

.hist-params-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    min-height: 0;
}

.hist-params-area.is-hidden {
    display: none;
}

/* 资源行：图片/视频/音频横向排列，无标题 */
.hist-param-res-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.hist-param-img-thumb {
    width: 44px;
    height: 44px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
    background: #000;
    display: block;
}

.hist-param-img-wrap {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}

.hist-param-portrait-badge {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .28);
    pointer-events: none;
}

.hist-param-media-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 5px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    background: rgba(102, 126, 234, 0.08);
    flex-shrink: 0;
    font-size: 20px;
}

/* 文本参数行：所有tag横排，无标题 */
.hist-param-tags-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    overflow: hidden;
}

.hist-param-tag {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 1px 7px;
    border-radius: 4px;
    border: 1px solid rgba(102, 126, 234, 0.18);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* 提示词——固定到参数最后一行 */
.hist-param-prompt {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.45;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    white-space: normal;
    border-left: 2px solid rgba(102, 126, 234, 0.5);
    padding: 2px 6px;
    border-radius: 0 4px 4px 0;
    margin-top: 3px;
    flex-shrink: 0;
}

.hist-actions {
    display: flex;
    gap: 3px;
    margin-top: auto;
    padding-top: 4px;
    align-items: center;
    justify-content: space-between;
}

/* 收藏按钮样式 */
.favorite-btn {
    cursor: pointer;
    font-size: 16px;
    color: #999;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
    line-height: 1;
    padding: 2px;
}

.favorite-btn.is-favorited {
    color: #f59e0b;
}

.favorite-btn:hover {
    color: #f59e0b;
    transform: scale(1.15);
}

.hist-actions img {
    height: 18px;
    width: 18px;
    object-fit: contain;
    padding: 3px;
    border-radius: 5px;
    cursor: pointer;
    opacity: 0.6;
    background: transparent;
    transition: opacity 0.15s, background 0.15s;
    filter: var(--icon-filter);
}

.hist-actions img:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.12);
}

/* 历史记录操作区 - 复用结果图按钮（继承 .hist-actions img 样式，无需额外定义） */
/* 填入图标为浅色，需要与主题相反的反色处理 */
.hist-actions img.reuse-img-btn {
    filter: invert(1);
}

[data-theme="dark"] .hist-actions img.reuse-img-btn {
    filter: none;
}

/* 历史记录顶部弹性占位，记录较少时推到底部 */
.history-top-spacer {
    flex: 1;
    min-height: 0;
}

/* 已无更小记录提示 */
.history-no-more-tip {
    text-align: center;
    padding: 14px 0 6px;
    font-size: 11.5px;
    color: var(--text-secondary);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
    letter-spacing: 0.4px;
}

.history-no-more-tip::before,
.history-no-more-tip::after {
    content: '';
    flex: 1;
    max-width: 80px;
    height: 1px;
    background: currentColor;
    opacity: 0.3;
}

/* 日期分隔标题 */
.history-date-separator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    flex-shrink: 0;
    pointer-events: none;
}

.history-date-separator::before,
.history-date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--text-secondary);
    opacity: 0.15;
}

.history-date-separator span {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
    white-space: nowrap;
    padding: 2px 10px;
    background: var(--bg-secondary);
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* 加载更旧记录指示器 */
.load-older-indicator {
    text-align: center;
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.75;
}

.load-older-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(102, 126, 234, 0.25);
    border-top-color: rgba(102, 126, 234, 0.85);
    border-radius: 50%;
    animation: histSpinAnim 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes histSpinAnim {
    to {
        transform: rotate(360deg);
    }
}

/* Chat输入包装器 */
.chat-input-wrapper {
    max-width: 800px;
    width: calc(100% - 100px);
    margin: 0 auto;
    background: var(--shadow-medium);
    backdrop-filter: blur(30px);
    border-radius: 16px;
    padding: 16px 24px;
    box-shadow: 0 0 8px var(--scrollbar-thumb);
    position: relative;
}

/* 回到底部/清空 快捷按钮 */
.scroll-to-bottom-btn {
    position: absolute;
    top: -36px;
    right: 0;
    background: var(--bg-primary);
    backdrop-filter: blur(30px);
    border-radius: 12px;
    padding: 6px 14px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s, color 0.2s;
    white-space: nowrap;
    z-index: 10;
}

.scroll-to-bottom-btn:hover {
    color: var(--text-primary);
}

.scroll-to-bottom-btn.mode-clear:hover {
    color: var(--text-primary);
}

[data-theme="dark"] .scroll-to-bottom-btn .btn-icon-clear {
    filter: brightness(0) invert(1);
}

.scroll-to-bottom-btn.mode-scroll .btn-icon-clear {
    display: none !important;
}

.scroll-to-bottom-btn.mode-clear .btn-icon-clear {
    display: inline-block !important;
}

.scroll-to-bottom-btn .btn-label-scroll,
.scroll-to-bottom-btn .btn-label-clear {
    display: none;
}

.scroll-to-bottom-btn.mode-scroll .btn-label-scroll {
    display: inline;
}

.scroll-to-bottom-btn.mode-clear .btn-label-clear {
    display: inline;
}

/* 预设chips */
.chat-presets-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 8px 0;
    scrollbar-width: thin;
    flex-wrap: nowrap;
}

.chat-presets-row::-webkit-scrollbar {
    height: 3px;
}

.chat-presets-row::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.preset-chip {
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.preset-chip:hover {
    background: rgba(102, 126, 234, 0.12);
    border-color: #667eea;
    color: #667eea;
}

.preset-chip.active {
    background: rgba(102, 126, 234, 0.18);
    border-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

/* 可选叠加开关 */
.overlay-toggle {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.07);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2px 22px 2px 2px;
    cursor: pointer;
    user-select: none;
    transition: background .2s, padding .2s;
}

.overlay-toggle.on {
    background: rgba(102, 126, 234, 0.15);
    padding: 2px 2px 2px 22px;
}

.overlay-toggle-knob {
    padding: 3px 10px;
    background: #bbb;
    color: #fff;
    border-radius: 18px;
    font-size: 12px;
    white-space: nowrap;
    font-weight: 500;
    transition: background .2s;
    pointer-events: none;
}

.overlay-toggle.on .overlay-toggle-knob {
    background: #667eea;
}

/* 上传区域 */
.chat-uploads-zone {
    position: absolute;
    top: -80px;
    display: flex;
    gap: 10px;
    max-width: calc(100vw - 32px);
    transform-origin: left bottom;
}

/* 输入行：上传区在左，textarea在右 */
.chat-input-row {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

/* 输入列：tab头部+presets+textarea 纵向排列 */
.chat-input-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-upload-item {
    flex-shrink: 0;
}

.chat-upload-item .file-upload-container {
    margin-bottom: 0;
}

.chat-upload-item .file-upload-area {
    height: 96px;
    width: 64px;
    border-radius: 10px;
    padding: 4px;
    min-height: unset;
}

.chat-upload-item .file-upload-area.has-file {
    min-height: unset;
}

.chat-upload-item .file-preview {
    max-height: 64px;
    max-width: 48px;
    object-fit: cover;
}

.chat-upload-item .file-type-icon {
    font-size: 15px;
    margin-bottom: 4px;
}

.chat-upload-item .file-upload-text {
    font-size: 9px;
}

.chat-upload-item .file-change-btn {
    font-size: 9px;
    padding: 1px 3px;
}

/* 多图上传网格在 chat UI 内的布局（脱离原有 .form-group.has-multiple-uploads 父级） */
.chat-upload-item .uploads-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
}

.chat-upload-item .upload-item-wrapper {
    min-height: unset;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.chat-upload-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    display: block;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

/* Tab切换（文本参数）—— 分组容器风格，区别于 preset-chip 标签 */
.chat-tab-header {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.18);
    border-radius: 10px;
    padding: 3px;
    width: fit-content;
    max-width: 100%;
    margin-top: 20px;
    margin-bottom: -20px;
}

.chat-tab-btn {
    padding: 4px 13px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-tab-btn:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-primary);
}

.chat-tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

/* 主文本输入框 */
.chat-main-input {
    width: 100% !important;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    resize: none !important;
    font-size: 14px;
    line-height: 1.5;
    min-height: 90px;
    max-height: 30vh;
    overflow-y: auto;
    margin-top: 20px;
    padding: 4px 4px !important;
    color: var(--text-primary) !important;
    font-family: inherit;
    box-shadow: none !important;
    margin-bottom: 0;
    transition: height 0.15s ease;
}

/* 提示词优化按钮（输入框右上角） */
.chat-optimize-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s;
    z-index: 5;
}

.chat-optimize-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.45);
}

.chat-optimize-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.3);
}

.chat-optimize-btn i {
    font-size: 11px;
}

.chat-optimize-btn .spinning {
    animation: optimizeSpin 0.8s linear infinite;
}

@keyframes optimizeSpin {
    to {
        transform: rotate(360deg);
    }
}

.chat-main-input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.at-mention-editor {
    white-space: pre-wrap;
    word-break: break-word;
}

.at-mention-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
}

.at-portrait-token {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 180px;
    margin: 0 2px;
    padding: 2px 7px 2px 3px;
    border: 1px solid rgba(122, 182, 255, .35);
    border-radius: 999px;
    background: rgba(122, 182, 255, .13);
    color: var(--text-primary);
    vertical-align: baseline;
    user-select: none;
}

.at-portrait-token img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.at-portrait-token .at-token-fallback {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3a7bd5, #00d2ff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.at-portrait-token .at-token-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-param-prompt .hist-at-portrait-token,
.hist-param-tag .hist-at-portrait-token {
    max-width: 150px;
    margin: 0 2px 2px 0;
    vertical-align: middle;
}

/* 底部参数行 */
.chat-bottom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-params-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}

.chat-param-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-send-action-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chat-param-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 自定义下拉选择器 */
.csel-wrap {
    position: relative;
    display: inline-block;
}

.csel-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.22);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    max-width: 150px;
    user-select: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.csel-trigger:hover {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(102, 126, 234, 0.14);
}

.csel-trigger.open {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.18);
    background: rgba(102, 126, 234, 0.14);
}

.csel-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}

.csel-arrow {
    flex-shrink: 0;
    transition: transform 0.2s;
    color: #667eea;
}

.csel-trigger.open .csel-arrow {
    transform: rotate(180deg);
}

.csel-dropdown {
    position: fixed;
    min-width: 100%;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(102, 126, 234, 0.22);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(102, 126, 234, 0.08);
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.16s, transform 0.16s;
    overflow-y: auto;
    max-height: 50%;
}

.csel-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.csel-dropdown::-webkit-scrollbar {
    width: 4px;
}

.csel-dropdown::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.csel-option {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.csel-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 3px;
}

/* 功能切换图标：使用 mask+currentColor 自动适配深/浅主题 */
.csel-icon.csel-icon-mask {
    display: inline-block;
    background: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    vertical-align: middle;
}

.csel-option:hover {
    background: rgba(102, 126, 234, 0.1);
}

.csel-option.selected {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    font-weight: 600;
}

/* 预览图网格下拉样式 */
.csel-dropdown.grid-mode {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    padding: 10px;
    max-width: 320px;
    white-space: normal;
}

.csel-option.grid-item {
    flex-direction: column;
    padding: 6px;
    border-radius: 8px;
    text-align: center;
}

.csel-option.grid-item .csel-preview-img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 4px;
}

.csel-option.grid-item .csel-preview-label {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csel-option.grid-item:hover {
    background: rgba(102, 126, 234, 0.12);
}

.csel-option.grid-item.selected {
    background: rgba(102, 126, 234, 0.22);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.5);
}

.csel-option.grid-item.selected .csel-preview-label {
    color: #667eea;
    font-weight: 600;
}

[data-theme="dark"] .csel-option.grid-item.selected {
    background: rgba(102, 126, 234, 0.3);
}

.csel-wrap.task-switcher .csel-trigger {
    font-weight: 600;
    color: var(--accent-primary, #667eea);
    border-color: rgba(102, 126, 234, 0.38);
    background: rgba(102, 126, 234, 0.12);
}

.csel-wrap.compact-batch .csel-trigger {
    padding: 5px 8px;
    border-radius: 16px;
    font-size: 12px;
    gap: 4px;
    border-radius: 0 20px 20px 0;
    height: 30px;
    padding-left: 22px;
    margin-left: -22px;
    border-left: none;
}

/* 暗色主题自定义下拉 */
[data-theme="dark"] .csel-trigger {
    background: rgba(102, 126, 234, 0.12);
    border-color: rgba(102, 126, 234, 0.28);
}

[data-theme="dark"] .csel-trigger:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
}

[data-theme="dark"] .csel-dropdown {
    background: rgba(24, 24, 40, 0.65);
    border-color: rgba(102, 126, 234, 0.28);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .csel-option:hover {
    background: rgba(102, 126, 234, 0.18);
}

[data-theme="dark"] .csel-option.selected {
    background: rgba(102, 126, 234, 0.25);
}

[data-theme="dark"] .csel-icon:not(.csel-icon-mask) {
    filter: none;
}

/* 小数字输入框 */
.chat-param-number {
    width: 64px;
    padding: 5px 8px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.22);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.chat-param-number:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

/* 发送按钮（图标式） */
.chat-send-btn {
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    width: 70px;
    height: 42px;
    padding: 0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 19px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.chat-send-btn.chat-send-btn-batch {
    width: 60px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(102, 126, 234, 0.45);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 算力消耗徽章 */
.send-cost-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #f59e0b 0%, #f57e00 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 2px;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.55);
    pointer-events: none;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

/* 按钮禁用时徽章变灰暗，明确与可用状态区分 */
.chat-send-btn:disabled .send-cost-badge {
    background: linear-gradient(135deg, #b0bec5 0%, #90a4ae 100%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    color: rgba(255, 255, 255, 0.85);
    text-shadow: none;
}

/* 暗色主题 */
[data-theme="dark"] .chat-main-input {
    color: var(--text-primary);
}

[data-theme="dark"] .preset-chip {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

[data-theme="dark"] .preset-chip:hover {
    background: rgba(102, 126, 234, 0.2);
    color: var(--accent-primary, #667eea);
}

/* 响应式 */
@media (max-width: 768px) {
    #historyArea .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 6px;
    }

    #historyArea {
        padding: 6px 8px 4px;
    }

    .chat-upload-item .file-upload-area {
        height: 52px;
        width: 52px;
    }

    .chat-main-input {
        font-size: 13px;
    }

    .chat-uploads-zone {
        top: -58px;
        max-width: calc(100vw - 16px);
    }

    /* ===== 手机端适配 ===== */
    /* body 高度用动态视口高度，避免移动端浏览器地址栏影响 */
    html,
    body {
        height: 100% !important;
        height: -webkit-fill-available !important;
    }

    body {
        height: 100dvh !important;
    }

    /* 输入区域紧凑化，兼容 iOS 底部安全区 */
    #inputArea {
        padding: 6px 0 !important;
        padding-bottom: max(6px, env(safe-area-inset-bottom)) !important;
    }

    /* 输入框 wrapper 缩减内边距 */
    .chat-input-wrapper {
        width: 90%;
        padding: 8px 10px;
        border-radius: 12px;
    }

    /* 主输入框高度缩减 */
    .chat-main-input {
        min-height: 56px;
        max-height: 30vh;
    }

    /* 发送按钮略微缩小 */
    .chat-send-btn {
        width: 56px;
        height: 38px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .chat-send-btn.chat-send-btn-batch {
        width: 50px;
    }

    .csel-wrap.compact-batch .csel-trigger {
        height: 26px;
    }

    /* 底部参数行横向滚动，防止换行挤占空间 */
    .chat-bottom-row {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
    }

    .chat-bottom-row::-webkit-scrollbar {
        display: none;
    }

    .chat-params-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        flex-shrink: 0;
    }

    /* 自定义下拉框在手机端字体缩小 */
    .csel-trigger {
        font-size: 11px;
        padding: 4px 8px;
        max-width: 110px;
    }

    .chat-param-label {
        font-size: 10px;
    }

    .chat-param-number {
        width: 52px;
        font-size: 11px;
    }

    /* 历史记录列表留底 padding 由 JavaScript 根据底部区域高度动态计算 */
    /* 缩小缩略图，节省宽度 */
    .hist-thumb {
        min-width: 90px;
        width: 90px;
    }

    /* 提示词字体缩小一号，移动端限1行 */
    .hist-param-prompt {
        font-size: 13px;
        -webkit-line-clamp: 1;
    }

    /* 历史列表项整体缩小间距 */
    .history-list-item {
        gap: 6px;
    }

    .hist-info {
        padding: 6px 8px 4px 6px;
    }

    /* 回到底部按钮在手机上更小 */
    .scroll-to-bottom-btn {
        font-size: 11px;
        padding: 4px 10px;
    }

    /* 上传图标区手机端略微缩小 */
    .chat-upload-item .file-upload-area {
        width: 52px;
    }

    /* preset chips 在手机上更紧凑 */
    .preset-chip {
        font-size: 11px;
        padding: 2px 8px;
    }

    /* tab 按钮更紧凑 */
    .chat-tab-btn {
        padding: 3px 9px;
        font-size: 11px;
    }
}