:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #14201d;
  --muted: #6b7c77;
  --line: #e2e8e5;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(16, 40, 34, 0.06), 0 8px 24px rgba(16, 40, 34, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: #eef8f4;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 84px;
}

/* 背景装饰层：渐变色块 + 细点，全部纯 CSS */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(160deg, #e4fbf3 0%, #eef4ff 42%, #fff5e8 100%);
}

.bg i {
  position: absolute;
  display: block;
  border-radius: 50%;
  will-change: transform;
  animation: floaty 24s ease-in-out infinite alternate;
}

.bg i:nth-child(1) {
  width: 58vmax;
  height: 58vmax;
  left: -20vmax;
  top: -22vmax;
  background: radial-gradient(circle at 50% 50%, rgba(45, 212, 191, 0.72), rgba(45, 212, 191, 0) 66%);
  animation-duration: 28s;
}

.bg i:nth-child(2) {
  width: 48vmax;
  height: 48vmax;
  right: -18vmax;
  top: -14vmax;
  background: radial-gradient(circle at 50% 50%, rgba(96, 165, 250, 0.6), rgba(96, 165, 250, 0) 66%);
  animation-duration: 34s;
  animation-delay: -8s;
}

.bg i:nth-child(3) {
  width: 44vmax;
  height: 44vmax;
  right: -2vmax;
  bottom: -22vmax;
  background: radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.55), rgba(251, 191, 36, 0) 68%);
  animation-duration: 30s;
  animation-delay: -14s;
}

.bg i:nth-child(4) {
  width: 38vmax;
  height: 38vmax;
  left: -10vmax;
  bottom: -14vmax;
  background: radial-gradient(circle at 50% 50%, rgba(167, 139, 250, 0.5), rgba(167, 139, 250, 0) 68%);
  animation-duration: 36s;
  animation-delay: -20s;
}

.bg i:nth-child(5) {
  width: 40vmax;
  height: 40vmax;
  left: 26%;
  top: 34%;
  background: radial-gradient(circle at 50% 50%, rgba(244, 114, 182, 0.34), rgba(244, 114, 182, 0) 70%);
  animation-duration: 40s;
  animation-delay: -26s;
}

.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(15, 118, 110, 0.16) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.7;
  -webkit-mask-image: radial-gradient(ellipse at 50% -6%, #000 0%, transparent 58%);
  mask-image: radial-gradient(ellipse at 50% -6%, #000 0%, transparent 58%);
}

@keyframes floaty {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(3%, 4%, 0) scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg i {
    animation: none;
  }
}

button {
  font: inherit;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226, 232, 229, 0.8);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.me-name {
  font-weight: 600;
  color: var(--ink);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.link {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.login-wrap {
  min-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #0f766e 0%, #2dd4bf 55%, #38bdf8 100%);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.26);
  margin-bottom: 14px;
}

.notice {
  background: rgba(240, 253, 250, 0.92);
  border-color: #99f6e4;
}

.notice-lines {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  word-break: break-all;
}

.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 229, 0.9);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 2px 4px rgba(16, 40, 34, 0.04), 0 14px 30px rgba(16, 40, 34, 0.07);
}

.card + .card {
  margin-top: 12px;
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

.sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
}

.field {
  display: block;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

textarea.field {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.2);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 500;
  box-shadow: none;
}

.btn.small {
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn.danger {
  background: rgba(255, 255, 255, 0.9);
  border-color: #f3c6c6;
  color: var(--bad);
}

.btn:disabled {
  opacity: 0.55;
}

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

.row > .btn {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

.mt {
  margin-top: 12px;
}

/* 词集卡片 */
.set-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 229, 0.9);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(16, 40, 34, 0.04), 0 14px 30px rgba(16, 40, 34, 0.07);
}

.set-title {
  font-weight: 700;
  font-size: 17px;
}

.set-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
}

/* 答题 */
.quiz-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.progress {
  height: 8px;
  background: rgba(15, 118, 110, 0.14);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 28px;
}

.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0f766e 0%, #2dd4bf 60%, #67e8f9 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* 分段进度条：每道题一格 */
.progress-wrap {
  margin-bottom: 24px;
}

.progress.segmented {
  display: flex;
  gap: 2px;
  height: 10px;
  margin-bottom: 7px;
  background: transparent;
  overflow: hidden;
}

.progress.segmented i {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  border-radius: 3px;
  background: rgba(15, 118, 110, 0.16);
  transition: background 0.2s ease;
}

.progress.segmented i.ok {
  background: #22c55e;
}

.progress.segmented i.bad {
  background: #f87171;
}

.progress.segmented i.current {
  background: #0f766e;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.progress-meta b {
  font-size: 14px;
  color: var(--ink);
}

.term {
  font-size: 40px;
  font-weight: 700;
  text-align: center;
  margin: 18px 0 32px;
  word-break: break-word;
  letter-spacing: -0.01em;
}

.options {
  display: grid;
  gap: 10px;
}

.opt {
  padding: 15px 16px;
  border: 1px solid rgba(226, 232, 229, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  text-align: left;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.opt:hover:not(:disabled) {
  border-color: var(--teal);
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.12);
}

.opt.ok {
  background: var(--ok-soft);
  border-color: #86efac;
  color: var(--ok);
  font-weight: 600;
}

.opt.bad {
  background: var(--bad-soft);
  border-color: #fca5a5;
  color: var(--bad);
  font-weight: 600;
}

.opt:disabled {
  opacity: 1;
  cursor: default;
}

.feedback {
  min-height: 48px;
  margin-top: 14px;
  text-align: center;
  font-size: 15px;
}

.feedback.ok {
  color: var(--ok);
  font-weight: 600;
}

.feedback.bad {
  color: var(--bad);
  font-weight: 600;
}

/* 结果 */
.score-big {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: var(--teal);
  margin: 8px 0 4px;
}

.score-unit {
  font-size: 22px;
  vertical-align: super;
  margin-left: 2px;
}

.stat-row {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.stat-row b {
  display: block;
  color: var(--ink);
  font-size: 20px;
  text-align: center;
}

.wrong-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wrong-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 15px;
}

.wrong-list li:last-child {
  border-bottom: 0;
}

.wrong-list .w-term {
  font-weight: 600;
  flex: 0 0 auto;
}

.w-answer {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
}

.wrong-list .w-choice {
  color: var(--bad);
  text-decoration: line-through;
  font-size: 13px;
}

.w-arrow {
  color: var(--muted);
  font-size: 12px;
}

.w-correct {
  color: var(--ok);
  font-weight: 600;
}

/* 排行榜 */
table.rank {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.rank th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

table.rank td {
  padding: 10px 8px;
  border-bottom: 1px solid #f0f4f2;
}

table.rank tr.me td {
  background: var(--teal-soft);
  font-weight: 700;
}

table.rank tr.me td:first-child {
  border-radius: 8px 0 0 8px;
}

table.rank tr.me td:last-child {
  border-radius: 0 8px 8px 0;
}

.rank-no {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  width: 42px;
}

.rank-no.top {
  color: var(--teal);
  font-weight: 700;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 0;
  font-size: 14px;
}

/* 教师端 */
.admin-grid {
  display: grid;
  gap: 10px;
}

.set-row {
  border: 1px solid rgba(226, 232, 229, 0.9);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.set-row + .set-row {
  margin-top: 10px;
}

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.file-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 13px;
  border: 1.5px dashed rgba(15, 118, 110, 0.4);
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.05);
  color: var(--teal);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.file-pick:hover {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.65);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 3px 3px 3px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  font-size: 13px;
  color: var(--ink);
}

.chip-x {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
}

.chip-x:hover {
  background: var(--bad-soft);
  color: var(--bad);
}

.pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
}

.pill.on {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.off {
  background: #f1f5f9;
  color: #64748b;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: rgba(255, 255, 255, 0.82);
  border-top: 1px solid rgba(226, 232, 229, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
}

.tabs button {
  flex: 1;
  border: 0;
  background: none;
  padding: 9px 0;
  font-size: 14px;
  color: var(--muted);
  border-radius: 10px;
}

.tabs button.active {
  color: var(--teal);
  font-weight: 700;
  background: var(--teal-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(20, 32, 29, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 20;
  max-width: 86vw;
  text-align: center;
}

/* ---------------- 新答题模式 ---------------- */

.level-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.level-row .btn {
  padding: 11px 8px;
  font-size: 14px;
}

.prompt-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 229, 0.9);
  border-radius: 18px;
  padding: 22px 18px;
  box-shadow: 0 2px 4px rgba(16, 40, 34, 0.04), 0 14px 30px rgba(16, 40, 34, 0.07);
  text-align: center;
}

.prompt-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.prompt {
  font-size: 22px;
  line-height: 1.55;
  font-weight: 600;
  word-break: break-word;
}

.hint {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #b45309;
  font-size: 11px;
}

.answer-form {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.answer-input {
  font-size: 22px;
  padding: 16px 14px;
  text-align: center;
  letter-spacing: 0.04em;
}

.answer-result {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
  border: 1px solid rgba(226, 232, 229, 0.9);
  box-shadow: 0 2px 4px rgba(16, 40, 34, 0.04), 0 14px 30px rgba(16, 40, 34, 0.07);
}

.answer-result.ok {
  border-color: #86efac;
  background: #f2fdf4;
}

.answer-result.bad {
  border-color: #fca5a5;
  background: #fff6f6;
}

.answer-mark {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 8px;
}

.answer-result.ok .answer-mark {
  color: var(--ok);
}

.answer-result.bad .answer-mark {
  color: var(--bad);
}

.answer-word {
  font-size: 30px;
  font-weight: 700;
  word-break: break-word;
}

.answer-phonetic {
  color: var(--muted);
  font-size: 15px;
  margin-top: 2px;
}

.answer-yours {
  margin-top: 10px;
  color: var(--bad);
  font-size: 14px;
}

.answer-zh {
  margin-top: 10px;
  font-size: 16px;
}

.answer-en {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.level-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.level-tabs button {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 13px;
}

.level-tabs button.active {
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

/* ---------------- 错题本 ---------------- */

.mistake-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mistake-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.mistake-row:last-child {
  border-bottom: 0;
}

.mistake-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mistake-main .w-term {
  font-weight: 600;
  word-break: break-word;
}

.mistake-zh {
  color: var(--muted);
  font-size: 13px;
}

.mistake-side {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.mistake-side .pill.on {
  background: var(--ok-soft);
  color: var(--ok);
}
