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

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

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 主布局 */
.main-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* 左侧列 */
.left-column {
    flex: 1;
    max-width: 600px;
}

/* 右侧列 */
.right-column {
    flex: 1;
    max-width: 600px;
}

/* 上传区域 */
.upload-section {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background-color: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-area:hover {
    border-color: #6366f1;
    background-color: #f8fafc;
}

.upload-area.dragover {
    border-color: #6366f1;
    background-color: #eff6ff;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
}

.upload-hint {
    font-size: 14px;
    color: #6b7280;
}

.image-preview-container {
    position: relative;
    width: 100%;
    min-height: 400px;
}

/* 图片网格布局 */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

/* 单张图片预览 */
.single-image-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.single-image-preview .image-item {
    position: relative;
    max-width: 400px;
    width: 100%;
    aspect-ratio: auto;
}

/* 每个图片预览项 */
.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background-color: white;
    transition: all 0.2s ease;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
}

.image-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background-color: rgba(239, 68, 68, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.delete-btn:active {
    transform: scale(0.95);
}

/* 上传操作区域 */
.upload-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.replace-btn, .clear-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.replace-btn {
    background-color: #6366f1;
    color: white;
}

.replace-btn:hover {
    background-color: #5856eb;
    transform: translateY(-1px);
}

.clear-btn {
    background-color: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.clear-btn:hover {
    background-color: #ef4444;
    color: white;
    transform: translateY(-1px);
}

/* 编辑器区域 */
.editor-section {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
}

/* 尺寸控制区域 */
.size-controls-section {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.size-controls-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1f2937;
}

.editor-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1f2937;
}

.textarea-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.textarea-container textarea {
    flex: 1;
    height: 120px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: vertical;
    font-size: 14px;
    font-family: inherit;
    background-color: #f9fafb;
    transition: all 0.2s ease;
}

.textarea-container textarea:focus {
    outline: none;
    border-color: #6366f1;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.textarea-container textarea::placeholder {
    color: #9ca3af;
}

/* 控制区域 */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analysis-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #6b7280;
}

.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.editor-header h3 {
    margin: 0;
}

.regenerate-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.regenerate-btn:hover {
    background-color: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.regenerate-btn:active {
    transform: translateY(0);
}

.regenerate-btn svg {
    width: 14px;
    height: 14px;
}

.regenerate-btn:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
    transform: none;
}

.regenerate-btn:disabled:hover {
    background-color: #f9fafb;
    color: #9ca3af;
    border-color: #e5e7eb;
    transform: none;
}

.size-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 14px;
    color: #6b7280;
    background-color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.aspect-ratio-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aspect-ratio-section label {
    font-weight: 500;
    color: #374151;
    min-width: 60px;
}

.aspect-ratio-section select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.aspect-ratio-section select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.size-input-section {
    display: flex;
    gap: 12px;
    transition: all 0.3s ease;
}

.size-input-section.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.size-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.size-input-group label {
    font-weight: 500;
    color: #374151;
    min-width: 40px;
}

.size-input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    transition: all 0.2s ease;
    text-align: center;
}

.size-input-group input:focus {
    outline: none;
    border-color: #6366f1;
    background-color: #f8fafc;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.size-input-group input:invalid {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.size-input-group input:read-only {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.size-display {
    text-align: center;
    font-weight: 600;
    color: #6366f1;
    background-color: white;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

/* AI生成区域 */
.generation-section {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
}

.generation-header {
    margin-bottom: 24px;
}

.generation-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1f2937;
}

.ai-generate-btn {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-generate-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.ai-generate-btn:active {
    transform: translateY(0);
}

.ai-generate-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.generation-hint {
    font-size: 14px;
    color: #6b7280;
}

.result-area {
    min-height: 300px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background-color: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.result-area.loading {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.result-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.loading-text {
    color: #6b7280;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.placeholder-text {
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
}

/* 设置按钮 */
.settings-btn-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.settings-btn {
    width: 48px;
    height: 48px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.settings-btn:hover {
    background-color: white;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.settings-btn svg {
    width: 24px;
    height: 24px;
    color: #6b7280;
    transition: all 0.3s ease;
}

.settings-btn:hover svg {
    color: #6366f1;
    transform: rotate(90deg);
}

/* 设置弹窗 */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background-color: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
}

.settings-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
}

.close-btn {
    width: 32px;
    height: 32px;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: #f3f4f6;
    color: #374151;
}

/* 设置标签页 */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin: 0 24px;
}

.tab-btn {
    flex: 1;
    padding: 16px 24px;
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #374151;
    background-color: #f9fafb;
}

.tab-btn.active {
    color: #6366f1;
    border-bottom-color: #6366f1;
}

/* 标签内容 */
.tab-content {
    display: none;
    padding: 24px;
}

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

/* 表单样式 */
.form-group {
    margin-bottom: 24px;
}

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

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #f9fafb;
}

.input-group input {
    padding-right: 48px;
}

.form-group input:focus {
    outline: none;
    border-color: #6366f1;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.toggle-password:hover {
    background-color: #f3f4f6;
}

/* 设置操作按钮 */
.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.save-btn, .test-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn {
    background-color: #6366f1;
    color: white;
}

.save-btn:hover {
    background-color: #5856eb;
    transform: translateY(-1px);
}

.test-btn {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.test-btn:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}

/* 历史记录样式 */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.clear-history-btn {
    padding: 8px 16px;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.history-item:hover {
    background-color: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
}

.history-details {
    flex: 1;
    min-width: 0;
}

.history-prompt {
    font-size: 14px;
    color: #374151;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    font-size: 12px;
    color: #6b7280;
}

.history-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-action-btn {
    padding: 4px 8px;
    background-color: transparent;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.history-action-btn:hover {
    background-color: #f3f4f6;
}

.history-action-btn.delete {
    color: #ef4444;
    border-color: #ef4444;
}

.history-action-btn.delete:hover {
    background-color: #fef2f2;
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

/* 响应式设计 */
@media (max-width: 968px) {
    .main-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .left-column, .right-column {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .textarea-container {
        flex-direction: column;
    }
    
    .size-input-section {
        flex-direction: column;
        gap: 8px;
    }
    
    .aspect-ratio-section {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .aspect-ratio-section label {
        min-width: auto;
        text-align: center;
    }
    
    .size-input-group {
        justify-content: space-between;
    }
    
    .size-input-group label {
        min-width: 50px;
    }
    
    .generation-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    /* 移动端图片网格适配 */
    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .upload-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .replace-btn, .clear-btn {
        width: 100%;
        padding: 12px;
    }
    
    /* 移动端设置弹窗适配 */
    .settings-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
    }
    
    .settings-header {
        padding: 16px 16px 0;
    }
    
    .settings-tabs {
        margin: 0 16px;
    }
    
    .tab-content {
        padding: 16px;
    }
    
    .settings-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .save-btn, .test-btn {
        width: 100%;
    }
    
    .history-item {
        flex-direction: column;
        gap: 8px;
    }
    
    .history-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
}

/* 图片预览模态框 */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview-modal.show {
    display: block;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: 90vw;
    max-height: 90vh;
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
}

.image-preview-modal.show .modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: #f3f4f6;
    color: #374151;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.modal-info {
    margin-top: 15px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* 图片hover效果提示 */
.image-item {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-item:hover {
    transform: scale(1.02);
}

.image-item::after {
    content: '双击查看';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

.image-item:hover::after {
    opacity: 1;
}