* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.input-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.input-group { margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #333; }

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group textarea { height: 100px; resize: vertical; }

.param-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.buttons { display: flex; gap: 15px; margin-bottom: 20px; }

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: white; flex: 1; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3); }

.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; transform: translateY(-2px); }

.btn-light {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}
.btn-light:hover {
    background: #e9ecef;
    border-color: #ced4da;
    transform: translateY(-1px);
}

.file-upload { position: relative; display: inline-block; width: 100%; }
.file-upload input[type="file"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-upload-label {
    display: block; padding: 12px; background: #f8f9fa; border: 2px dashed #ddd; border-radius: 8px;
    text-align: center; cursor: pointer; transition: all 0.3s ease;
}
.file-upload:hover .file-upload-label { border-color: #667eea; background: #f0f2ff; }

#imagePreview { position: relative; display: inline-block; }
.delete-image-btn {
    position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
    background: #dc3545; color: white; border: 2px solid white; font-size: 14px; font-weight: bold; cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; z-index: 10;
    transition: all 0.3s ease;
}
.delete-image-btn:hover { background: #c82333; transform: scale(1.1); }

.result-section {
    background: #f8f9fa; padding: 25px; border-radius: 15px; border: 2px solid #e9ecef; text-align: center;
}

.generated-image {
    max-width: 100%; max-height: 400px; border-radius: 10px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); margin-bottom: 15px;
}

.loading { display: none; padding: 20px; }
.loading.show { display: block; }
.spinner {
    border: 4px solid #f3f3f3; border-top: 4px solid #667eea; border-radius: 50%; width: 40px; height: 40px;
    animation: spin 1s linear infinite; margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 实时日志面板 */
.log-panel {
    text-align: left; margin-top: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px; border-radius: 8px; padding: 10px;  max-height: 450px; overflow: auto;
    background: #f8f9fa; color: #6c757d; border: 1px dashed #e9ecef;
    transition: all 0.3s ease;
}
.log-panel.active {
    background: #0f172a; color: #e2e8f0; border: 1px solid #1e293b;
}
.log-actions { display: flex; gap: 10px; margin-top: 8px; justify-content: flex-end; }
.log-line { white-space: pre-wrap; margin: 2px 0; }
.log-info { color: #93c5fd; }
.log-warn { color: #facc15; }
.log-error { color: #fda4af; }

.history-section { margin-top: 30px; background: #f8f9fa; padding: 25px; border-radius: 15px; border: 2px solid #e9ecef; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; margin-top: 20px; }
.history-item { background: white; padding: 15px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease; }
.history-item:hover { transform: translateY(-5px); }
.history-item {
    position: relative; /* For checkbox positioning */
    border: 2px solid transparent;
}
.history-item.selected {
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}
.history-item-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-actions { display: flex; gap: 10px; }
.history-image { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }
.history-prompt { font-size: 12px; color: #666; word-break: break-word; }
.history-time { font-size: 10px; color: #999; margin-top: 5px; }
.history-logs details { margin-top: 8px; }
.history-logs pre {
    background: #0f172a; color: #e2e8f0; padding: 8px; border-radius: 6px; font-size: 11px;
    max-height: 200px; overflow: auto; border: 1px solid #1e293b;
}

.error { color: #dc3545; background: #f8d7da; padding: 10px; border-radius: 5px; margin-top: 10px; display: none; }
.error.show { display: block; }
.success { color: #155724; background: #d4edda; padding: 10px; border-radius: 5px; margin-top: 10px; display: none; }
.success.show { display: block; }

@media (max-width: 768px) {
    .main-content { grid-template-columns: 1fr; }
    .param-grid { grid-template-columns: 1fr; }
    .history-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}