/* ===========================================
   刷题系统 — 移动端优先样式
   =========================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f5f6fa;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-touch-callout: none;
}

/* --- Container --- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 90px;
}

/* --- Typography --- */
h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
}
h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.text-muted {
  color: #999;
  font-size: 13px;
}
.text-center {
  text-align: center;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  padding: 12px 0 12px;
  position: sticky;
  top: 0;
  background: #f5f6fa;
  z-index: 10;
  min-height: 48px;
}
.page-header h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
}
.btn-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: none;
  background: none;
  color: #333;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 8px;
}
.btn-back:active {
  background: #e8e8e8;
}

/* --- Cards (首页功能入口) --- */
.func-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.func-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s;
}
.func-card:active {
  transform: scale(0.95);
  background: #f8f8ff;
}
.func-card .icon {
  font-size: 24px;
  margin-bottom: 6px;
}
.func-card p {
  font-size: 12px;
  color: #666;
}

/* --- Practice Mode Cards --- */
.practice-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.practice-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.practice-card:active {
  transform: scale(0.97);
}
.practice-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}
.practice-card p {
  font-size: 13px;
  color: #999;
}
.practice-card.seq {
  border-left: 4px solid #4a6cf7;
}
.practice-card.random {
  border-left: 4px solid #f7a84a;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  min-width: 44px;
}
.btn:active {
  opacity: 0.8;
}
.btn-primary {
  background: #4a6cf7;
  color: #fff;
}
.btn-primary:active {
  background: #3a5ce5;
}
.btn-outline {
  background: #fff;
  color: #4a6cf7;
  border: 1.5px solid #4a6cf7;
}
.btn-danger {
  background: #ff4757;
  color: #fff;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  height: 36px;
  font-size: 13px;
  padding: 0 14px;
}
.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn-group .btn {
  flex: 1;
}

/* --- Extra Function Buttons --- */
.extra-func {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.extra-func button {
  height: 48px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  color: #fff;
}
.extra-func button:first-child {
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.extra-func button:last-child {
  background: linear-gradient(135deg, #f093fb, #f5576c);
}
.extra-func button:active {
  opacity: 0.85;
}

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.active {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.modal-box h3 {
  margin-bottom: 16px;
}
.modal-box input[type="number"] {
  width: 100%;
  height: 48px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  text-align: center;
  font-size: 20px;
  margin-bottom: 16px;
  outline: none;
}
.modal-box input[type="number"]:focus {
  border-color: #4a6cf7;
}
.modal-box .btns {
  display: flex;
  gap: 10px;
}
.modal-box .btns button {
  flex: 1;
  height: 44px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  cursor: pointer;
}
.modal-box .btns button:first-child {
  background: #f0f0f0;
  color: #666;
}
.modal-box .btns button:last-child {
  background: #4a6cf7;
  color: #fff;
}

/* --- Practice Page --- */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #888;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #4a6cf7;
  border-radius: 3px;
  transition: width 0.3s;
}

.question-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.question-title {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 20px;
  word-break: break-word;
}
.question-type-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-weight: 500;
}
.badge-judge { background: #e8f5e9; color: #2e7d32; }
.badge-single { background: #e3f2fd; color: #1565c0; }
.badge-multi { background: #fff3e0; color: #e65100; }

/* --- Options (选择按钮) --- */
.option-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  margin-bottom: 10px;
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 15px;
  text-align: left;
}
.option-item:active {
  transform: scale(0.98);
}
.option-item .opt-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8e8e8;
  font-weight: 600;
  font-size: 13px;
  margin-right: 12px;
  flex-shrink: 0;
}
.option-item.selected {
  border-color: #4a6cf7;
  background: #eef1ff;
}
.option-item.selected .opt-key {
  background: #4a6cf7;
  color: #fff;
}
.option-item.correct {
  border-color: #2e7d32;
  background: #e8f5e9;
}
.option-item.correct .opt-key {
  background: #2e7d32;
  color: #fff;
}
.option-item.wrong {
  border-color: #c62828;
  background: #ffebee;
}
.option-item.wrong .opt-key {
  background: #c62828;
  color: #fff;
}
.option-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Judge buttons (对/错) */
.judge-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}
.judge-btn {
  height: 60px;
  border: 2px solid #e8e8e8;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.judge-btn:active {
  transform: scale(0.96);
}
.judge-btn.selected-true {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #2e7d32;
}
.judge-btn.selected-false {
  border-color: #c62828;
  background: #ffebee;
  color: #c62828;
}
.judge-btn.show-correct-true {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #2e7d32;
}
.judge-btn.show-correct-false {
  border-color: #c62828;
  background: #ffebee;
  color: #c62828;
}

/* --- Analysis --- */
.analysis-box {
  background: #fff8e1;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #5d4037;
  display: none;
}
.analysis-box.show {
  display: block;
}
.analysis-box .label {
  font-weight: 600;
  margin-bottom: 6px;
  color: #f57f17;
}

/* --- Action Bar (收藏/斩题/笔记) --- */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}
.action-btn {
  flex: 1;
  height: 40px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.action-btn:active {
  background: #f5f5f5;
}
.action-btn.active {
  color: #4a6cf7;
  border-color: #4a6cf7;
}

/* --- Bottom Navigation Bar (刷题) --- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #eee;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-bar .btn {
  flex: 1;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.tab-item {
  flex: 1;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab-item.active {
  color: #4a6cf7;
  border-bottom-color: #4a6cf7;
  font-weight: 600;
}
.tab-item .tab-count {
  font-size: 11px;
  color: #999;
  margin-left: 4px;
}

/* --- List Items (错题/收藏等列表) --- */
.list-item {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  cursor: pointer;
}
.list-item:active {
  background: #f8f8ff;
}
.list-item .q-title {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-item .q-meta {
  font-size: 12px;
  color: #999;
  display: flex;
  gap: 12px;
}
.list-item .q-meta .tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* --- Exam Page --- */
.exam-header {
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.exam-timer {
  font-size: 24px;
  font-weight: 700;
  color: #e74c3c;
  font-variant-numeric: tabular-nums;
}
.exam-progress {
  font-size: 14px;
  color: #666;
}
.exam-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 16px;
}
.exam-nav-item {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1.5px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}
.exam-nav-item.answered {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
}
.exam-nav-item.current {
  border-color: #4a6cf7;
  border-width: 2px;
}

/* --- Exam Result --- */
.result-box {
  background: #fff;
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.result-score {
  font-size: 56px;
  font-weight: 800;
  color: #4a6cf7;
}
.result-score.pass { color: #2e7d32; }
.result-score.fail { color: #c62828; }
.result-label {
  font-size: 16px;
  color: #666;
  margin-top: 8px;
}
.result-detail {
  font-size: 14px;
  color: #999;
  margin-top: 4px;
}

/* --- Note Editor --- */
.note-editor {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.note-editor.active {
  display: flex;
}
.note-editor .note-box {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
}
.note-editor textarea {
  width: 100%;
  min-height: 120px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.note-editor textarea:focus {
  border-color: #4a6cf7;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #bbb;
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 14px;
}

/* --- Utility --- */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
