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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #6c63ff 0%, #e040fb 100%);
  text-align: center;
  padding: 32px 20px;
  color: white;
}

header h1 { font-size: 2.2rem; margin-bottom: 8px; }
header p { opacity: 0.85; font-size: 1rem; }

main {
  max-width: 680px;
  margin: 32px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 生成区 */
.generator {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 28px;
  border: 1px solid #2a2a4a;
}

.input-area { position: relative; margin-bottom: 20px; }

textarea {
  width: 100%;
  height: 100px;
  background: #0f0f1a;
  border: 2px solid #2a2a4a;
  border-radius: 12px;
  color: #e0e0e0;
  font-size: 1rem;
  padding: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

textarea:focus { border-color: #6c63ff; }
textarea::placeholder { color: #555; }

.char-count {
  text-align: right;
  font-size: 0.78rem;
  color: #555;
  margin-top: 4px;
}

/* 选项 */
.options-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.option-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #888;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opt-btn {
  padding: 7px 16px;
  border: 2px solid #2a2a4a;
  border-radius: 20px;
  background: transparent;
  color: #aaa;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.opt-btn:hover { border-color: #6c63ff; color: #e0e0e0; }
.opt-btn.active { border-color: #6c63ff; background: #6c63ff22; color: #a78bfa; font-weight: 600; }

/* 生成按钮 */
.generate-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #6c63ff, #e040fb);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-bottom: 12px;
}

.generate-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.quota-info {
  text-align: center;
  font-size: 0.82rem;
  color: #666;
}

.quota-info strong { color: #a78bfa; }

/* 加载动画 */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* 结果区 */
.result-area {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 28px;
  border: 1px solid #2a2a4a;
  text-align: center;
}

.result-area h2, .history-area h2 {
  font-size: 1rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.result-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#resultImg {
  width: 200px;
  height: 200px;
  border-radius: 20px;
  object-fit: cover;
  border: 2px solid #2a2a4a;
}

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

.btn-primary, .btn-secondary {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: linear-gradient(135deg, #6c63ff, #e040fb); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: #2a2a4a; color: #aaa; }
.btn-secondary:hover { background: #3a3a5a; color: #e0e0e0; }

/* 历史 */
.history-area {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 28px;
  border: 1px solid #2a2a4a;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.history-item {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.history-item:hover { border-color: #6c63ff; }
.history-item img { width: 100%; height: 100%; object-fit: cover; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
  max-width: 320px;
  border: 1px solid #2a2a4a;
}

.modal-icon { font-size: 3rem; margin-bottom: 16px; }
.modal-box h3 { font-size: 1.2rem; margin-bottom: 10px; }
.modal-box p { color: #888; font-size: 0.9rem; margin-bottom: 8px; }
.modal-sub { font-size: 0.8rem !important; color: #555 !important; }
.modal-box .btn-primary { margin-top: 20px; width: 100%; padding: 12px; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .history-grid { grid-template-columns: repeat(3, 1fr); }
  .result-actions { flex-direction: column; width: 100%; }
  .btn-primary, .btn-secondary { width: 100%; text-align: center; }
}
