:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #8a8479;
  --accent: #b03a2e;
  --accent-soft: #f4e3e0;
  --gold: #c8a96a;
  --green: #2e7d4f;
  --green-soft: #e3f1e8;
  --red: #b03a2e;
  --line: #e7e1d6;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(60, 50, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.topbar { text-align: center; margin-bottom: 20px; }
.topbar h1 {
  font-size: 22px;
  margin: 0 0 4px;
  letter-spacing: 1px;
  color: var(--accent);
}
.subtitle { color: var(--muted); font-size: 13px; margin: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 18px; font-size: 18px; }

.hidden { display: none !important; }

.field { margin-bottom: 22px; }
.field > label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lesson-actions { margin-bottom: 8px; display: flex; gap: 14px; }
.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline;
}

.lessons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 2px;
}
.lesson-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.lesson-item input { margin-top: 5px; flex-shrink: 0; }
.lesson-item .ln-count { color: var(--muted); font-size: 11px; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500 !important; font-size: 14px; cursor: pointer;
}

button.primary, button.secondary {
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: opacity .15s, transform .05s;
}
button.primary { background: var(--accent); color: #fff; }
button.secondary { background: #efe9df; color: var(--ink); }
button.primary:active, button.secondary:active { transform: translateY(1px); }
button.big { width: 100%; padding: 14px; font-size: 16px; }
button:disabled { opacity: .4; cursor: not-allowed; }

/* Quiz */
.progress-wrap { margin-bottom: 18px; }
.progress-bar {
  height: 8px; background: var(--line);
  border-radius: 999px; overflow: hidden;
}
#progressFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width .25s;
}
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 6px;
}

.q-lesson {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.q-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

#answerInput {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 14px;
}
#answerInput:focus { outline: none; border-color: var(--gold); }

.answer-box {
  background: var(--green-soft);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  white-space: pre-wrap;
}
.answer-label {
  font-size: 12px; color: var(--green);
  font-weight: 700; margin-bottom: 4px;
}

.quiz-actions { display: flex; flex-direction: column; gap: 10px; }
.grade-buttons { display: flex; gap: 10px; }
.grade {
  flex: 1; border: none; border-radius: 10px;
  padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.grade.right { background: var(--green-soft); color: var(--green); }
.grade.wrong { background: var(--accent-soft); color: var(--red); }

/* Result */
.score-circle {
  width: 130px; height: 130px;
  border-radius: 50%;
  margin: 10px auto 6px;
  display: flex; align-items: baseline; justify-content: center;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent-soft));
  border: 6px solid var(--gold);
}
.score-circle #finalScore { font-size: 46px; font-weight: 800; color: var(--accent); }
.score-total { font-size: 20px; color: var(--muted); }
.score-rate { text-align: center; font-size: 15px; color: var(--muted); margin: 0 0 20px; }

#wrongReview h3 { font-size: 15px; margin: 18px 0 8px; }
.wrong-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.wrong-item .wi-q { font-weight: 600; margin-bottom: 6px; }
.wrong-item .wi-a { color: var(--green); white-space: pre-wrap; font-size: 14px; }
.wrong-item .wi-lesson { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.result-actions button { flex: 1; }

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}

@media (max-width: 480px) {
  .lessons { grid-template-columns: 1fr; }
  .q-text { font-size: 16px; }
}
