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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    margin-bottom: 24px;
    color: #333;
}

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

/* 并排布局 */
.form-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.form-row .seed-group {
    flex: 0 0 140px;
}

.form-row .seed-group input[type="number"] {
    width: 100%;
}

.form-row .image-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

input[type="file"] {
    padding: 8px 0;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.error {
    color: #d32f2f;
    font-size: 14px;
    margin-top: 4px;
    display: none;
}

.error.visible {
    display: block;
}

button {
    background: #1976d2;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #1565c0;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.visible {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result {
    display: none;
    margin-top: 24px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.result.visible {
    display: block;
}

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

.result-info {
    margin-top: 12px;
    font-size: 14px;
    color: #666;
}

.global-error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.global-error.visible {
    display: block;
}

.config-section {
    background: #f5f5f5;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.config-section h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
}

.config-item {
    margin-bottom: 8px;
    font-size: 14px;
}

.config-item label {
    display: inline;
    font-weight: 600;
    color: #555;
    margin-right: 8px;
}

.config-item span {
    color: #333;
    font-family: monospace;
    word-break: break-all;
}

.debug-info {
    display: none;
    margin-top: 24px;
    padding: 20px;
    background: #fff3e0;
    border-radius: 8px;
    border: 1px solid #ff9800;
}

.debug-info.visible {
    display: block;
}

.debug-info h2 {
    color: #e65100;
    margin-bottom: 12px;
}

.debug-info pre {
    background: #fff8e1;
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    border: 1px solid #ffe0b2;
}

/* 图片并排显示区域 */
.images-display {
    display: none;
    margin-top: 30px;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
}

.images-display.visible {
    display: flex;
}

/* 上传图片预览区域 */
.image-preview-section {
    display: none;
}

.image-preview-section.visible {
    display: block;
}

.image-preview-section img {
    width: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 结果区域 */
.result-section {
    display: none;
}

.result-section.visible {
    display: block;
}

.result-section img {
    width: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.result-section .result-info {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* 模式选择单选框 */
.mode-group .radio-group {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
}

.radio-label input[type="radio"] {
    margin-right: 6px;
    cursor: pointer;
}

.radio-label span {
    color: #555;
    font-size: 14px;
}

.radio-label:hover span {
    color: #1976d2;
}

/* Navigation Header */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.nav-header h1 {
    margin-bottom: 0;
}

.nav-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-link {
    color: #1976d2;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border: 1px solid #1976d2;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: #1976d2;
    color: white;
}

/* Admin navigation specific styles */
.admin-nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-nav a {
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.admin-nav a:hover,
.admin-nav a.active {
    background-color: #007bff;
    color: white;
}

/* Responsive navigation */
@media (max-width: 768px) {
    .nav-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .nav-links,
    .admin-nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .nav-link,
    .admin-nav a {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Template Actions Section */
.template-actions {
    margin-top: 30px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
    border: 2px dashed #ccc;
}

.template-actions h3 {
    margin-bottom: 12px;
    color: #333;
}

.template-input-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.template-input-row input[type="text"] {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.template-input-row button {
    padding: 10px 20px;
    font-size: 14px;
}

.save-status {
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

.save-status.success {
    color: #2e7d32;
}

.save-status.error {
    color: #d32f2f;
}

/* Dynamic Form Styles */
.api-selector-group {
    margin-bottom: 24px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.api-selector-group label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
    display: block;
    font-size: 16px;
}

.api-selector-group select {
    width: 100%;
    max-width: 500px;
    padding: 12px 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.api-selector-group select:hover {
    border-color: #80bdff;
}

.api-selector-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

.refresh-api-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-api-btn:hover:not(:disabled) {
    background: #f57c00;
}

.refresh-api-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.dynamic-field {
    margin-bottom: 20px;
    padding: 16px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.dynamic-field label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-container input[type="range"] {
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.range-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #1976d2;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.range-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #1976d2;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    border: none;
}

.range-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #1976d2;
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

#dynamic-form-container {
    margin-bottom: 20px;
}

/* 新的动态表单布局样式 */
.prompt-container {
    margin-bottom: 20px;
}

.prompt-field {
    width: 100%;
    margin-bottom: 16px;
}

.prompt-field textarea {
    width: 100%;
    min-width: 400px;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.prompt-field textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Textarea character counter */
.textarea-wrapper {
    position: relative;
    width: 100%;
}
.char-counter {
    text-align: right;
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    padding-right: 4px;
}
.char-counter.near-limit {
    color: #ffc107;
}
.char-counter.over-limit {
    color: #dc3545;
    font-weight: 600;
}

.compact-fields-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.compact-field {
    flex: 1;
    min-width: 180px;
    margin-bottom: 8px;
}

.compact-field input[type="file"],
.compact-field input[type="number"],
.compact-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.compact-field input[type="file"]:focus,
.compact-field input[type="number"]:focus,
.compact-field select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.compact-field .range-container {
    width: 100%;
}

/* Enhance panel (collapsible) */
.enhance-panel {
    margin-top: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.enhance-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    user-select: none;
}
.enhance-toggle:hover {
    filter: brightness(1.05);
}
.enhance-toggle-icon {
    font-size: 10px;
    transition: transform 0.2s;
}
.enhance-content {
    padding: 16px;
    background: #fafbff;
}
.enhance-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 24px;
}
.enhance-field {
    margin-bottom: 0 !important;
}
.enhance-field label {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}
.enhance-field .range-container {
    display: flex;
    align-items: center;
    gap: 8px;
}
.enhance-field .range-container input[type="range"] {
    flex: 1;
    height: 6px;
}
.enhance-field .range-value {
    min-width: 36px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
}
.enhance-reset-btn {
    margin-top: 12px;
    padding: 4px 12px;
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}
.enhance-reset-btn:hover {
    background: #e0e0e0;
}

/* 动态表单动画效果 */
.dynamic-field {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Templates Gallery Page */
.templates-info {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #e3f2fd;
    border-radius: 4px;
    color: #1976d2;
}

.templates-info p {
    margin: 0;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.template-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.template-images {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #f5f5f5;
}

.template-images img {
    width: calc(50% - 4px);
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    background: #ddd;
}

.template-content {
    padding: 16px;
}

.template-card h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
    word-break: break-word;
}

.template-prompt {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.template-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.mode-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 4px;
    font-size: 12px;
}

.seed-info {
    font-size: 12px;
    color: #888;
}

.template-date {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 12px;
}

.template-actions-card {
    display: flex;
    gap: 8px;
}

.template-actions-card button {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.use-template-btn {
    background: #1976d2;
    color: white;
}

.use-template-btn:hover {
    background: #1565c0;
}

.delete-template-btn {
    background: #f5f5f5;
    color: #d32f2f;
    border: 1px solid #e0e0e0 !important;
}

.delete-template-btn:hover {
    background: #ffebee;
}

/* Test Template Button */
.test-template-btn {
    background: #4caf50;
    color: white;
}

.test-template-btn:hover {
    background: #388e3c;
}

/* Update Template Button */
#update-template-btn {
    background: #ff9800;
    color: white;
}

#update-template-btn:hover {
    background: #f57c00;
}

/* Mode-specific options */
.mode-options {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 4px;
    margin-top: -10px;
    margin-bottom: 20px;
}

.mode-options label {
    font-weight: 600;
    color: #333;
}

.mode-options .radio-group {
    margin-top: 8px;
}

.mode-options input[type="number"] {
    width: 100%;
    max-width: 200px;
    margin-top: 8px;
}

/* Logout Button */
.logout-btn {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
    padding: 8px 16px;
    font-size: 14px;
    margin-left: 10px;
}

.logout-btn:hover {
    background: #ffebee;
    color: #d32f2f;
}

/* ==========================================
   Edit Template Page Styles
   ========================================== */

/* Edit Section Layout */
#edit-section {
    margin-top: 20px;
}

/* Edit Header */
.edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
}

.edit-header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.edit-actions {
    display: flex;
    gap: 12px;
}

/* Button Styles */
.btn-primary,
.btn-secondary,
.btn-success {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #1976d2;
    color: white;
}

.btn-primary:hover {
    background: #1565c0;
}

.btn-secondary {
    background: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #388e3c;
}

/* Message Area */
.message {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.message.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.message.error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Template Metadata */
.template-meta {
    background: #f5f5f5;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.template-meta p {
    margin: 8px 0;
    font-size: 14px;
    color: #555;
}

.template-meta strong {
    color: #333;
    display: inline-block;
    width: 100px;
}

/* Form Section */
.form-section {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.form-section h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #333;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

/* Form Group */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    max-width: 400px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.help-text {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #888;
}

/* Image Preview Section */
.image-preview-section {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.image-preview-box {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.image-preview-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.image-preview-box img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
}

/* Reference Images Grid */
.reference-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.reference-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.reference-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reference-image-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: #d32f2f;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.reference-image-delete:hover {
    background: #ffebee;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #1976d2;
    background: #e3f2fd;
}

.upload-area span {
    color: #666;
    font-size: 14px;
}

/* Multi-file Preview Styles */
.file-preview-container {
    margin-top: 12px;
}

.file-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.file-preview-item {
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
}

.file-preview-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.file-preview-icon {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: #f0f0f0;
}

.file-preview-info {
    padding: 8px;
    font-size: 12px;
    background: white;
}

.file-preview-info .file-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
    margin-bottom: 2px;
}

.file-preview-info .file-size {
    color: #666;
    font-size: 11px;
}

.file-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: #d32f2f;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.file-remove-btn:hover {
    background: #ffebee;
}

.file-preview-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
    border: 1px dashed #ddd;
    border-radius: 8px;
}

/* Parameter Grid */
.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Progressive Image Upload Styles */
.progressive-upload {
    width: 100%;
}

.pu-row-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pu-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pu-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
}

.pu-thumb--empty {
    background: #f0f0f0;
    border: 1px dashed #ccc;
}

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

.pu-file-input {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}

.pu-remove-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: #f5f5f5;
    color: #d32f2f;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.pu-remove-btn:hover {
    background: #ffebee;
}

.pu-add-btn {
    margin-top: 6px;
    width: 32px;
    height: 32px;
    border: 2px dashed #bbb;
    border-radius: 6px;
    background: #fafafa;
    color: #555;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.pu-add-btn:hover {
    border-color: #1976d2;
    background: #e3f2fd;
    color: #1976d2;
}

.pu-count {
    margin-top: 4px;
    font-size: 12px;
    color: #888;
    text-align: right;
}

/* ============================================================
   Asset Picker Modal
   ============================================================ */
.asset-picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.asset-picker-overlay.active {
    display: flex;
}
.asset-picker-modal {
    background: #fff;
    border-radius: 12px;
    width: min(90vw, 860px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
}
.asset-picker-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.asset-picker-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}
.asset-picker-header .close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    line-height: 1;
}
.asset-picker-header .close-btn:hover { color: #333; }
.asset-picker-filters {
    padding: 10px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.asset-picker-filters .filter-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.asset-picker-filters .filter-btn:hover { border-color: #1976d2; color: #1976d2; }
.asset-picker-filters .filter-btn.active {
    background: #1976d2;
    border-color: #1976d2;
    color: #fff;
}
.asset-picker-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.asset-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.asset-picker-item {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    background: #fafafa;
    position: relative;
}
.asset-picker-item:hover { border-color: #1976d2; transform: translateY(-1px); }
.asset-picker-item.selected { border-color: #1976d2; background: #e3f2fd; }
.asset-picker-item.selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    background: #1976d2;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.asset-picker-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #eee;
}
.asset-picker-item .asset-name {
    padding: 5px 6px;
    font-size: 11px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.asset-picker-item .asset-category {
    padding: 0 6px 5px;
    font-size: 10px;
    color: #999;
}
.asset-picker-empty {
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-size: 14px;
}
.asset-picker-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.asset-picker-footer .selection-info {
    font-size: 13px;
    color: #666;
}
.asset-picker-footer .footer-actions {
    display: flex;
    gap: 10px;
}
.asset-picker-footer .cancel-btn {
    padding: 8px 18px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.asset-picker-footer .confirm-btn {
    padding: 8px 18px;
    background: #1976d2;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}
.asset-picker-footer .confirm-btn:disabled { background: #90caf9; cursor: not-allowed; }

/* Asset picker trigger button */
.asset-picker-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.asset-picker-trigger .pick-btn {
    padding: 6px 14px;
    border: 1px dashed #1976d2;
    border-radius: 6px;
    background: #f0f7ff;
    color: #1976d2;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
}
.asset-picker-trigger .pick-btn:hover { background: #e3f2fd; }
.asset-picker-selected-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.asset-picker-selected-previews .selected-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}
.asset-picker-selected-previews .selected-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.asset-picker-selected-previews .selected-thumb .remove-thumb {
    position: absolute;
    top: -1px;
    right: -1px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 0 4px 0 4px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
