* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --text: #1e293b;
  --text-soft: #64748b;
  --border: #e2e8f0;
  --answer-bg: #f0fdf4;
  --answer-border: #86efac;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text);
  padding: 24px 16px;
}

.app {
  max-width: 760px;
  margin: 0 auto;
}

/* Header */
.app-header {
  position: relative;
  text-align: center;
  color: #fff;
  margin-bottom: 28px;
}

.app-header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.subtitle {
  opacity: 0.9;
  font-size: 0.95rem;
}

.icon-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(45deg);
}

/* Cards */
.form-card,
.settings-panel {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.settings-panel h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.hint {
  color: var(--text-soft);
  font-size: 0.85rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

.field {
  margin-bottom: 16px;
  flex: 1;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-row {
  display: flex;
  gap: 16px;
}

/* 图片上传 */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-soft);
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
  font-size: 1.8rem;
}

.upload-text {
  font-size: 0.9rem;
}

.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.image-preview:empty {
  margin-top: 0;
}

.preview-item {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item .remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-item .remove-img:hover {
  background: #dc2626;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* Status */
.status {
  background: var(--card);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: center;
  font-weight: 500;
  box-shadow: var(--shadow);
}

.status.error {
  color: #dc2626;
}

.stream-preview {
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-soft);
  font-family: "Consolas", "Monaco", monospace;
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
}

/* 进度条 */
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.progress-count {
  font-weight: 700;
  color: var(--primary);
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid #c7d2fe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.result-header h2 {
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-header .btn {
  width: auto;
}

/* Question cards */
.questions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.q-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeIn 0.4s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.q-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.q-head:hover {
  background: #f8fafc;
}

.q-index {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.q-text {
  flex: 1;
  font-weight: 500;
  line-height: 1.6;
}

.q-meta {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 6px;
}

.q-arrow {
  flex-shrink: 0;
  color: var(--text-soft);
  transition: transform 0.3s;
  font-size: 0.9rem;
  margin-top: 4px;
}

.q-card.open .q-arrow {
  transform: rotate(180deg);
}

.q-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  background: var(--answer-bg);
  border-top: 1px solid transparent;
}

.q-card.open .q-answer {
  border-top: 1px solid var(--answer-border);
}

.q-answer-inner {
  padding: 16px 20px;
  line-height: 1.7;
}

.q-answer-label {
  font-weight: 700;
  color: #16a34a;
  display: block;
  margin-bottom: 6px;
}

.q-answer-inner pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Consolas", "Monaco", monospace;
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* 朗读按钮 */
.q-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.tts-btn {
  border: 1.5px solid var(--answer-border);
  background: #fff;
  color: #16a34a;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.tts-btn:hover {
  background: #dcfce7;
}

.tts-btn:active {
  transform: scale(0.96);
}

.tts-btn.speaking {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.hidden {
  display: none !important;
}

@media (max-width: 540px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .app-header h1 {
    font-size: 1.5rem;
  }
}
