:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #8a9099;
  --line: #e6e8eb;
  --brand: #2f6feb;
  --brand-dark: #2456b8;
  --ok: #1a7f37;
  --danger: #d1242f;
  --warn: #d1242f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.6;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); }
.ok { color: var(--ok); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 14px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card.narrow { max-width: 460px; margin: 40px auto; }

label { display: block; margin: 12px 0; font-weight: 600; font-size: 14px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-right: 18px; }
input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
label.inline input, label.inline select { width: auto; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #cfe0ff; border-color: var(--brand); }

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn:hover { background: var(--brand-dark); }
.btn.big { padding: 14px 32px; font-size: 17px; }
.btn:disabled { background: #b9c4d6; cursor: not-allowed; }
.mini {
  background: #eef1f5; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; font-size: 12px; cursor: pointer; color: var(--ink);
}
.link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 14px; padding: 0; }
.link.danger { color: var(--danger); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* 答题页顶栏 + 计时器 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 8px;
}
.topbar .tname { font-weight: 700; }
.topbar .tuser { color: var(--muted); font-size: 14px; }
.timer {
  margin-left: auto; font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 700; color: var(--brand);
  background: #eef4ff; border-radius: 8px; padding: 4px 14px;
}
.timer.warn { color: #fff; background: var(--warn); }

.q .qhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.qno {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
}
.qtype { font-size: 12px; color: var(--brand); background: #eef4ff; border-radius: 6px; padding: 2px 8px; }
.qpts { font-size: 12px; color: var(--muted); margin-left: auto; }
.prompt { font-size: 16px; margin: 6px 0 12px; white-space: pre-wrap; }

.options .opt {
  display: flex; align-items: flex-start; gap: 10px; font-weight: 400;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; cursor: pointer;
}
.options .opt:hover { border-color: var(--brand); }
.options .opt input { width: auto; margin-top: 4px; }

.actions { display: flex; align-items: center; gap: 16px; justify-content: flex-end; margin-top: 20px; }

/* 后台导航 */
.adminnav {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.adminnav strong { margin-right: auto; font-size: 16px; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.tbl th { background: #f0f2f5; font-weight: 600; }
.tbl tr:last-child td { border-bottom: none; }
.ops { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inlineform { display: inline; }
.linkcell { max-width: 260px; word-break: break-all; }
.linkrow { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }

.qlist { list-style: none; padding: 0; }
.optlist { margin: 8px 0; padding-left: 22px; }
.optlist li { padding: 4px 0; }
.optlist li.correct { color: var(--ok); font-weight: 600; }
.optlist li.chosen { background: #fff8e6; border-radius: 4px; }
.tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; margin-left: 8px; }
.tag.ok { background: #e6f4ea; color: var(--ok); }
.tag.pick { background: #fff2cc; color: #9a6700; }
.answerbox {
  white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; margin: 8px 0; min-height: 60px;
}
details.editbox { margin-top: 10px; }
details.editbox > summary {
  cursor: pointer; color: var(--brand); font-size: 14px; font-weight: 600;
  list-style: none; display: inline-block;
}
details.editbox > summary::before { content: '▸ '; }
details.editbox[open] > summary::before { content: '▾ '; }
details.editbox[open] > summary { margin-bottom: 8px; }
.result { font-weight: 600; }
.result.right { color: var(--ok); }
.result.wrong { color: var(--danger); }
.scoreline { font-size: 15px; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
  .wrap { padding: 12px 10px 48px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
  .card { padding: 14px; }
  .card.narrow { margin: 20px auto; }

  /* 答题页顶栏：换行不挤，计时器单独一行靠右 */
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .topbar .tname { font-size: 15px; }
  .topbar .tuser { font-size: 13px; }
  .timer { font-size: 19px; padding: 3px 12px; margin-left: auto; }

  /* 选项加大点击区域 */
  .options .opt { padding: 13px 12px; }
  .prompt { font-size: 15px; }

  /* 交卷按钮整行 */
  .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .actions .btn.big { width: 100%; }
  #savehint { text-align: center; }

  /* 表格横向滚动 + 收紧 */
  .tbl th, .tbl td { padding: 8px 8px; font-size: 13px; white-space: nowrap; }
  .linkcell { max-width: 180px; }
  .ops { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* 表单控件整行 */
  .row { flex-direction: column; align-items: stretch; }
  .row input, .row .btn { width: 100%; }
  label.inline { display: flex; width: 100%; justify-content: space-between; margin-right: 0; }
  label.inline input, label.inline select { width: auto; min-width: 110px; }

  .adminnav { flex-wrap: wrap; gap: 8px 12px; }
  .adminnav strong { width: 100%; margin-right: 0; }
}
