/* AMC8 模考主题：深蓝主色 + 中文字体 */
:root {
  --primary: #1c3d6e;
  --primary-dark: #142c50;
  --accent: #e8a020;
  --bg: #f2f5fa;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #dfe5ee;
  --ok: #1e8e4f;
  --ok-bg: #e6f6ec;
  --no: #c0392b;
  --no-bg: #fdeceb;
  --flag: #b0620a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

/* 顶栏 */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(20, 44, 80, .25);
}
.appbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-badge {
  flex: none;
  background: var(--accent); color: var(--primary-dark);
  font-weight: 700; font-size: 14px; letter-spacing: .5px;
  padding: 5px 10px; border-radius: 8px;
}
.appbar .title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .sub { font-size: 12px; opacity: .8; }
.appbar .actions { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.appbar a { color: #fff; text-decoration: none; opacity: .85; }
.appbar a:hover { opacity: 1; }

/* 计时器 */
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 18px;
  background: rgba(255,255,255,.15);
  padding: 4px 12px; border-radius: 8px;
}
.timer.low { background: var(--no); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

main { max-width: 880px; margin: 0 auto; padding: 18px 16px 90px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(28, 61, 110, .06);
}
.card-title { margin: 0 0 12px; font-size: 18px; color: var(--primary-dark); }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

/* 按钮 */
.btn {
  display: inline-block; border: none; cursor: pointer;
  background: var(--primary); color: #fff;
  font-size: 15px; font-family: inherit;
  padding: 10px 22px; border-radius: 9px;
  text-decoration: none; text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: #e8edf5; color: var(--primary-dark); }
.btn.secondary:hover { background: #dbe3ef; }
.btn.danger { background: var(--no); }
.btn.danger:hover { background: #a02f22; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* 登录页 */
.login-wrap { max-width: 400px; margin: 8vh auto 0; padding: 0 16px; }
.login-wrap .brand-badge { font-size: 18px; padding: 8px 14px; }
.login-head { text-align: center; margin-bottom: 18px; color: var(--primary-dark); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; margin-bottom: 5px; color: var(--primary-dark); font-weight: 500; }
.field input {
  width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28,61,110,.12); }
.login-tip { font-size: 13px; color: var(--muted); text-align: center; margin-top: 14px; }

/* 试卷选择网格 */
.paper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.paper-cell {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; text-align: center;
  color: var(--ink); text-decoration: none; cursor: pointer;
  transition: transform .08s, border-color .12s;
}
.paper-cell:hover { border-color: var(--primary); transform: translateY(-2px); }
.paper-cell .yr { font-size: 20px; font-weight: 700; color: var(--primary); }
.paper-cell .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 答题工具条 */
.q-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 14px; }
.q-num { font-weight: 700; color: var(--primary); }
.flag-btn {
  border: 1px solid var(--flag); color: var(--flag); background: #fff;
  font-size: 13px; padding: 5px 12px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.flag-btn.flagged { background: var(--flag); color: #fff; }

.statement { font-size: 16px; margin-bottom: 6px; white-space: pre-wrap; }
.figure { margin: 10px 0; text-align: center; overflow-x: auto; }
.figure img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.figure img.wide { max-width: none; }

/* 选项 */
.opts { list-style: none; margin: 12px 0 0; padding: 0; }
.opts li { margin-bottom: 8px; }
.opt {
  display: flex; align-items: baseline; gap: 10px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 14px; cursor: pointer; background: #fff;
}
.opt:hover { border-color: var(--primary); }
.opt input { flex: none; }
.opt-letter { flex: none; font-weight: 700; color: var(--primary); }
.opt.selected { border-color: var(--primary); background: #eef3fb; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong-pick { border-color: var(--no); background: var(--no-bg); }
.opt:has(input:checked) { border-color: var(--primary); background: #eef3fb; }
.badge {
  flex: none; font-size: 12px; padding: 2px 8px; border-radius: 20px; margin-left: auto;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.no { background: var(--no-bg); color: var(--no); }

/* 答题卡导航盘 */
.palette-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dot {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; cursor: pointer; background: #fff; user-select: none;
}
.dot:hover { border-color: var(--primary); }
.dot.current { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); font-weight: 700; }
.dot.answered { background: var(--primary); color: #fff; border-color: var(--primary); }
.dot.flagged::after { content: "⚑"; position: absolute; margin: -18px 0 0 20px; color: var(--flag); font-size: 12px; }
.dot { position: relative; }

/* 底部操作栏 */
.quiz-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; gap: 10px; justify-content: center;
  padding: 10px 16px; background: #fff; border-top: 1px solid var(--line);
}

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(15, 25, 45, .45);
  align-items: center; justify-content: center; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 22px;
  max-width: 420px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}

/* 结果页 */
.score-hero { text-align: center; padding: 26px 0 10px; }
.score-num { font-size: 56px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.score-num small { font-size: 22px; color: var(--muted); font-weight: 500; }
.rv-q { margin-bottom: 14px; }
.rv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.rv-opts .opt { cursor: default; }

/* 历史/后台表格 */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.list th { color: var(--primary-dark); font-weight: 600; background: #f7f9fc; }
table.list tr:hover td { background: #f4f7fc; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%) translateY(20px);
  background: #222c3a; color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 99; font-size: 14px;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.admin-key-row { display: flex; gap: 10px; margin-bottom: 16px; }
.admin-key-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

@media (max-width: 600px) {
  .dots { grid-template-columns: repeat(5, 1fr); }
  .score-num { font-size: 44px; }
  main { padding: 14px 12px 90px; }
}
