:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --amber: #d97706;
  --green: #16a34a;
  --red: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
/* 触屏优化：去掉点击高亮、消除双击缩放延迟 */
.btn, .option, .p-item, .nav-link, .palette-head {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 导航 ---------- */
.navbar { background: #1e1b4b; color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.nav-inner {
  max-width: 1000px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 17px; padding: 14px 0; }
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link { color: #c7d2fe; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-user { color: #a5b4fc; font-size: 13px; margin: 0 6px; }

/* ---------- 布局 ---------- */
.container { max-width: 1000px; margin: 24px auto 40px; padding: 0 16px; }
.footer { text-align: center; color: #94a3b8; font-size: 13px; padding: 18px 0 28px; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(15,23,42,.06);
}
.center-card { text-align: center; padding: 48px 24px; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 19px; }
h3 { font-size: 17px; margin: 0 0 6px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.green { color: var(--green); }
.red { color: var(--red); }
.section-title { margin: 26px 4px 14px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 9px 18px; border-radius: 10px; font-size: 14px; cursor: pointer;
  text-decoration: none; transition: all .15s; font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-amber:hover { background: #b45309; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 徽标 / 提示 ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; vertical-align: middle;
}
.badge-blue  { background: #e0e7ff; color: #4338ca; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red   { background: #fee2e2; color: #b91c1c; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn  { background: #fef3c7; color: #92400e; }
.empty { color: var(--muted); padding: 12px 0; }
.empty.big { text-align: center; font-size: 17px; padding: 40px 0; }

/* ---------- 首页 ---------- */
.hero { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); color: #fff; padding: 34px 30px; }
.hero h1 { font-size: 28px; }
.hero p { color: #e0e7ff; margin: 8px 0 0; }
.hero b { color: #fde047; }
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.cards2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 18px; }
.statcard { text-align: center; }
.stat-num { font-size: 34px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 13px; }
.action-card h3 { font-size: 18px; }
.action-card .btn { margin-top: 10px; }

/* ---------- 表格（小屏横向滚动） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 620px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: #f8fafc; }
.q-cell { max-width: 340px; }
.table a { white-space: nowrap; }

/* ---------- 表单 ---------- */
.auth-card { max-width: 420px; margin: 40px auto; padding: 32px 34px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; font-family: inherit; outline: none; transition: border .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; }

/* ---------- 考试页 ---------- */
.exam-wrap { max-width: 780px; margin: 0 auto; }
.exam-bar {
  position: sticky; top: 10px; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px; flex-wrap: wrap;
}
.exam-bar-left, .exam-bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-text { font-weight: 700; font-size: 16px; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px;
  background: #f1f5f9; border-radius: 8px; padding: 4px 10px;
}
.palette-card { padding: 14px 18px; }
.palette-head {
  font-size: 13px; margin-bottom: 8px; display: flex; align-items: center;
  justify-content: space-between; cursor: pointer; user-select: none;
}
.palette-head .chev { transition: transform .2s; color: var(--muted); }
.palette-head-right { display: inline-flex; align-items: center; gap: 8px; }
.palette-head.closed .chev { transform: rotate(-90deg); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; max-height: 180px; overflow-y: auto; }
.palette.collapsed { display: none; }
.p-item {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  font-size: 12px; padding: 5px 0; cursor: pointer; text-align: center; font-family: inherit;
}
.p-item.answered { background: var(--primary); border-color: var(--primary); color: #fff; }
.p-item.current { outline: 2px solid #f59e0b; outline-offset: 1px; font-weight: 700; }
.qcard { min-height: 260px; }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mark { font-size: 20px; }
.q-stem { font-size: 19px; font-weight: 700; margin-bottom: 20px; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .12s;
  position: relative; flex-wrap: wrap;
}
.option:hover { border-color: var(--primary); background: #f5f3ff; }
.option.selected { border-color: var(--primary); background: #eef2ff; }
.option.correct { border-color: var(--green); background: #f0fdf4; }
.option.wrong { border-color: var(--red); background: #fef2f2; }
.opt-letter {
  width: 30px; height: 30px; border-radius: 50%; background: #e2e8f0; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none;
}
.option.selected .opt-letter { background: var(--primary); color: #fff; }
.option.correct .opt-letter { background: var(--green); color: #fff; }
.option.wrong .opt-letter { background: var(--red); color: #fff; }
.opt-tag { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--green); }
.opt-tag.bad { color: var(--red); }
.fill-input {
  width: 100%; font-size: 18px; padding: 14px 16px; border: 1.5px solid var(--border);
  border-radius: 12px; outline: none; font-family: inherit; margin-bottom: 8px;
}
.fill-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.fill-review p { margin: 6px 0; font-size: 15px; }
.qnav { display: flex; justify-content: space-between; gap: 12px; }
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 99; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 成绩页 ---------- */
.result-head { text-align: center; padding: 34px 24px; }
.result-badge { font-size: 46px; }
.result-head h1 { font-size: 46px; margin: 6px 0; color: var(--primary); }
.score-unit { font-size: 15px; color: var(--muted); font-weight: 400; }
.result-badges { margin: 10px 0 16px; }
.result-badges .badge { margin: 0 4px; font-size: 13px; padding: 4px 14px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.qc-ok   { border-left: 5px solid var(--green); }
.qc-bad  { border-left: 5px solid var(--red); }

/* ---------- 平板（≤1024px） ---------- */
@media (max-width: 1024px) {
  .container { max-width: 100%; }
  .cards3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 手机（≤720px） ---------- */
@media (max-width: 720px) {
  .container { margin: 14px auto 32px; padding: 0 12px; }
  .card { padding: 16px 14px; border-radius: 12px; }

  /* 导航 */
  .brand { font-size: 15px; padding: 10px 0; }
  .nav-inner { padding: 0 10px; }
  .nav-link { padding: 7px 9px; font-size: 13px; }
  .nav-user { display: none; }

  /* 首页 */
  .hero { padding: 22px 18px; }
  .hero h1 { font-size: 21px; }
  .cards3, .cards2 { grid-template-columns: 1fr; gap: 12px; }
  .stat-num { font-size: 27px; }
  h1 { font-size: 20px; }
  h2.section-title { font-size: 17px; margin: 20px 2px 12px; }

  /* 表单 */
  .auth-card { margin: 18px auto; padding: 24px 18px; }

  /* 表格密度（外层 .table-wrap 负责横向滚动） */
  .table { font-size: 13px; }
  .table th { padding: 8px 6px; }
  .table td { padding: 8px 6px; }
  .q-cell { max-width: 200px; }
  .btn-col { flex-direction: row; width: 100%; }
  .btn-col .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; }

  /* 考试页 */
  .exam-bar { top: 6px; padding: 9px 12px; gap: 8px; }
  .progress-text { font-size: 14px; }
  .timer { font-size: 14px; padding: 3px 8px; }
  .exam-bar .btn { padding: 7px 14px; }
  .palette-card { padding: 10px 12px; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 5px; max-height: 132px; }
  .p-item { font-size: 11px; padding: 4px 0; border-radius: 7px; }
  .qcard { min-height: 180px; padding: 16px 14px; }
  .q-stem { font-size: 17px; margin-bottom: 16px; }
  .option { padding: 12px 13px; gap: 10px; }
  .opt-letter { width: 28px; height: 28px; font-size: 14px; }
  .fill-input { font-size: 18px; padding: 12px 14px; }
  .fill-review { font-size: 14px; }

  /* 底部翻题栏：吸底便于拇指操作 */
  .qnav {
    position: sticky; bottom: 0; z-index: 15;
    background: rgba(241, 245, 249, .92);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    padding: 10px 2px calc(10px + env(safe-area-inset-bottom, 0px));
    margin-bottom: 0;
  }
  .qnav .btn { flex: 1; padding: 13px 0; font-size: 16px; }

  /* 成绩页 */
  .result-head { padding: 24px 14px; }
  .result-head h1 { font-size: 34px; }
  .result-badge { font-size: 38px; }
  .result-actions .btn { flex: 1; min-width: 130px; }
}

/* ---------- 小屏手机（≤480px） ---------- */
@media (max-width: 480px) {
  .brand { font-size: 14px; }
  .nav-link { padding: 6px 7px; font-size: 12px; }
  .hero p { font-size: 13px; }
  .opt-tag { margin-left: 0; width: 100%; }   /* “正确答案/你的答案”标记独占一行 */
  .exam-bar-left { gap: 8px; }
}
