/* ====== 广西专升本 · 全局样式 v3 ====== */
:root {
  --primary: #1e293b;
  --primary-light: #f1f5f9;
  --bg: #fafbfc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: rgba(0,0,0,.05);
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.03), 0 1px 3px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --easing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* 保护 KaTeX 不受全局 reset 影响 */
.katex, .katex * { box-sizing: content-box; margin: revert; padding: revert; }

html { overflow-x: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }

/* === Card === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 0.5px solid var(--border-light);
  margin-bottom: 14px;
}

/* === 进度条 === */
.progress-bar { height: 5px; background: var(--border); border-radius: 3px; margin: 10px 0 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #475569); border-radius: 3px; transition: width 0.5s var(--easing); }
.progress-text { font-size: 12px; color: var(--text-muted); text-align: right; margin-bottom: 6px; font-weight: 500; }

/* === 章节标签 === */
.chapter-tag { display: inline-block; font-size: 12px; padding: 4px 12px; border-radius: 20px; font-weight: 500; margin-bottom: 8px; letter-spacing: 0.2px; }
.chapter-tag.math       { background: #eff6ff; color: #1e40af; }
.chapter-tag.chinese    { background: #fef3c7; color: #92400e; }
.chapter-tag.english    { background: #ecfdf5; color: #065f46; }
.chapter-tag.psychology { background: #fdf2f8; color: #9d174d; }
.chapter-tag.education  { background: #f5f3ff; color: #5b21b6; }
.chapter-tag.politics   { background: #fef2f2; color: #991b1b; }
.chapter-tag.computer   { background: #ecfeff; color: #155e75; }
.chapter-tag.management { background: #fff7ed; color: #9a3412; }

/* === 题干 === */
.stem { font-size: 16px; font-weight: 500; line-height: 1.75; margin: 10px 0; }

/* === 选项 === */
.option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 15px 16px; margin-bottom: 8px;
  border: 1.5px solid var(--border); border-radius: 14px;
  cursor: pointer; transition: all var(--easing);
  background: var(--card-bg);
}
.option:hover { border-color: #cbd5e1; box-shadow: var(--shadow-sm); }
.option:active { transform: scale(0.985); }
.option.selected { border-color: var(--primary); background: var(--primary-light); }
.option-label {
  width: 30px; height: 30px; border-radius: 50%;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  transition: all var(--easing);
}
.option.selected .option-label { background: var(--primary); color: #fff; }
.option-content { flex: 1; font-size: 15px; padding-top: 4px; line-height: 1.6; }
.multiple-choice-hint { margin:4px 0 10px; color:var(--text-secondary); font-size:13px; line-height:1.5; }
.exam-group-note { display:grid; gap:5px; margin:14px 0; padding:12px 14px; border-left:3px solid #2563eb; background:#eff6ff; color:#1e3a5f; }
.exam-group-note span { font-size:13px; font-weight:600; }
.exam-group-note small { line-height:1.6; color:#475569; }

/* === 输入区 === */
.input-area { margin: 14px 0; }
.textarea {
  width: 100%; min-height: 80px; padding: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; resize: vertical;
  background: var(--card-bg); transition: border-color var(--easing);
}
.textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,41,59,.06); }
.math-input-tools { width: 100%; max-width: 100%; margin-top: 8px; overflow: hidden; contain: paint; }
.math-input-preview {
  display: grid; grid-template-columns: 64px minmax(0,1fr); align-items: center;
  min-height: 54px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff;
}
.math-input-preview > span { font-size: 12px; color: var(--text-muted); }
.math-input-preview output { min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 3px 4px; font-size: 17px; }
.math-preview-empty { color: var(--text-muted); font: 13px/1.4 system-ui,sans-serif; }
.math-preview-error { color: #b91c1c; font: 13px/1.4 system-ui,sans-serif; }
.math-preview-lines { display:flex; flex-direction:column; align-items:flex-start; gap:5px; min-width:max-content; }
.math-preview-lines>span { display:flex; align-items:center; gap:4px; }
.math-preview-lines b { color:var(--text-secondary); font:600 12px/1.4 system-ui,sans-serif; }
.symbol-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.symbol-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 40px; padding: 4px 9px; background: #f8fafc;
  border-radius: 6px; font-size: 14px; font-family: inherit;
  cursor: pointer; border: 1px solid var(--border); flex: 0 0 auto;
  transition: all var(--easing); color: var(--text-secondary);
}
.symbol-btn .katex { font-size: 1.05em; }
.symbol-clear { color: #b91c1c; font: 600 13px/1 system-ui,sans-serif; }
.symbol-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
@media (max-width: 600px) {
  .symbol-bar { width: 100%; max-width: 100%; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; scrollbar-width: none; }
  .symbol-bar::-webkit-scrollbar { display: none; }
  .math-input-preview { grid-template-columns: 54px minmax(0,1fr); }
}

/* === 按钮 === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 26px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer; border: none;
  transition: all var(--easing); font-family: inherit; letter-spacing: -0.1px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #334155; box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--primary-light); color: var(--text); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* === 操作栏 === */
.action-bar { display: flex; gap: 12px; margin-top: 16px; }

/* === 结果页 === */
.result-container { text-align: center; padding: 20px 0; }
.result-icon { font-size: 56px; margin-bottom: 8px; line-height: 1; }
.result-text { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.result-text.correct { color: var(--success); }
.result-text.wrong { color: var(--danger); }
.answer-box {
  text-align: left; background: #f8fafc; border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 10px; border: 0.5px solid var(--border-light);
}
.answer-box .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.answer-box .value { font-size: 15px; }
.answer-box.correct { background: var(--success-bg); border-color: #a7f3d0; }
.answer-box.wrong { background: var(--danger-bg); border-color: #fecaca; }
.solution-box {
  text-align: left; background: var(--warning-bg); border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px;
}
.solution-box summary { font-weight: 600; font-size: 14px; cursor: pointer; color: #92400e; }
.solution-content { margin-top: 8px; font-size: 14px; color: #78350f; line-height: 1.7; }

/* === Toast === */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 24px; border-radius: 14px; font-size: 14px; font-weight: 500; z-index: 999; box-shadow: 0 4px 20px rgba(0,0,0,.15); animation: fadeIn 0.3s var(--easing); }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.loading, .empty { text-align: center; padding: 50px 20px; color: var(--text-muted); font-size: 15px; }

/* ====== 移动端 ====== */
@media (max-width: 480px) {
  .card { padding: 14px; }
  .stem { font-size: 15px; }
  .option { padding: 12px 14px; }
}

/* ====== 教科书级数学排版 ====== */
/* 展示公式居中 + 上下间距 */
.katex-display {
  margin: 14px 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
}
.katex-display > .katex {
  font-size: 1.15em;
}

/* 解析区行高 — 给展示公式留足空间 */
.solution-content {
  line-height: 2;
}

/* 行内公式垂直居中 */
.katex {
  vertical-align: middle;
}

/* 隐藏 MathML — 避免复制时公式文本重复三次 */
.katex .katex-mathml {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* 移动端公式不溢出 */
@media (max-width: 480px) {
  .katex-display {
    font-size: 0.95em;
    margin: 10px 0;
  }
}
