:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --border: #e5e7eb;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

/* ---------- Home ---------- */
.home-header {
  text-align: center;
  margin-bottom: 28px;
}
.home-header h1 {
  font-size: 22px;
  margin: 0 0 6px;
}
.home-header p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.mode-grid {
  display: grid;
  gap: 16px;
}

.mode-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .15s, transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.mode-card:hover {
  box-shadow: 0 6px 18px rgba(37,99,235,.12);
  transform: translateY(-1px);
}
.mode-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  border-radius: 12px;
  flex: none;
}
.mode-card h2 {
  font-size: 16px;
  margin: 0 0 4px;
}
.mode-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

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

/* ---------- Quiz top bar ---------- */
.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.back-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.back-btn:hover { background: #fff; }

.progress-wrap {
  flex: 1;
  margin: 0 4px;
}
.progress-text {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  margin-bottom: 4px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .2s;
}

.score-pill {
  font-size: 13px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--primary-dark);
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ---------- Question card ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}

.q-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.q-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 16px;
}

.context-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  margin-bottom: 16px;
}

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

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.45;
  background: #fff;
  transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--primary); }
.option.selected {
  border-color: var(--primary);
  background: #eef2ff;
}
.option.correct {
  border-color: var(--green);
  background: var(--green-bg);
}
.option.incorrect {
  border-color: var(--red);
  background: var(--red-bg);
}
.option .letter {
  font-weight: 700;
  color: var(--muted);
  flex: none;
  width: 20px;
}
.option.selected .letter,
.option.correct .letter { color: inherit; }

.option-icon {
  margin-left: auto;
  font-weight: 700;
  flex: none;
}

/* true/false statement rows */
/* question image */
.q-image-wrap {
  margin-bottom: 16px;
  text-align: center;
}
.q-image {
  max-width: 260px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.q-image-caption {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* fill-in-the-blank */
.fillblank-input {
  width: 100%;
  font-size: 15px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  box-sizing: border-box;
}
.fillblank-input:focus {
  outline: none;
  border-color: var(--primary);
}
.fillblank-input:disabled {
  background: #f8fafc;
  color: var(--text);
}

/* essay */
.essay-input {
  width: 100%;
  min-height: 140px;
  font-size: 14.5px;
  line-height: 1.6;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.essay-input:focus {
  outline: none;
  border-color: var(--primary);
}
.sample-answer {
  margin-top: 16px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #1e293b;
}
.sample-answer-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.tf-statement {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.tf-statement .tf-text {
  font-size: 14.5px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.tf-choices {
  display: flex;
  gap: 10px;
}
.tf-btn {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  background: #fff;
}
.tf-btn.selected { border-color: var(--primary); background: #eef2ff; }
.tf-btn.correct { border-color: var(--green); background: var(--green-bg); }
.tf-btn.incorrect { border-color: var(--red); background: var(--red-bg); }
.tf-statement.answered .tf-text { color: var(--text); }

/* ---------- Feedback banner (study mode) ---------- */
.feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.feedback.correct { background: var(--green-bg); color: #166534; }
.feedback.incorrect { background: var(--red-bg); color: #991b1b; }

/* ---------- Action bar ---------- */
.action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

button.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background .12s;
}
button.btn:hover { background: var(--primary-dark); }
button.btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}
button.btn.secondary {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
button.btn.secondary:hover { background: #eef2ff; }

/* ---------- Result screen ---------- */
.result-hero {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  margin-bottom: 20px;
}
.result-score {
  font-size: 40px;
  font-weight: 800;
  color: var(--primary);
}
.result-score small {
  font-size: 18px;
  color: var(--muted);
  font-weight: 600;
}
.result-pct {
  font-size: 15px;
  color: var(--muted);
  margin-top: 6px;
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.review-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.review-item .review-q {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 14.5px;
}
.review-row {
  font-size: 13.5px;
  padding: 6px 0;
  display: flex;
  gap: 6px;
}
.review-row .tag {
  flex: none;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}
.tag.ok { background: var(--green-bg); color: #166534; }
.tag.bad { background: var(--red-bg); color: #991b1b; }

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin: 24px 0 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

@media (max-width: 480px) {
  .q-text { font-size: 15.5px; }
  .result-score { font-size: 32px; }
}
