:root {
  --primary: #1E3A8A;
  --primary-light: #2563EB;
  --primary-bg: #EFF6FF;
  --bg: #F3F4F6;
  --text: #1F2937;
  --text-light: #6B7280;
  --white: #FFFFFF;
  --border: #D1D5DB;
  --success: #059669;
  --success-bg: #D1FAE5;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --warning: #D97706;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 8px;
}

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

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* 头部 */
.header {
  text-align: center;
  padding: 32px 0 24px;
}
.header h1 {
  font-size: 28px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}
.header p {
  color: var(--text-light);
  font-size: 15px;
}

/* 卡片 */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 文章输入区 */
.article-textarea {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
}
.article-textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.article-hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}
.btn-disabled {
  background: #E5E7EB;
  color: #9CA3AF;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: not-allowed;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 设置面板 */
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
  background: none;
  border: none;
  padding: 0;
}
.settings-toggle .arrow {
  transition: transform 0.3s;
  font-size: 12px;
}
.settings-toggle .arrow.open {
  transform: rotate(90deg);
}
.settings-body {
  margin-top: 16px;
  display: none;
}
.settings-body.show {
  display: block;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--white);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.hidden { display: none !important; }

/* 按钮 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-light);
}
.btn-secondary {
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: #DBEAFE;
}
.btn-success {
  background: var(--success);
  color: var(--white);
}
.btn-success:hover {
  background: #047857;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* 出题控制 */
.control-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.control-row label {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.control-row input[type="range"] {
  flex: 1;
  min-width: 120px;
}
.control-row .range-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  min-width: 30px;
  text-align: center;
}
.difficulty-hint {
  font-size: 13px;
  color: var(--text-light);
  background: #F9FAFB;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid #E5E7EB;
  margin-bottom: 16px;
}
.btn-generate {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  justify-content: center;
}

/* 加载动画 */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.loading-overlay.show {
  display: flex;
}
.loading-box {
  background: var(--white);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}
.loading-sub-text {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
  min-height: 20px;
  transition: opacity 0.5s;
}

/* 进度条 */
.loading-phase-bar {
  width: 100%;
  height: 4px;
  background: #E5E7EB;
  border-radius: 2px;
  margin-top: 18px;
  overflow: hidden;
}
.loading-phase-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* 阶段指示点 */
.loading-phase-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}
.phase-dot {
  font-size: 10px;
  transition: color 0.5s, transform 0.3s;
}
.phase-dot.active {
  color: var(--primary);
  transform: scale(1.3);
}
.phase-dot.done {
  color: var(--success);
}

/* 模式切换 */
.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.mode-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* 题目区域 */
.question-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.question-card:hover {
  border-color: var(--primary-light);
}
.question-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.question-id {
  background: var(--primary);
  color: var(--white);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.question-type {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-bg);
  color: var(--primary);
}
.question-difficulty {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}
.question-difficulty.基础 { background: #D1FAE5; color: #065F46; }
.question-difficulty.进阶 { background: #FEF3C7; color: #92400E; }
.question-difficulty.困难 { background: #FEE2E2; color: #991B1B; }
.question-text {
  font-size: 15px;
  margin-bottom: 14px;
  line-height: 1.8;
}
.options-list {
  list-style: none;
}
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  line-height: 1.6;
}
.option-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}
.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.option-item.correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.option-radio {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}
.option-label {
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}
.option-text {
  flex: 1;
}

/* 解析区域 */
.analysis-box {
  display: none;
  margin-top: 14px;
  padding: 14px;
  background: #F9FAFB;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  font-size: 14px;
  line-height: 1.8;
}
.analysis-box.show {
  display: block;
}
.analysis-box .correct-answer {
  font-weight: 600;
  color: var(--success);
  margin-bottom: 6px;
}

/* 逐题模式导航 */
.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #E5E7EB;
}
.quiz-progress {
  font-size: 14px;
  color: var(--text-light);
}

/* 结果区 */
.result-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 20px;
  border: 2px solid var(--primary);
}
.result-score {
  text-align: center;
  padding: 20px 0;
}
.result-score .score-number {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
}
.result-score .score-label {
  font-size: 16px;
  color: var(--text-light);
  margin-top: 4px;
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* 知识点总结 */
.summary-card {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #BFDBFE;
}
.summary-card .card-title {
  color: var(--primary);
  font-size: 16px;
  margin-bottom: 12px;
}
.summary-content {
  font-size: 14px;
  line-height: 1.9;
  color: var(--text);
  white-space: pre-wrap;
}

/* 错误提示 */
.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
  align-items: center;
  gap: 8px;
}
.error-banner.show {
  display: flex;
}

/* 响应式 */
@media (max-width: 640px) {
  .container { padding: 12px 10px; }
  .card { padding: 16px; }
  .header h1 { font-size: 22px; }
  .form-row { grid-template-columns: 1fr; }
  .control-row { flex-direction: column; align-items: stretch; }
  .result-score .score-number { font-size: 36px; }
  .option-item { padding: 8px 10px; font-size: 13px; }
}
