/* ========== 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  padding: 20px;
  color: #1a202c;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
}

/* ========== 首页 ========== */
.app-header {
  text-align: center;
  padding: 30px 0 20px;
}
.app-header h1 {
  font-size: 36px;
  color: #1a365d;
  font-weight: 800;
}
.app-header .subtitle {
  color: #718096;
  font-size: 15px;
  margin-top: 6px;
}

.mode-section {
  margin-bottom: 30px;
}
.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 500px;
  margin: 0 auto;
}
@media (max-width: 480px) {
  .mode-row {
    grid-template-columns: 1fr;
  }
}
.mode-btn {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}
.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.mode-btn .icon {
  font-size: 32px;
  display: block;
  margin-bottom: 6px;
}
.mode-btn h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1a365d;
}
.mode-btn p {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 2px;
}
.mode-btn.selected-local {
  border-color: #48bb78;
  background: #f0fff4;
}
.mode-btn.selected-cloud {
  border-color: #4299e1;
  background: #ebf8ff;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}
.section-header h2 {
  font-size: 20px;
  color: #1a365d;
}
.btn-add {
  background: #2b6cb0;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-add:hover {
  background: #2c5282;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.subject-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px 20px;
  border: 1px solid #e9edf4;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 14px;
}
.subject-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: #bee3f8;
}
.subject-card .subject-icon {
  font-size: 32px;
  flex-shrink: 0;
}
.subject-card .subject-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a365d;
  flex: 1;
}
.subject-card .btn-delete {
  background: none;
  border: none;
  font-size: 18px;
  color: #a0aec0;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.subject-card .btn-delete:hover {
  background: #fed7d7;
  color: #e53e3e;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #a0aec0;
}
.empty-state .empty-icon {
  font-size: 48px;
}
.empty-state .empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #718096;
}
.empty-state .empty-desc {
  font-size: 14px;
  margin-top: 4px;
}

.app-footer {
  text-align: center;
  color: #a0aec0;
  font-size: 12px;
  padding: 20px 0 10px;
  border-top: 1px solid #edf2f7;
  margin-top: 20px;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 440px;
  width: 92%;
  position: relative;
  animation: slideUp 0.25s ease;
}
.modal.modal-sm {
  max-width: 360px;
  padding: 28px 24px;
}
.modal .close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 24px;
  color: #a0aec0;
  cursor: pointer;
}
.modal .close-btn:hover {
  color: #1a202c;
}
.modal h2 {
  font-size: 20px;
  color: #1a365d;
  margin-bottom: 4px;
}
.modal p {
  color: #718096;
  font-size: 14px;
  margin-bottom: 20px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
}
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: #2b6cb0;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}
.form-group .form-hint {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 4px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.modal-actions button {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel {
  background: #edf2f7;
  color: #4a5568;
}
.btn-cancel:hover {
  background: #e2e8f0;
}
.btn-confirm {
  background: #2b6cb0;
  color: #fff;
}
.btn-confirm:hover {
  background: #2c5282;
}
.btn-danger {
  background: #e53e3e;
  color: #fff;
}
.btn-danger:hover {
  background: #c53030;
}
@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========== 题库列表 ========== */
.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.back-btn {
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #2b6cb0;
  cursor: pointer;
}
.back-btn:hover {
  background: #edf2f7;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a365d;
  flex: 1;
}
.mode-badge {
  font-size: 12px;
  padding: 4px 14px;
  border-radius: 20px;
  background: #edf2f7;
  color: #4a5568;
  font-weight: 600;
}
.subject-header {
  background: #fff;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1px solid #e9edf4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.subject-header .icon {
  font-size: 28px;
}
.subject-header .name {
  font-size: 18px;
  font-weight: 700;
  color: #1a365d;
  margin-left: 8px;
}
.subject-header .stats {
  font-size: 13px;
  color: #a0aec0;
  margin-left: 8px;
}
.subject-header .actions {
  display: flex;
  gap: 10px;
}
.btn-import {
  background: #2b6cb0;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-import:hover {
  background: #2c5282;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.file-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid #e9edf4;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 14px;
}
.file-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: #bee3f8;
}
.file-card .file-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.file-card .file-info {
  flex: 1;
  min-width: 0;
}
.file-card .file-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a365d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card .file-meta {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 2px;
}
.file-card .btn-delete-sm {
  background: none;
  border: none;
  font-size: 16px;
  color: #a0aec0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.file-card .btn-delete-sm:hover {
  background: #fed7d7;
  color: #e53e3e;
}
.file-card .btn-reset-sm {
  background: none;
  border: none;
  font-size: 16px;
  color: #a0aec0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.file-card .btn-reset-sm:hover {
  background: #bee3f8;
  color: #3182ce;
}
.file-card .file-arrow {
  color: #cbd5e0;
  font-size: 18px;
  flex-shrink: 0;
}

/* ========== 刷题页面 ========== */
.home-header {
  background: linear-gradient(135deg, #1a365d, #2b6cb0);
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.home-header .home-back {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 4px 14px;
  border-radius: 30px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.home-header .home-back:hover {
  background: rgba(255, 255, 255, 0.25);
}
.home-header h1 {
  font-size: 18px;
  margin: 0;
}
.home-header .stats {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 14px;
  border-radius: 30px;
  white-space: nowrap;
}
.home-header .stats .num {
  font-weight: 700;
  color: #fbd38d;
}
.home-header .stats span {
  margin: 0 4px;
}

.overall-progress {
  background: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid #e9edf4;
}
.overall-progress .info {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #4a5568;
}
.overall-progress .info .num {
  font-weight: 700;
  color: #1a365d;
}
.overall-progress .info .num.green {
  color: #48bb78;
}
.overall-progress .info .num.red {
  color: #fc8181;
}
.overall-progress .bar-wrap {
  flex: 1;
  min-width: 100px;
  margin-top: 6px;
}
.overall-progress .bar-wrap .bar {
  height: 5px;
  background: #edf2f7;
  border-radius: 10px;
  overflow: hidden;
}
.overall-progress .bar-wrap .fill {
  height: 100%;
  background: linear-gradient(90deg, #2b6cb0, #48bb78);
  border-radius: 10px;
  transition: width 0.6s ease;
  width: 0%;
}
.overall-progress .bar-wrap .label {
  font-size: 12px;
  color: #718096;
  display: flex;
  justify-content: space-between;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.chapter-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e9edf4;
  cursor: pointer;
  transition: all 0.25s;
}
.chapter-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.chapter-card .title {
  font-size: 15px;
  font-weight: 600;
  color: #1a365d;
  line-height: 1.4;
  min-height: 42px;
}
.chapter-card .meta {
  font-size: 13px;
  color: #4a5568;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.chapter-card .badge {
  background: #ebf4ff;
  color: #2b6cb0;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.chapter-card .wrong-badge {
  background: #fff5f5;
  color: #e53e3e;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.chapter-card .progress-section {
  margin: 10px 0 6px;
}
.chapter-card .progress-section .bar {
  height: 5px;
  background: #edf2f7;
  border-radius: 10px;
  overflow: hidden;
}
.chapter-card .progress-section .bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #2b6cb0, #48bb78);
  border-radius: 10px;
  transition: width 0.5s ease;
  width: 0%;
}
.chapter-card .progress-section .info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #718096;
  margin-top: 3px;
}
.chapter-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0f4f8;
}
.chapter-card .actions button {
  flex: 1;
  padding: 6px 0;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.chapter-card .actions button:active {
  transform: scale(0.95);
}
.chapter-card .btn-primary {
  background: #2b6cb0;
  color: #fff;
}
.chapter-card .btn-primary:hover {
  background: #2c5282;
}
.chapter-card .btn-wrong {
  background: #fc8181;
  color: #fff;
}
.chapter-card .btn-wrong:hover:not(:disabled) {
  background: #e53e3e;
}
.chapter-card .btn-wrong:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chapter-card .btn-reset {
  background: #718096;
  color: #fff;
}
.chapter-card .btn-reset:hover {
  background: #4a5568;
}

.quiz-header {
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid #e9edf4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.quiz-header .left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quiz-header .back-btn {
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  color: #2d3748;
  padding: 4px 14px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-header .back-btn:hover {
  background: #e2e8f0;
}
.quiz-header .chapter-name {
  font-weight: 700;
  font-size: 18px;
}
.quiz-header .mode-badge {
  font-size: 12px;
  padding: 2px 12px;
  border-radius: 20px;
  background: #ebf8ff;
  color: #2b6cb0;
  font-weight: 600;
}
.quiz-header .mode-badge.wrong {
  background: #fff5f5;
  color: #e53e3e;
}
.quiz-header .quiz-stats {
  font-size: 13px;
  color: #718096;
}
.quiz-header .btn-sync {
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #2b6cb0;
  cursor: pointer;
  margin-right: 8px;
}
.quiz-header .btn-sync:hover {
  background: #edf2f7;
}
.quiz-header .btn-sync:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.question-numbers {
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid #e9edf4;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  gap: 4px;
}
.question-numbers .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  background: #edf2f7;
  color: #2d3748;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.question-numbers .num:active {
  transform: scale(0.9);
}
.question-numbers .num.active {
  background: #2b6cb0;
  color: #fff;
  border-color: #2b6cb0;
}
.question-numbers .num.correct {
  background: #48bb78;
  color: #fff;
}
.question-numbers .num.wrong {
  background: #fc8181;
  color: #fff;
}

.question-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e9edf4;
  transition: transform 0.3s ease;
}
.q-type {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 10px;
}
.q-type.single {
  background: #ebf8ff;
  color: #2b6cb0;
}
.q-type.multi {
  background: #faf5ff;
  color: #6b46c1;
}
.q-text {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 16px;
  word-break: break-all;
}
.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #edf2f7;
  background: #fafcff;
  cursor: pointer;
  transition: border-color 0.2s;
}
.option-item:active {
  transform: scale(0.98);
}
.option-item .label {
  font-weight: 600;
  color: #4a5568;
}
.option-item.selected {
  border-color: #2b6cb0;
  background: #ebf8ff;
}
.option-item.correct {
  border-color: #48bb78;
  background: #f0fff4;
}
.option-item.wrong {
  border-color: #fc8181;
  background: #fff5f5;
}
.option-item.missed {
  border-color: #ecc94b;
  background: #fffff0;
}
.option-item.disabled {
  cursor: default;
}
.option-item.disabled:active {
  transform: none;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.action-row button {
  padding: 8px 18px;
  border: none;
  border-radius: 30px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  flex: 1 1 auto;
  transition: all 0.15s;
}
.action-row button:active {
  transform: scale(0.95);
}
.btn-submit {
  background: #2b6cb0;
  color: #fff;
}
.btn-next {
  background: #48bb78;
  color: #fff;
}
.btn-prev {
  background: #edf2f7;
  color: #2d3748;
}

.explain-box {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid;
}
.explain-box.correct {
  background: #f0fff4;
  border-color: #48bb78;
}
.explain-box.wrong {
  background: #fff5f5;
  border-color: #fc8181;
}
.explain-box .exp-title {
  font-weight: 700;
  font-size: 15px;
}
.explain-box .exp-content {
  font-size: 14px;
  color: #4a5568;
  margin-top: 4px;
}

.finish-box {
  text-align: center;
  padding: 20px 10px;
}
.finish-box .f-title {
  font-size: 24px;
  font-weight: 700;
  color: #1a365d;
  margin-bottom: 8px;
}
.finish-box .f-stats {
  font-size: 16px;
  color: #4a5568;
  margin-bottom: 6px;
}
.finish-box .f-rate {
  font-size: 42px;
  font-weight: 800;
  margin: 12px 0 20px;
}
.finish-box .f-rate.green {
  color: #48bb78;
}
.finish-box .f-rate.orange {
  color: #ed8936;
}
.finish-box .f-rate.red {
  color: #e53e3e;
}
.finish-box .f-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.finish-box .f-btns button {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.finish-box .f-btns button:active {
  transform: scale(0.95);
}
.f-btn-wrong {
  background: #fc8181;
  color: #fff;
}
.f-btn-wrong:hover {
  background: #e53e3e;
}
.f-btn-retry {
  background: #2b6cb0;
  color: #fff;
}
.f-btn-retry:hover {
  background: #2c5282;
}
.f-btn-home {
  background: #edf2f7;
  color: #2d3748;
}
.f-btn-home:hover {
  background: #e2e8f0;
}

/* ========== 加载遮罩 ========== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.loading-overlay.active {
  display: flex;
}
.loading-box {
  background: #fff;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.loading-box .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #edf2f7;
  border-top-color: #2b6cb0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-box .loading-msg {
  font-size: 15px;
  color: #1a365d;
  font-weight: 600;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  body {
    padding: 12px;
  }
  .chapter-grid {
    grid-template-columns: 1fr;
  }
  .home-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .home-header .stats {
    white-space: normal;
  }
  .quiz-header {
    flex-direction: column;
    align-items: stretch;
  }
/* 强制题号颜色 - 提高优先级 */
.question-numbers .num.correct {
  background: #48bb78 !important;
  color: #fff !important;
  border-color: #48bb78 !important;
}

.question-numbers .num.wrong {
  background: #fc8181 !important;
  color: #fff !important;
  border-color: #fc8181 !important;
}

.question-numbers .num.active {
  background: #2b6cb0 !important;
  color: #fff !important;
  border-color: #2b6cb0 !important;
}
}
/* 解析区 tips 板块：妙题绝招 / 做1题会4题 / 丢分警示 */
.tips-box { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.tip-item { border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.6; }
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-text { color: #4a5568; white-space: pre-wrap; }
.tip-miaoti { background: #e6f7ff; border-left: 3px solid #1890ff; }
.tip-miaoti .tip-title { color: #1890ff; }
.tip-zuoti { background: #f6ffed; border-left: 3px solid #52c41a; }
.tip-zuoti .tip-title { color: #52c41a; }
.tip-diushi { background: #fffbe6; border-left: 3px solid #faad14; }
.tip-diushi .tip-title { color: #faad14; }
