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

:root {
  --pink: #f8c8dc;
  --pink-light: #fce4ec;
  --yellow: #fff3cd;
  --yellow-light: #fff8e1;
  --blue: #b3d9f2;
  --blue-light: #e3f2fd;
  --purple-light: #f3e5f5;
  --text: #3d2b3d;
  --text-light: #7a5a7a;
  --card-bg: #ffffff;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #fdf6f0 0%, #f0f4fd 50%, #f5f0fd 100%);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.6;
}

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

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 0 32px;
}

.header-icon {
  font-size: 36px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.header h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #e87ea0, #b388ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-light);
  font-size: 15px;
  margin-top: 6px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,0.04);
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: #f0f0f0;
  border-radius: var(--radius-sm);
}

.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover {
  background: rgba(255,255,255,0.5);
}

.mode-btn.active {
  background: white;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.input-mode {
  animation: fadeIn 0.3s ease;
}

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

/* Textarea */
#customPrompt, #imageInstruction {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 0.2s;
  outline: none;
  resize: vertical;
}

#customPrompt:focus, #imageInstruction:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
}

#customPrompt::placeholder, #imageInstruction::placeholder {
  color: #bbb;
}

/* Input Section */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}

#topic {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: border-color 0.2s;
  outline: none;
}

#topic:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
}

#topic::placeholder {
  color: #bbb;
}

/* Custom Ratio Select */
.custom-select {
  position: relative;
  width: 100%;
}

.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  background: #fafafa;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.2s;
}

.select-trigger:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.custom-select.open .select-trigger {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
  background: white;
}

.select-arrow {
  margin-left: auto;
  font-size: 10px;
  color: #999;
  transition: transform 0.2s;
}

.custom-select.open .select-arrow {
  transform: rotate(180deg);
}

.select-label {
  font-weight: 500;
}

.select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: white;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
}

.select-dropdown.open {
  display: block;
}

.select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.select-option:hover {
  background: var(--blue-light);
}

.select-option.selected {
  background: var(--pink-light);
}

.option-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* Ratio shapes in selects */
.custom-select .ratio-shape {
  display: block;
  width: 32px;
  height: auto;
  border-radius: 3px;
  background: #999;
  flex-shrink: 0;
}

.select-option.selected .ratio-shape {
  background: var(--pink);
}

.select-option:hover .ratio-shape {
  background: var(--blue);
}

.shape-16-9 { aspect-ratio: 16 / 9; }
.shape-4-3  { aspect-ratio: 4 / 3; }
.shape-1-1  { aspect-ratio: 1 / 1; }
.shape-3-4  { aspect-ratio: 3 / 4; }
.shape-9-16 { aspect-ratio: 9 / 16; }

/* Style Grid */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  max-width: 100%;
}

.style-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.style-option:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.style-option.selected {
  border-color: var(--pink);
  background: var(--pink-light);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
}

/* Prompt mode style options - same styling */
.style-option-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.style-option-prompt:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.style-option-prompt.selected {
  border-color: var(--pink);
  background: var(--pink-light);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
}

/* Image mode style options */
.style-option-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid #eee;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.style-option-image:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.style-option-image.selected {
  border-color: var(--pink);
  background: var(--pink-light);
  box-shadow: 0 0 0 3px rgba(248, 200, 220, 0.3);
}

/* Upload Area */
.upload-area {
  width: 100%;
  min-height: 200px;
  border: 2px dashed #ddd;
  border-radius: var(--radius-sm);
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.upload-area:hover {
  border-color: var(--pink);
  background: var(--pink-light);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
  padding: 20px;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-placeholder p {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-placeholder small {
  font-size: 12px;
  color: var(--text-light);
}

.image-preview {
  position: relative;
  width: 100%;
  min-height: 200px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.remove-image {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(231, 76, 60, 0.9);
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.remove-image:hover {
  background: #e74c3c;
  transform: scale(1.1);
}

.style-icon {
  font-size: 24px;
  line-height: 1;
}

.style-label {
  font-size: 12px;
  font-weight: 600;
}

/* Button */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f8c8dc, #b388ff);
  color: white;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(179, 136, 255, 0.4);
}

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

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

/* Loader */
.btn-loader {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Result Section */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.result-header h2 {
  font-size: 18px;
}

.image-container {
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f5f5f5;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-message {
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--yellow-light);
  border-left: 4px solid var(--yellow);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  display: none;
}

.image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.placeholder {
  color: #bbb;
  font-size: 15px;
}

/* Buttons */
.btn-secondary {
  padding: 8px 20px;
  border: 2px solid var(--pink);
  border-radius: 20px;
  background: white;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--pink-light);
}

.btn-text {
  padding: 4px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-text:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

/* Prompt Card */
.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.prompt-header h3 {
  font-size: 15px;
  color: var(--text);
}

#promptDisplay {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  color: #555;
}

/* Steps Section */
.steps-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text);
}

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

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-content strong {
  font-size: 13px;
}

.step-content span {
  font-size: 11px;
  color: var(--text-light);
}

.step-arrow {
  font-size: 20px;
  color: var(--pink);
  flex-shrink: 0;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px 0;
  color: #aaa;
  font-size: 13px;
}

/* Error */
.error-msg {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fdf0ef;
  border-radius: var(--radius-sm);
  display: none;
}

.error-msg.show {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .style-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
}

@media (max-width: 600px) {
  .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .steps {
    flex-direction: column;
  }

  .step-arrow {
    transform: rotate(90deg);
  }

  .header h1 {
    font-size: 24px;
  }
}
