/* ===== gls错题本 H5 样式(移动端优先) ===== */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a919f;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --orange-bg: #fef3c7;
  --orange-text: #92400e;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --green-bg: #dcfce7;
  --green-text: #166534;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 18px; font-weight: 700; color: var(--text); }
.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: var(--muted); font-size: 14px; }
.nav a.active, .nav a:hover { color: var(--primary); font-weight: 600; }
.nav-user { color: var(--text); font-size: 14px; font-weight: 600; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 { font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 400; }

/* 提示条 */
.flashes { max-width: 720px; margin: 10px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; font-size: 14px; }
.flash-ok { background: var(--green-bg); color: var(--green-text); }
.flash-error { background: var(--red-bg); color: var(--red-text); }

/* 登录注册 */
.auth-card {
  max-width: 380px; margin: 40px auto; padding: 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.auth-card h2 { margin-bottom: 16px; text-align: center; }
.auth-tip { margin-top: 14px; text-align: center; font-size: 14px; }
.auth-hint { margin-top: 6px; text-align: center; color: var(--muted); font-size: 12px; }

/* 表单 */
form label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; background: var(--card); color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type="file"] { margin-top: 6px; font-size: 14px; }
.radio-row { display: flex; gap: 18px; }
.radio { display: flex; align-items: center; gap: 6px; font-weight: 400 !important; margin: 0 !important; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-preview { max-width: 100%; margin-top: 10px; border-radius: 8px; border: 1px solid var(--border); }

/* 按钮 */
.btn {
  display: inline-block; padding: 9px 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
  font-size: 14px; cursor: pointer; text-align: center;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; margin-top: 16px; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-plain { background: transparent; }
.btn-block { display: block; width: 100%; }

/* 筛选栏 */
.filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.filter-bar select, .filter-bar input { font-size: 14px; padding: 8px 10px; }
.filter-bar .btn { margin-top: 0; }

/* 错题卡片列表 */
.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-card {
  display: flex; gap: 12px; padding: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text);
}
.q-card:hover { border-color: var(--primary); }
.q-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.q-main { flex: 1; min-width: 0; }
.q-title { font-weight: 600; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; }
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.q-time { color: var(--muted); font-size: 12px; margin-left: auto; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.tag-warn { background: var(--orange-bg); color: var(--orange-text); border-color: transparent; }
.tag-ok { background: var(--green-bg); color: var(--green-text); border-color: transparent; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-status0 { background: var(--orange-bg); color: var(--orange-text); }
.badge-status1 { background: var(--red-bg); color: var(--red-text); }
.badge-status2 { background: var(--green-bg); color: var(--green-text); }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }

/* 空状态 */
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* 详情 */
.detail-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.d-row { display: flex; gap: 10px; padding: 6px 0; }
.d-label { flex: 0 0 84px; color: var(--muted); font-size: 14px; }
.d-row > div { flex: 1; min-width: 0; }
.pre-wrap { white-space: pre-wrap; word-break: break-all; }
.detail-photo { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.ai-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 700; margin-bottom: 8px;
}
.ai-card { border-left: 3px solid var(--primary); }
.btn-small { padding: 5px 12px; font-size: 13px; margin: 0; }
.ai-error {
  color: var(--red-text); background: var(--red-bg);
  padding: 8px 12px; border-radius: 8px; font-size: 14px;
}
.ai-progress {
  background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 14px;
}
.review-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--border); }
.review-row:first-of-type { border-top: none; }

/* 操作栏 */
.action-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.inline-form { display: inline; }

/* 统计 */
.stat-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-chip {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table th, .stat-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); }
.stat-table th { color: var(--muted); font-weight: 500; }
.rate-bar {
  display: inline-block; width: 80px; height: 8px;
  background: var(--bg); border-radius: 999px; overflow: hidden; vertical-align: middle;
}
.rate-fill { height: 100%; background: var(--success); border-radius: 999px; }

/* 窄屏适配 */
@media (max-width: 480px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .d-label { flex-basis: 76px; }
  .q-time { margin-left: 0; width: 100%; }
}

/* ===== 录入模式卡片 ===== */
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.mode-card .mode-icon { width: 34px; height: 34px; fill: var(--muted); }
.mode-card .mode-name { font-size: 15px; font-weight: 600; color: var(--muted); }
.mode-card.active { border-color: var(--primary); background: #eff6ff; }
.mode-card.active .mode-icon, .mode-card.active .mode-name { color: var(--primary); }

/* 框选裁剪 */
.crop-section { margin-top: 12px; }
.crop-box { height: 320px; max-height: 60vh; overflow: hidden; border-radius: var(--radius); }
.crop-box img { display: block; max-width: 100%; }
/* 选框样式:红色虚线 + 可拖拽手柄 */
.cropper-view-box { outline: 2px dashed #ef4444; }
.cropper-line, .cropper-point { background-color: #ef4444; }
.cropper-point { width: 10px; height: 10px; opacity: .85; }
.crop-actions { display: flex; gap: 10px; margin-top: 10px; }
.crop-actions .btn { flex: 1; }
.photo-preview { margin-top: 10px; }
.photo-preview .btn { margin-top: 10px; }

/* 长按说话按钮 */
.rec-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 22px; border-radius: var(--radius);
  border: 2px solid var(--primary); background: var(--primary); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: none;
}
.rec-btn .rec-icon { width: 26px; height: 26px; fill: #fff; }
.rec-btn.recording { background: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }
.voice-preview { margin-top: 12px; }
.voice-preview audio { width: 100%; margin-bottom: 10px; }
.existing-media { margin-top: 14px; }
.existing-media audio { width: 100%; }

/* 列表语音占位缩略图 */
.q-thumb-audio {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; flex-shrink: 0;
  background: #eff6ff; border-radius: 8px;
  color: var(--primary); font-size: 13px; font-weight: 600;
}

/* 列表勾选框与浮动出卷栏 */
.q-check {
  width: 20px; height: 20px; flex-shrink: 0;
  margin-top: 2px; accent-color: var(--primary); cursor: pointer;
}
.q-card > a.q-main { display: block; flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.paper-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 16px; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.paper-bar-info { font-size: 14px; }

/* ===== 练习卷(A4纸张) ===== */
.sheet {
  max-width: 794px; margin: 0 auto; padding: 40px 48px 64px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.sheet-title { font-size: 22px; text-align: center; margin-bottom: 8px; }
.sheet-sub { color: var(--muted); font-size: 14px; text-align: center; margin-bottom: 24px; }
.paper-q { padding: 18px 0 6px; border-top: 1px dashed var(--border); }
.paper-q:first-of-type { border-top: none; }
.pq-head { display: flex; gap: 8px; }
.pq-no { font-weight: 700; flex-shrink: 0; }
.pq-content { flex: 1; min-width: 0; line-height: 1.9; }
.pq-fail { color: var(--red-text); }
.pq-fail .btn { margin-left: 10px; }
.write-space { height: 180px; margin: 8px 0 0 20px; }
.answer-area { margin: 10px 0 0 20px; }
.answer-box {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
}
.pq-retry { margin-left: 8px; }

/* ===== 错题分享图片 ===== */
/* 分享卡片:屏外渲染,颜色写死不依赖CSS变量,保证html2canvas截图稳定 */
.share-card {
  position: fixed; left: -9999px; top: 0; width: 640px;
  padding: 36px 32px; background: #ffffff; color: #1f2329;
  font-size: 15px; line-height: 1.75;
}
.sc-brand { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.sc-brand-name { font-size: 20px; font-weight: 700; color: #2f6bff; }
.sc-brand span:last-child { font-size: 13px; color: #9ca3af; }
.sc-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; word-break: break-all; }
.sc-meta { font-size: 13px; color: #6b7280; padding-bottom: 14px; border-bottom: 1px solid #eef0f3; }
.sc-label { font-size: 13px; font-weight: 700; color: #2f6bff; margin: 14px 0 4px; }
.sc-block { white-space: pre-wrap; word-break: break-word; }
.sc-photo { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.sc-foot { margin-top: 24px; padding-top: 14px; border-top: 1px solid #eef0f3; font-size: 12px; color: #9ca3af; text-align: center; }

/* 预览遮罩 */
.share-mask {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0;
  background: rgba(0,0,0,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.share-mask[hidden] { display: none; }
.share-mask-inner { max-height: 94vh; overflow: auto; text-align: center; }
.share-mask img { max-width: 100%; max-height: 70vh; border-radius: 8px; background: #fff; }
.share-mask p { color: #fff; font-size: 14px; margin: 10px 0; }

/* ===== 打印导出PDF(A4) ===== */
@media print {
  body { background: #fff; }
  .topbar, .flashes, .no-print, .page-head, .ai-progress { display: none !important; }
  .container { max-width: none; padding: 0; }
  .sheet {
    max-width: none; border: none; border-radius: 0;
    box-shadow: none; padding: 0;
  }
  /* 导出的卷子不含答案 */
  .answer-area { display: none !important; }
  /* 每题不跨页断开,保证手写空白完整 */
  .paper-q { page-break-inside: avoid; }
  .write-space { height: 200px; }
}
