:root {
  --navy: #0b3d5c;
  --navy-dark: #082a40;
  --blue: #1e6ea8;
  --accent: #f5a623;
  --green: #2e8b57;
  --red: #c0392b;
  --bg: #f4f7fa;
  --card: #ffffff;
  --ink: #1b2733;
  --muted: #5f7180;
  --border: #dbe4ea;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #eef4f9 0%, var(--bg) 260px);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

header.top h1 {
  font-size: 1.4rem;
  margin: 0;
  color: var(--navy-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

header.top h1 .wave { font-size: 1.3rem; }

.pill-btn, button.pill-btn {
  border: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--navy);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.pill-btn:hover { background: #eaf1f7; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(11,61,92,0.06);
}

.summary-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.summary-card .stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; }
.summary-card .stat { min-width: 90px; }
.summary-card .stat .num { font-size: 1.7rem; font-weight: 700; }
.summary-card .stat .label { font-size: 0.75rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.mode-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mode-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(11,61,92,0.12); }
.mode-card .icon { font-size: 1.5rem; }
.mode-card h3 { margin: 0; font-size: 1.02rem; color: var(--navy-dark); }
.mode-card p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.3; }
.mode-card .count { font-size: 0.75rem; color: var(--accent); font-weight: 700; }
.mode-card:disabled, .mode-card.disabled { opacity: 0.5; cursor: not-allowed; }
.mode-card:disabled:hover, .mode-card.disabled:hover { transform: none; box-shadow: none; }

h2.section-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 26px 0 10px;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  margin-bottom: 8px;
  cursor: pointer;
}
.chapter-row:hover { background: #f7fafc; }
.chapter-row .name { flex: 1; font-weight: 600; font-size: 0.92rem; color: var(--navy-dark); }
.chapter-row .mastery-num { font-size: 0.8rem; color: var(--muted); width: 46px; text-align: right; }
.bar-track {
  flex: 2;
  height: 8px;
  background: #e3ecf2;
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 6px;
  transition: width .3s ease;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.progress-track {
  height: 6px;
  background: #e3ecf2;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  background: #e7f1fa;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.tag.missed { color: var(--red); background: #fbe9e7; }

.question-prompt {
  font-size: 1.12rem;
  line-height: 1.55;
  margin: 6px 0 18px;
  color: var(--ink);
}
.question-prompt .blank-slot {
  display: inline-block;
  min-width: 90px;
}
.question-prompt input.blank-input {
  border: none;
  border-bottom: 2px solid var(--blue);
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  padding: 2px 4px;
  min-width: 90px;
  text-align: center;
  color: var(--navy-dark);
  font-weight: 600;
}
.question-prompt input.blank-input:focus { outline: none; border-bottom-color: var(--accent); }
.question-prompt input.blank-input.correct { border-bottom-color: var(--green); color: var(--green); }
.question-prompt input.blank-input.incorrect { border-bottom-color: var(--red); color: var(--red); }

.diagram-wrap { text-align: center; margin-bottom: 16px; }
.diagram-wrap img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-btn {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.96rem;
  color: var(--ink);
}
.option-btn:hover { border-color: var(--blue); background: #f4f9fd; }
.option-btn.selected { border-color: var(--blue); background: #e7f1fa; }
.option-btn.correct { border-color: var(--green); background: #eaf6ee; color: #1f6b3d; }
.option-btn.incorrect { border-color: var(--red); background: #fbeceb; color: #9a2c20; }
.option-btn:disabled { cursor: default; }

.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.match-row:last-child { border-bottom: none; }
.match-row .left-label { flex: 1; font-size: 0.92rem; }
.match-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
}
.match-row select.correct { border-color: var(--green); background: #eaf6ee; }
.match-row select.incorrect { border-color: var(--red); background: #fbeceb; }
.match-row .mark { width: 20px; text-align: center; font-weight: 700; }

.actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 11px 22px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--border); }
.btn.ghost:hover { background: #f0f5f9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.feedback-banner {
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.9rem;
  font-weight: 600;
}
.feedback-banner.correct { background: #eaf6ee; color: #1f6b3d; }
.feedback-banner.incorrect { background: #fbeceb; color: #9a2c20; }
.feedback-banner .explain { font-weight: 400; margin-top: 4px; color: var(--muted); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 2.4rem; margin-bottom: 10px; }

.result-list { margin-top: 8px; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.result-item .mark { width: 18px; }
.result-item.ok .mark { color: var(--green); }
.result-item.bad .mark { color: var(--red); }

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 30px;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff3e0;
  color: #a15c00;
  font-weight: 700;
}

@media (max-width: 520px) {
  header.top h1 { font-size: 1.15rem; }
  .summary-card .stat-row { gap: 14px; }
}
