/* ========== 全局变量 ========== */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --accent: #10b981;
  --accent-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ========== Login Page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.login-card .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  text-align: center;
  letter-spacing: 1px;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}
.login-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.4); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 20px;
}

/* ========== Header ========== */
.header {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%);
  color: white;
  padding: 24px 32px;
  text-align: center;
}
.header h1 { font-size: 24px; font-weight: 700; }
.header p { font-size: 14px; opacity: 0.85; margin-top: 4px; }

/* ========== Steps Bar ========== */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 0;
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  transition: all 0.2s;
  white-space: nowrap;
}
.step:hover { background: var(--primary-light); }
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  transition: all 0.2s;
}
.step-label { font-size: 13px; color: var(--text-secondary); transition: all 0.2s; }
.step.active .step-num { background: var(--primary); color: white; }
.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.done .step-num { background: var(--accent); color: white; }
.step.done .step-label { color: var(--accent); }
.step-line { width: 24px; height: 2px; background: var(--border); margin: 0 2px; }

/* ========== Panels ========== */
.step-panel {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}
.step-panel.active { display: block; }

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

.panel-header { margin-bottom: 24px; }
.panel-header h2 { font-size: 20px; color: var(--text); margin-bottom: 4px; }
.panel-header p { font-size: 14px; color: var(--text-secondary); }

/* ========== Themes Grid (Step 0) ========== */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.theme-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.theme-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.theme-title {
  font-size: 16px; font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.theme-desc {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.example-list { display: flex; flex-direction: column; gap: 8px; }
.example-btn {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  font-size: 13px;
  line-height: 1.5;
}
.example-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.example-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}
.example-btn .ex-tag {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}
.example-btn .ex-text { flex: 1; }
.example-btn .ex-title { font-weight: 600; color: var(--text); }
.example-btn .ex-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Selected Info */
.selected-info {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
}
.info-badge {
  position: absolute;
  top: -10px; left: 16px;
  background: var(--primary);
  color: white;
  padding: 2px 12px;
  border-radius: 4px;
  font-size: 12px; font-weight: 600;
}
.selected-info h3 { font-size: 14px; color: var(--primary-dark); margin-bottom: 4px; }
.selected-info h4 { font-size: 16px; margin-bottom: 8px; }
.selected-info p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ========== Two Column Layout ========== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .themes-grid { grid-template-columns: 1fr; }
}

.col-left, .col-right { min-width: 0; }

/* ========== Cards ========== */
.guide-card, .form-card, .checklist-card, .preview-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.guide-card h3, .form-card h3, .checklist-card h3, .preview-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ========== Tips Content ========== */
.tips-content {
  margin-bottom: 16px;
}
.tips-content .tip-item {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
}
.tips-content .tip-label {
  font-weight: 600;
  color: var(--primary-dark);
  display: block;
  margin-bottom: 2px;
}

/* Highlight boxes */
.highlight-box {
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
}
.highlight-box.warning { background: var(--warning-light); border-left: 4px solid var(--warning); }
.highlight-box.info { background: var(--primary-light); border-left: 4px solid var(--primary); }
.highlight-box ul { padding-left: 18px; margin-top: 8px; }
.highlight-box li { margin-bottom: 4px; }

/* Prompt copy box */
.prompt-copy-box {
  background: #1e293b;
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.prompt-copy-box h4 { color: #94a3b8; font-size: 12px; margin-bottom: 8px; }
.copyable-prompt {
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-family: "Consolas", "SFMono-Regular", monospace;
}
.btn-copy {
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-copy:hover { background: rgba(255,255,255,0.2); color: white; }

/* ========== Form Elements ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group label.required::after { content: ' *'; color: var(--danger); }
.form-row { display: flex; gap: 12px; }
.form-group.half { flex: 1; }

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: white;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-textarea { resize: vertical; min-height: 100px; }
.word-count { text-align: right; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.panel-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ========== Checklist ========== */
.checklist-card { margin-bottom: 20px; }
.checklist-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 700px) { .checklist-items { grid-template-columns: 1fr; } }
.check-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.check-item:hover { background: var(--accent-light); }
.check-item input[type="checkbox"] {
  width: 16px; height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.checklist-progress {
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* ========== Preview ========== */
.preview-card { margin-bottom: 20px; }
.preview-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.preview-header h3 { margin-bottom: 0; padding-bottom: 0; border: none; }
.preview-content {
  background: var(--bg);
  border-radius: 8px;
  padding: 24px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 600px;
  overflow-y: auto;
}

/* ========== Toast ========== */
.copy-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.copy-toast.show { transform: translateX(-50%) translateY(0); }

/* ========== Guide Content (分步操作指引) ========== */
.guide-content { font-size: 14px; }

.eval-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
}
.eval-box.eval-important {
  background: #fef3c7;
  border-color: #fbbf24;
}
.eval-tag {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}
.eval-important .eval-tag { background: #d97706; }
.eval-box ul { padding-left: 18px; margin-top: 6px; }
.eval-box li { margin-bottom: 4px; }

.section-intro {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  border-left: 4px solid var(--primary);
}

.op-steps { display: flex; flex-direction: column; gap: 14px; }
.op-step {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: 10px;
  border-left: 3px solid var(--border);
}
.op-step.highlight-step {
  border-left-color: var(--warning);
  background: #fffbeb;
}
.op-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.op-num.bad { background: var(--danger); }
.op-num.good { background: var(--accent); }
.op-body { flex: 1; min-width: 0; }
.op-body h4 { font-size: 14px; margin-bottom: 6px; color: var(--text); }
.op-body p { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.5; }
.op-body ul { padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.op-body li { margin-bottom: 3px; }

.hint-box {
  background: white;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 8px 0;
}

.prompt-box-dark {
  background: #1e293b;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}
.prompt-box-dark pre {
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-family: "Consolas", "SFMono-Regular", monospace;
}

.screenshot-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 3px solid #ef4444;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: #991b1b;
  margin: 8px 0;
}
.screenshot-box small { color: #b91c1c; }
.screenshot-step { border-left-color: var(--danger); }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== Key Bar ========== */
.key-bar {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}
.key-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.key-label { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.key-input {
  width: 260px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  letter-spacing: 1px;
}
.key-input:focus { outline: none; border-color: var(--primary); }
.key-status { font-size: 12px; }
.key-status.success { color: var(--accent); }
.key-status.error { color: var(--danger); }
.balance-badge {
  background: var(--accent-light);
  color: #065f46;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid #a7f3d0;
}

/* ========== AI Generate Button ========== */
.btn-ai {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border: none;
}
.btn-ai:hover:not(:disabled) { background: linear-gradient(135deg, #047857, #059669); }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ai.loading::after {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-block { width: 100%; }

/* ========== AI Output Box ========== */
.ai-output-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.ai-output-label {
  font-size: 12px;
  color: #065f46;
  font-weight: 600;
  margin-bottom: 8px;
}
.ai-output-pre {
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px;
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
  font-family: "Consolas", "SFMono-Regular", monospace;
}
#final-output-text {
  max-height: 700px;
}

/* ========== AI Generate Bar ========== */
.ai-gen-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: #f0fdf4;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
}
.ai-gen-hint { font-size: 12px; color: #065f46; }

/* ========== Important Notice Box ========== */
.important-notice {
  display: flex;
  gap: 12px;
  background: #fff7ed;
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 32px 20px 32px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}
.notice-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1.4;
}
.notice-body h4 {
  color: #b45309;
  font-size: 15px;
  margin-bottom: 4px;
}
.notice-body p {
  font-size: 13px;
  color: #78350f;
  line-height: 1.7;
}

/* ========== Required Label & Tag ========== */
.required-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.required-tag {
  display: inline-block;
  background: #ef4444;
  color: white;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.form-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ========== Form Textarea ========== */
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
}
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-textarea::placeholder {
  color: #94a3b8;
}

/* ========== Final Generation Card ========== */
.final-gen-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 32px 20px 32px;
  box-shadow: var(--shadow);
  border: 2px solid var(--primary-light);
}
.final-gen-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--primary-dark);
}
.btn-lg {
  padding: 12px 28px;
  font-size: 16px;
}

/* ========== Scenario Gen Box ========== */
.scenario-gen-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* ========== Analysis Gen Box ========== */
.analysis-gen-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* ========== Analysis Type Picker ========== */
.analysis-type-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: all 0.15s;
}
.type-option:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.type-option input[type="radio"] { accent-color: var(--primary); }

/* ========== Two-Prompt Sections ========== */
.prompt-section {
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.prompt-section-label {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}
.prompt-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.prompt-before {
  background: #fef3c7;
  border: 1px solid #f59e0b;
}
.prompt-before .prompt-section-label { color: #b45309; }
.prompt-after {
  background: #d1fae5;
  border: 1px solid #10b981;
}
.prompt-after .prompt-section-label { color: #047857; }
