/* ===================================================================
   考研错题本 — 移动端优先样式表
   配色：蓝灰主色调，清爽干净
   =================================================================== */

/* --- 重置 & 基础 --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #1f2937;
  background: #f3f4f6;
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* --- 容器 --- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- 页头 --- */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  height: 52px;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
}
.logo:hover { text-decoration: none; }

/* --- 主内容 --- */
.main-content {
  padding-top: 20px;
  padding-bottom: 80px;
}

/* --- Flash 消息 --- */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.flash-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* --- 页面标题 --- */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.back-link {
  font-size: 0.9rem;
  color: #6b7280;
  white-space: nowrap;
}
.back-link:hover { color: #2563eb; }

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
  min-height: 44px;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-outline {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
}
.btn-outline:hover { background: #f9fafb; border-color: #9ca3af; }

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-height: 32px;
}

.btn-block { width: 100%; }
.btn-half { width: calc(50% - 4px); }

.btn-correct {
  background: #059669;
  color: #fff;
  border-color: #059669;
}
.btn-correct:hover { background: #047857; }

.btn-wrong {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.btn-wrong:hover { background: #b91c1c; }

/* --- 快捷入口 --- */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.action-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 10px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.1s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.action-card:hover { transform: translateY(-1px); text-decoration: none; }

.action-icon { font-size: 1.6rem; }
.action-title {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.9rem;
}
.action-desc {
  font-size: 0.75rem;
  color: #9ca3af;
  line-height: 1.3;
}

/* --- 统计行 --- */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card-lg {
  padding: 24px 16px;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #2563eb;
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 2px;
}

/* --- 卡片容器通用 --- */
.section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* --- 书单（片区列表） --- */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  transition: background 0.1s;
}
.book-item:hover { background: #eff6ff; text-decoration: none; }

.book-name { font-weight: 500; color: #1f2937; }
.book-counts { display: flex; gap: 8px; font-size: 0.85rem; }
.book-total { color: #6b7280; }
.book-wrong { color: #dc2626; font-weight: 600; }

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: #6b7280;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: #374151;
}

.empty-state p {
  margin-bottom: 16px;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* --- 上传表单页 --- */
.upload-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.upload-form-page {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-btn {
  display: block;
  padding: 14px 20px;
  background: #eff6ff;
  color: #2563eb;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.15s;
}
.upload-btn:hover { background: #dbeafe; }
.upload-btn input[type="file"] { display: none; }

.upload-preview {
  margin-top: 8px;
  text-align: center;
  min-height: 0;
}
.upload-preview img {
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

/* --- 确认页 --- */
.upload-confirm {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.confirm-section {
  padding: 20px;
  border-bottom: 1px solid #f3f4f6;
}

.confirm-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}

.image-preview {
  background: #f9fafb;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 12px;
  max-height: 280px;
  overflow: hidden;
}

.image-preview img {
  max-height: 260px;
  object-fit: contain;
  margin: 0 auto;
}

.img-error, .img-placeholder {
  padding: 32px;
  color: #9ca3af;
  font-size: 0.9rem;
  text-align: center;
}

.confirm-form {
  padding: 0;
}

.confirm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}

.meta-chip {
  font-size: 0.85rem;
  color: #374151;
  background: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

/* --- 表单 --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-group textarea,
.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s;
  font-family: inherit;
  line-height: 1.5;
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
}

.form-actions .btn {
  flex: 1;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.input-sm {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
}
.input-sm:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* --- 复习页面 --- */
.filter-bar {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 100px;
}

.filter-group label {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.filter-group select {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
}

.filter-bar .btn {
  min-width: 60px;
}

/* --- 复习卡片 --- */
.review-session { position: relative; }

.review-progress {
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 12px;
  font-weight: 500;
}

.review-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.review-card.hidden { display: none; }

.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.card-book {
  background: #eff6ff;
  color: #2563eb;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.card-ref {
  background: #f3f4f6;
  color: #6b7280;
  padding: 2px 8px;
  border-radius: 4px;
}

.card-question {
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 16px;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-mistake {
  font-size: 0.85rem;
  color: #92400e;
  background: #fffbeb;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  border-left: 3px solid #f59e0b;
}

.card-answer { margin-bottom: 16px; }

.answer-divider {
  text-align: center;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.answer-content {
  font-size: 1rem;
  line-height: 1.8;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.answer-empty { color: #9ca3af; font-style: italic; }

.card-actions { display: flex; gap: 8px; }
.card-actions.hidden { display: none; }

/* --- 复习完成 --- */
.review-done {
  text-align: center;
  padding: 48px 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.review-done.hidden { display: none; }

.done-icon { font-size: 3rem; margin-bottom: 12px; }
.review-done h3 { font-size: 1.2rem; margin-bottom: 8px; }
.review-done p { color: #6b7280; margin-bottom: 20px; }

.done-actions { display: flex; gap: 12px; justify-content: center; }

/* --- 统计页 --- */
.kp-stats-table {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kp-stat-row {
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
}
.kp-stat-row:last-child { border-bottom: none; padding-bottom: 0; }

.kp-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.kp-stat-name { font-weight: 600; font-size: 0.95rem; }
.kp-stat-counts { font-size: 0.8rem; color: #9ca3af; }

.kp-stat-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.kp-stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-low { background: #ef4444; }
.bar-mid { background: #f59e0b; }
.bar-high { background: #10b981; }
.bar-empty { background: #e5e7eb; }

.kp-stat-accuracy { font-size: 0.85rem; color: #6b7280; }
.kp-stat-untested { color: #9ca3af; font-style: italic; }

/* 最近记录 */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.recent-item:last-child { border-bottom: none; }

.recent-result {
  font-size: 1.2rem;
  flex-shrink: 0;
  padding-top: 2px;
}

.recent-body { flex: 1; min-width: 0; }

.recent-question {
  font-size: 0.9rem;
  color: #1f2937;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-meta {
  font-size: 0.8rem;
  color: #9ca3af;
  display: flex;
  gap: 12px;
}

/* --- 页脚 --- */
.site-footer {
  text-align: center;
  padding: 20px 0;
  color: #9ca3af;
  font-size: 0.8rem;
  border-top: 1px solid #e5e7eb;
  margin-top: 20px;
}

/* --- 隐藏工具 --- */
.hidden { display: none !important; }

/* --- 响应式 --- */
@media (max-width: 400px) {
  .quick-actions { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kp-stat-header { flex-direction: column; align-items: flex-start; gap: 2px; }
}
