:root {
  --brand: #C41E3A;
  --brand-dark: #9c162d;
  --brand-soft: #fdf1f3;
  --ink: #1b1b1b;
  --ink-2: #4a4a4a;
  --muted: #8a8580;
  --line: #e6e2de;
  --bg: #f6f5f3;
  --card: #ffffff;
  --ok: #1c7a4b;
  --warn: #b06a00;
  --shadow: 0 1px 2px rgba(20, 16, 14, .04), 0 8px 24px rgba(20, 16, 14, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #fbe9ec 0%, rgba(251, 233, 236, 0) 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 34px 30px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.brand-name {
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--muted);
}

.login-card h1 {
  font-size: 23px;
  line-height: 1.4;
  margin: 0 0 6px;
  letter-spacing: .01em;
}

.login-card .sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 15px;
  background: #fdfdfc;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, .1);
  background: #fff;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 11px 18px;
  font-size: 15px;
  background: var(--card);
  color: var(--ink);
  transition: all .15s;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
  font-weight: 500;
  letter-spacing: .04em;
}

.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost {
  border-color: var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
  padding: 8px 14px;
}

.btn-ghost:hover { border-color: #cfc9c3; background: #faf9f8; }

.btn-danger {
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  padding: 9px 18px;
}

.err {
  margin-top: 14px;
  color: var(--brand);
  font-size: 13px;
  min-height: 18px;
}

.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------------- 须知页 ---------------- */
.notice-card {
  width: 100%;
  max-width: 680px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 38px 30px;
}

.notice-card h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.notice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.pill {
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 100px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #f3d3d9;
}

.pill.plain {
  background: #f6f5f3;
  color: var(--ink-2);
  border-color: var(--line);
}

.notice-card ol {
  margin: 0 0 26px;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 14px;
}

.notice-card ol li { margin-bottom: 9px; }

.notice-actions { display: flex; gap: 12px; align-items: center; }
.notice-actions .btn-primary { width: auto; padding: 11px 30px; }

/* ---------------- 考试页 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar .title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.topbar .who {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.topbar .spacer { flex: 1; }

.timer {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 9px;
  background: #f6f5f3;
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.timer .num { font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.timer .lab { font-size: 11.5px; color: var(--muted); }

.timer.warn { background: #fff6e8; border-color: #f2ddb9; }
.timer.warn .num { color: var(--warn); }
.timer.danger { background: #fdeef1; border-color: #f3ccd4; }
.timer.danger .num { color: var(--brand); }

.save-hint { font-size: 12px; color: var(--muted); min-width: 96px; text-align: right; }

.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 22px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 84px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.side-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.side-title b { font-size: 17px; color: var(--brand); font-variant-numeric: tabular-nums; }

.progress {
  height: 4px;
  border-radius: 4px;
  background: #eeece9;
  overflow: hidden;
  margin: 8px 0 16px;
}

.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .3s; }

.nav-group { margin-bottom: 14px; }

.nav-group h4 {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 7px;
  letter-spacing: .04em;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.nav-btn {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fbfaf9;
  color: var(--ink-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  transition: all .12s;
}

.nav-btn:hover { border-color: #cfc9c3; }

.nav-btn.done {
  background: var(--brand-soft);
  border-color: #f0c8cf;
  color: var(--brand-dark);
  font-weight: 600;
}

.nav-btn.cur {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legend span::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: 0;
  border: 1px solid var(--line);
  background: #fbfaf9;
}

.legend span.d::before { background: var(--brand-soft); border-color: #f0c8cf; }
.legend span.c::before { background: var(--brand); border-color: var(--brand); }

.qarea { min-height: 520px; }

.qcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 34px 26px;
  box-shadow: var(--shadow);
}

.qhead {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.qno {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: .04em;
}

.qtype {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 100px;
  background: #f6f5f3;
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.qscore { font-size: 11.5px; color: var(--muted); margin-left: auto; }

.stem {
  font-size: 16.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  margin-bottom: 24px;
  letter-spacing: .01em;
}

.opts { display: flex; flex-direction: column; gap: 10px; }

.opt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fdfdfc;
  transition: all .13s;
  text-align: left;
  width: 100%;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
}

.opt:hover { border-color: #cfc9c3; background: #fff; }

.opt .k {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  margin-top: 1px;
}

.opt.sel {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.opt.sel .k { background: var(--brand); border-color: var(--brand); color: #fff; }

.tf-row { display: flex; gap: 12px; }

.tf-btn {
  flex: 1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fdfdfc;
  font-size: 17px;
  color: var(--ink);
  transition: all .13s;
}

.tf-btn:hover { border-color: #cfc9c3; }
.tf-btn.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

.blank-input {
  width: 100%;
  max-width: 460px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: #fdfdfc;
}

.blank-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, .1);
  background: #fff;
}

.essay-box {
  width: 100%;
  min-height: 190px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.8;
  resize: vertical;
  background: #fdfdfc;
}

.essay-box:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, .1);
  background: #fff;
}

.counter {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.qfoot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.qfoot .spacer { flex: 1; }

.hint-text { font-size: 12.5px; color: var(--muted); }

/* ---------------- 交卷 / 成绩 ---------------- */
.done-card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 40px 34px;
  text-align: center;
}

.done-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 18px;
}

.done-card h2 { font-size: 21px; margin: 0 0 8px; }
.done-card p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.score-row {
  display: flex;
  justify-content: center;
  gap: 34px;
  padding: 20px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.score-item .v { font-size: 27px; font-weight: 600; font-variant-numeric: tabular-nums; }
.score-item .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.score-item .v small { font-size: 14px; color: var(--muted); font-weight: 400; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 18, 16, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  padding: 26px 28px 22px;
  box-shadow: 0 20px 60px rgba(20, 16, 14, .2);
}

.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal p { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; line-height: 1.75; }
.modal .acts { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------- 管理端 ---------------- */
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }

.admin-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.admin-head h1 { font-size: 19px; margin: 0; }
.admin-head .spacer { flex: 1; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.grid th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf9;
  white-space: nowrap;
}

table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1eeeb;
  vertical-align: middle;
}

table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #fcfbfa; }

.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 100px;
  background: #f6f5f3;
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.tag.done { background: #edf6f1; color: var(--ok); border-color: #cfe7db; }
.tag.wait { background: #fff6e8; color: var(--warn); border-color: #f2ddb9; }
.tag.bad { background: var(--brand-soft); color: var(--brand-dark); border-color: #f0c8cf; }

.link-btn {
  border: none;
  background: none;
  color: var(--brand);
  font-size: 13px;
  padding: 2px 4px;
}

.link-btn:hover { text-decoration: underline; }

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 18, 16, .34);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(860px, 94vw);
  height: 100%;
  background: var(--bg);
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .12);
  animation: slide .22s ease-out;
}

@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.drawer-head {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { padding: 20px 24px 40px; }

.gcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.gcard .gh {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.gcard .gno { font-size: 13px; font-weight: 600; color: var(--brand); }
.gcard .gscore { margin-left: auto; font-size: 12.5px; color: var(--muted); }

.answer-box {
  background: #fbfaf9;
  border: 1px dashed #ddd7d2;
  border-radius: 9px;
  padding: 13px 15px;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  margin: 10px 0;
  max-height: 320px;
  overflow-y: auto;
}

.answer-box.empty { color: var(--muted); font-style: normal; }

details.rubric {
  margin: 8px 0 12px;
  font-size: 13px;
  color: var(--ink-2);
}

details.rubric summary {
  cursor: pointer;
  color: var(--brand);
  font-size: 12.5px;
  outline: none;
  user-select: none;
}

details.rubric .rb {
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.75;
  max-height: 300px;
  overflow-y: auto;
}

.grade-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

.grade-row input {
  width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

.grade-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(196, 30, 58, .1); }

.grade-row .full { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #241d1b;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 100px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .sidebar { position: static; order: 2; }
  .qcard { padding: 22px 20px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .who { display: none; }
  .stem { font-size: 15.5px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .notice-card, .login-card { padding: 26px 22px; }
}

/* ============================================================
   手机端（≤ 560px）专项优化 · 2026-10-23
   桌面端不受影响；核心变化：
   1) 顶栏精简：隐藏长标题与保存提示，保留计时 / 答题卡 / 交卷
   2) 答题卡改为底部滑出抽屉（点顶栏"答题卡"呼出，选题后自动收起）
   3) 输入框 16px 起，避免 iOS 聚焦自动放大
   4) 教师端表格横向滚动
   ============================================================ */
.nav-toggle { display: none; }
.nav-mask { display: none; }

@media (max-width: 560px) {
  /* ---- 顶栏 ---- */
  .topbar {
    padding: 0 12px 0 calc(12px + env(safe-area-inset-left));
    gap: 8px;
    padding-top: env(safe-area-inset-top);
  }
  .topbar .title { display: none; }
  .topbar .save-hint { display: none; }
  .nav-toggle {
    display: inline-block;
    white-space: nowrap;
    font-size: 13px;
    padding: 8px 12px;
  }
  .nav-toggle b { font-variant-numeric: tabular-nums; }
  .btn-danger { padding: 9px 14px; }

  /* ---- 答题卡：底部滑出抽屉 ---- */
  .layout { padding: 12px 12px 28px; }
  .sidebar {
    display: none;
    order: 0;
  }
  .sidebar.sheet-open {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 70;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    max-height: 74vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(105%);
    transition: transform .26s ease;
    box-shadow: 0 -10px 40px rgba(20, 16, 14, .18);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .sidebar.sheet-open.open { transform: none; }
  .nav-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(24, 18, 16, .38);
    z-index: 65;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
  }
  .nav-mask.show { opacity: 1; pointer-events: auto; }

  /* ---- 题目卡与作答区 ---- */
  .qcard { padding: 20px 16px 18px; }
  .stem { font-size: 16px; }
  .qfoot { flex-wrap: wrap; gap: 8px; margin-top: 20px; padding-top: 16px; }
  .qfoot .btn-ghost { flex: 1; padding: 12px 10px; }
  .qfoot .hint-text { display: none; }   /* 手机上没有键盘提示的意义 */
  .blank-input { font-size: 16px; max-width: 100%; }
  .essay-box { font-size: 16px; min-height: 150px; }
  .field input { font-size: 16px; }
  .tf-btn { padding: 16px; font-size: 16.5px; }

  /* ---- 教师端 ---- */
  .admin-wrap { padding: 14px 12px 28px; }
  .admin-head { flex-wrap: wrap; gap: 8px; }
  .admin-head .spacer { display: none; }
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.grid { min-width: 620px; }
  .drawer { width: 100vw; }
  .drawer-head { padding: 12px 14px; }
  .drawer-body { padding: 14px 14px 40px; }
  .answer-box { max-height: 260px; }
  .stat-row { gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat .v { font-size: 20px; }

  /* ---- 弹层 / 提示 ---- */
  .modal-mask { padding: 14px; align-items: flex-end; }
  .modal { margin-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .toast { bottom: 20px; width: max-content; max-width: 86vw; }
}
