:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --primary: #2f6fed;
  --primary-d: #1f57c9;
  --text: #1f2733;
  --muted: #8a94a6;
  --border: #e6eaf2;
  --green: #25b865;
  --red: #e8503a;
  --shadow: 0 4px 16px rgba(31, 39, 51, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: #1f2733;
  color: #cfd6e2;
  padding: 20px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.logo { font-size: 22px; font-weight: 700; color: #fff; padding: 0 22px 18px; display: flex; align-items: center; gap: 10px; }
.ico { width: 20px; height: 20px; flex-shrink: 0; }
.logo .ico { width: 24px; height: 24px; }
.sidebar nav { flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 22px;
  cursor: pointer;
  font-size: 15px;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active {
  background: rgba(47,111,237,.18);
  border-left-color: var(--primary);
  color: #fff;
}
.sidebar-foot { padding: 16px 22px 0; font-size: 12px; color: #6b7488; }

/* 内容区 */
.content { flex: 1; padding: 28px 36px; max-width: 920px; }
.view h2 { font-size: 22px; margin-bottom: 18px; }

/* 卡片 */
.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h3 { font-size: 17px; margin-bottom: 12px; }

/* 按钮 */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}
.btn:hover { border-color: #c7d0e0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { color: var(--red); border-color: #f3c2bb; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.empty {
  background: var(--panel);
  border-radius: 12px;
  padding: 50px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.empty .hint { margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; }

/* 练习条 */
.practice-bar, .exam-bar {
  display: flex;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: 14px;
  flex-wrap: wrap;
}
.exam-bar { justify-content: space-between; }
.exam-timer { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.exam-timer.danger { color: var(--red); }

/* 题目卡 */
.q-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.q-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; color: #fff; }
.badge-single { background: #2f6fed; }
.badge-multiple { background: #9b59d0; }
.badge-judge { background: #f0922f; }
.badge-qa { background: #2bb5a0; }
.q-history { font-size: 12px; color: var(--muted); }
.q-stem { font-size: 17px; font-weight: 600; margin-bottom: 16px; white-space: pre-wrap; }
.q-stem.small { font-size: 15px; font-weight: 500; }

.q-options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .12s;
}
.opt:hover { border-color: #b9c6e6; background: #f8faff; }
.opt input { width: 18px; height: 18px; accent-color: var(--primary); }
.opt-key {
  width: 24px; height: 24px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef2fb; border-radius: 50%; font-size: 13px; font-weight: 600; color: var(--primary);
}
.opt-text { flex: 1; }
.opt-selected { border-color: var(--primary); background: #f3f7ff; }
.opt-correct { border-color: var(--green); background: #ecfaf1; }
.opt-correct .opt-key { background: var(--green); color: #fff; }
.opt-wrong { border-color: var(--red); background: #fdecea; }
.opt-wrong .opt-key { background: var(--red); color: #fff; }

.q-feedback { margin-top: 16px; font-weight: 600; padding: 10px 14px; border-radius: 8px; }
.fb-right { color: var(--green); background: #ecfaf1; }
.fb-wrong { color: var(--red); background: #fdecea; }
.q-analysis { margin-top: 12px; padding: 12px 14px; background: #f8fafc; border-radius: 8px; font-size: 14px; color: #46506a; }
.q-analysis.small { font-size: 13px; }

/* 问答题（抢答/风险）显示答案模式 */
.qa-hint { margin-top: 14px; font-size: 14px; color: var(--muted); background: #f3f7ff; padding: 12px 14px; border-radius: 8px; }
.q-answer-box { margin-top: 14px; padding: 14px; background: #ecfaf1; border: 1px solid #bfe9cf; border-radius: 8px; }
.q-answer-box b { color: var(--green); }
.q-answer-text { margin-top: 6px; font-size: 15px; line-height: 1.7; white-space: pre-wrap; }

/* 题型筛选 */
.type-filter { background: var(--panel); border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.tf-title { font-size: 14px; margin-bottom: 10px; color: var(--muted); }
.tf-row { display: flex; flex-wrap: wrap; gap: 14px; }
.tf-item { font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tf-item input { width: 16px; height: 16px; accent-color: var(--primary); }

.q-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* 考试进度点 */
.exam-progress { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.dot {
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; background: #e9edf5; color: #6b7488;
}
.dot.done { background: var(--green); color: #fff; }
.dot.cur { outline: 2px solid var(--primary); outline-offset: 1px; }

/* 考试结果 */
.result-card { text-align: center; }
.result-card h2 { font-size: 24px; margin-bottom: 6px; }
.result-card .pass { color: var(--green); }
.result-card .fail { color: var(--red); }
.score { font-size: 56px; font-weight: 800; color: var(--primary); margin: 10px 0; }
.score span { font-size: 20px; color: var(--muted); margin-left: 6px; }
.result-stats { display: flex; justify-content: center; gap: 28px; margin: 18px 0; flex-wrap: wrap; }
.result-stats div { text-align: center; }
.result-stats b { font-size: 22px; display: block; }
.result-stats span { font-size: 12px; color: var(--muted); }

/* 统计 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); text-align: center; }
.stat-val { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-label { width: 70px; font-size: 14px; }
.bar-track { flex: 1; height: 12px; background: #eef2fb; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #2f6fed, #57c0ff); border-radius: 8px; }
.bar-num { font-size: 12px; color: var(--muted); width: 180px; text-align: right; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl .pass { color: var(--green); font-weight: 600; }
.tbl .fail { color: var(--red); font-weight: 600; }

/* 错题本 */
.wrong-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.wrong-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.wrong-item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.wrong-item-head .btn { margin-left: auto; }
.wrong-ans { font-size: 13px; color: var(--red); margin: 6px 0; }

/* 题库管理 */
.prev-item { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row label { width: 150px; font-size: 14px; }
.form-row input[type="number"] { width: 90px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }
.form-row input[type="file"] { font-size: 13px; }
pre { background: #f3f5fa; padding: 10px 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; margin-top: 6px; }

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,28,40,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 10px; }
.modal textarea {
  width: 100%; min-height: 180px; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 14px; font-family: inherit; resize: vertical; margin: 10px 0;
}
#import-msg { color: var(--red); min-height: 18px; }

.mobile-topbar { display: none; }

/* ---------------- 手机端：底部 Tab + App 式布局 ---------------- */
@media (max-width: 720px) {
  body { -webkit-text-size-adjust: 100%; }
  .app { flex-direction: column; }

  /* 顶部标题条 */
  .mobile-topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 30;
    background: #1f2733; color: #fff;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    font-size: 17px; font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
  }
  .mobile-topbar span { color: #9aa6bb; font-weight: 400; font-size: 13px; }

  /* 侧边栏 → 固定底部 Tab 栏 */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    width: 100%; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    flex-direction: column; background: #1f2733;
    box-shadow: 0 -3px 14px rgba(0,0,0,.16);
  }
  .logo, .sidebar-foot { display: none; }
  .sidebar nav { display: flex; width: 100%; }
  .nav-item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 7px 2px; font-size: 11px; line-height: 1.35;
    border-left: none; border-bottom: none; border-top: 3px solid transparent;
    white-space: nowrap; touch-action: manipulation;
  }
  .nav-item.active { border-left: none; border-top-color: var(--primary); background: rgba(47,111,237,.16); color: #fff; }
  .nav-item .ico { width: 22px; height: 22px; }

  /* 内容区给底部 Tab 留空间 */
  .content {
    padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .view h2 { font-size: 19px; margin-bottom: 14px; }

  /* 更大的点击区域 */
  .btn { padding: 12px 18px; font-size: 15px; min-height: 46px; touch-action: manipulation; }
  .btn-sm { min-height: 36px; padding: 8px 14px; font-size: 13px; }
  .q-card, .card, .type-filter { padding: 16px; }
  .q-stem { font-size: 16px; }
  .opt { padding: 14px 12px; min-height: 54px; touch-action: manipulation; }
  .opt input { width: 22px; height: 22px; }
  .opt-key { width: 28px; height: 28px; font-size: 14px; }
  .q-actions { gap: 10px; }
  .q-actions .btn { flex: 1; min-width: 120px; }
  .tf-item { min-height: 40px; font-size: 15px; }
  .tf-item input { width: 20px; height: 20px; }
  .tf-row { gap: 12px 18px; }

  /* 统计与进度条 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-val { font-size: 24px; }
  .bar-row { flex-wrap: wrap; gap: 6px 10px; }
  .bar-label { width: 60px; }
  .bar-track { flex: 1 1 100%; order: 3; }
  .bar-num { width: auto; text-align: left; order: 2; font-size: 11px; }
  .result-stats { gap: 14px; }
  .score { font-size: 48px; }

  /* 表单与进度点 */
  .form-row label { width: 100%; }
  .form-row input[type="number"] { min-height: 44px; font-size: 16px; }
  .exam-progress { gap: 5px; }
  .dot { width: 30px; height: 30px; font-size: 13px; }
  .exam-bar { gap: 10px; font-size: 13px; padding: 10px 14px; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 8px 6px; }
  .modal { padding: 18px; }
}
