:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16202b;
  --ink-2: #5b6878;
  --ink-3: #8b97a6;
  --line: #e3e7ec;
  --accent: #2f6df6;
  --accent-soft: #eaf0ff;
  --ok: #1a9c5b;
  --ok-soft: #e8f7ee;
  --warn: #c2760a;
  --warn-soft: #fdf3e3;
  --bad: #d02f2f;
  --bad-soft: #fdeceb;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 通用 ---------- */

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }

.muted { color: var(--ink-2); font-size: 13px; }
.faint { color: var(--ink-3); font-size: 12px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap8 { gap: 10px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 14px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
  flex: 0 0 auto;
}
.btn:active { background: #f0f2f5; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: #275ccc; }
.btn.danger { color: var(--bad); border-color: #f3c9c7; background: var(--bad-soft); }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  background: #eef1f5;
  color: var(--ink-2);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--accent-soft); color: var(--accent); }

input[type=text], input[type=password], input[type=number], input[type=datetime-local],
textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; line-height: 1.65; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 550; }

.list { display: flex; flex-direction: column; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.item:last-child { border-bottom: 0; }
.item:active { background: #fafbfc; }
.item .title { font-weight: 600; font-size: 15px; }
.item .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.score-big {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.score-big small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }

.bar-row { margin-top: 12px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar { height: 7px; border-radius: 99px; background: #edf0f4; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

.words { line-height: 2.1; font-size: 16px; word-break: break-word; }
.words .w { padding: 1px 2px; border-radius: 4px; }
.words .w.bad { background: var(--bad-soft); color: var(--bad); }
.words .w.miss { background: var(--warn-soft); color: var(--warn); text-decoration: underline dashed; }
.words .w.extra { background: #eef1f5; color: var(--ink-3); text-decoration: line-through; }

.ded {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.ded:last-child { border-bottom: 0; }
.ded .kind { flex: 0 0 auto; color: var(--bad); font-weight: 600; }
.ded .pts { flex: 0 0 auto; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.reference {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.source-text {
  background: #f7f9fc;
  border-radius: 10px;
  padding: 12px;
  line-height: 1.9;
  font-size: 15px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  max-width: 88vw;
  background: rgba(22, 32, 43, .93);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 50;
  line-height: 1.5;
}

.spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { max-width: 380px; margin: 8vh auto 0; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.auth-tabs button.on { background: var(--accent-soft); border-color: #c8d8ff; color: var(--accent); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.tabs button {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.tabs button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; font-size: 14px; }

@media (min-width: 640px) {
  .app { padding: 24px 18px 40px; }
  h1 { font-size: 22px; }
}

/* ---------- 学生自助注册 ---------- */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--ink-3);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.reg-err {
  background: var(--bad-soft);
  border: 1px solid #f3c9c7;
  color: var(--bad);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
  word-break: break-word;
}

.auth-wrap select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* 手机上输入框给 16px，避免 iOS 点进去自动放大 */
@media (max-width: 480px) {
  .auth-wrap input,
  .auth-wrap select,
  .auth-wrap .btn { font-size: 16px; }
  .auth-wrap { margin-top: 4vh; }
}

/* ---------- 听原文 ---------- */

.listen-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.listen-row audio { width: 100%; height: 38px; }
.btn.listen {
  background: var(--accent-soft);
  border-color: #c8d8ff;
  color: var(--accent);
  font-weight: 650;
}
.btn.listen:active { background: #dfe8ff; }

.spinner.dark {
  border-color: rgba(47, 109, 246, .25);
  border-top-color: var(--accent);
}

/* ---------- 教师设置页：多选班级 ---------- */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check-row:last-child { border-bottom: 0; }
.check-row input[type=checkbox] {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.check-row .grow { display: flex; flex-direction: column; gap: 2px; }
.check-row .faint { font-weight: 400; }
