:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #1c2333;
  --muted: #5b6472;
  --primary: #1f4fa3;
  --primary-dark: #163b7d;
  --accent: #2ecc71;
  --danger: #e74c3c;
  --warn: #f39c12;
  --border: #e2e7ef;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(28, 35, 51, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-badge {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: #fff; color: var(--primary);
  font-weight: 800; font-size: 18px;
}
.brand-text { font-size: 15px; line-height: 1.15; }
.brand-text strong { display: block; font-size: 16px; }
.topnav { display: flex; align-items: center; gap: 10px; }
.topnav a { color: #fff; font-size: 14px; padding: 7px 12px; border-radius: 8px; }
.topnav a:hover { background: rgba(255, 255, 255, 0.14); text-decoration: none; }
.topnav .btn-exam {
  background: var(--accent); color: #0a2a12; font-weight: 700;
}
.topnav .btn-exam:hover { background: #27ae60; }

/* ---------- Layout ---------- */
.app-main { max-width: 860px; margin: 0 auto; padding: 22px 16px 60px; }
.app-footer {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 16px; margin-top: 20px;
}

/* ---------- Cards & sections ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.page-title { font-size: 24px; margin: 4px 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 18px; }

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #2c63c7 100%);
  color: #fff; border: none; padding: 24px;
}
.hero h1 { margin: 0 0 8px; font-size: 26px; }
.hero p { margin: 0 0 16px; opacity: 0.92; }
.hero .btn { background: #fff; color: var(--primary); font-weight: 700; }

/* ---------- Tema list ---------- */
.tema-list { list-style: none; margin: 0; padding: 0; }
.tema-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-bottom: 1px solid var(--border);
}
.tema-item:last-child { border-bottom: none; }
.tema-num {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: #e8eef9; color: var(--primary); font-weight: 800;
}
.tema-info { flex: 1 1 auto; min-width: 0; }
.tema-info .tema-title { font-weight: 700; margin: 0; }
.tema-info .tema-desc { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.tema-meta { flex: 0 0 auto; text-align: right; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; background: #eef1f6; color: var(--muted);
}
.pill.ok { background: #e6f7ec; color: #1d8a44; }
.pill.soon { background: #fdeee2; color: #b26a1d; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 700;
  text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: #eef1f6; color: var(--ink); }
.btn.ghost:hover { background: #e2e7ef; }
.btn.success { background: var(--accent); color: #0a2a12; }
.btn.success:hover { background: #27ae60; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- Resumen (tema) ---------- */
.resumen h3 { color: var(--primary); margin: 20px 0 8px; font-size: 18px; }
.resumen h3:first-child { margin-top: 0; }
.resumen p { margin: 8px 0; }
.resumen ul { margin: 8px 0; padding-left: 20px; }
.resumen li { margin: 6px 0; }
.resumen .note {
  background: #fff8e6; border-left: 4px solid var(--warn);
  padding: 12px 14px; border-radius: 8px; margin: 12px 0; font-size: 14px;
}

/* ---------- Test ---------- */
.test-progress {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  font-size: 14px; color: var(--muted);
}
.bar { flex: 1 1 auto; height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s; }

.question { font-size: 18px; font-weight: 700; margin: 4px 0 16px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 13px 14px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 15px;
}
.option:hover { border-color: var(--primary); }
.option .key {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: #eef1f6; font-weight: 700; font-size: 13px;
}
.option.correct { border-color: var(--accent); background: #e9f9ef; }
.option.correct .key { background: var(--accent); color: #fff; }
.option.wrong { border-color: var(--danger); background: #fdecec; }
.option.wrong .key { background: var(--danger); color: #fff; }
.option.disabled { pointer-events: none; }
.option.hidden-answer { opacity: 0.45; }

.feedback {
  margin-top: 14px; padding: 13px 15px; border-radius: 12px; font-size: 14px;
}
.feedback.good { background: #e9f9ef; border: 1px solid #bfe8cd; }
.feedback.bad { background: #fdecec; border: 1px solid #f3c1bd; }
.feedback strong { display: block; margin-bottom: 4px; }

/* ---------- Resultado ---------- */
.result-box {
  text-align: center; padding: 28px 18px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
}
.result-big { font-size: 54px; font-weight: 800; line-height: 1; }
.result-box.pass { background: #e9f9ef; border-color: #bfe8cd; }
.result-box.pass .result-big { color: #1d8a44; }
.result-box.fail { background: #fdecec; border-color: #f3c1bd; }
.result-box.fail .result-big { color: var(--danger); }
.result-sub { color: var(--muted); margin: 6px 0 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }

/* ---------- Review de examen ---------- */
.review-q { border-bottom: 1px solid var(--border); padding: 14px 0; }
.review-q:last-child { border-bottom: none; }
.review-q .q-text { font-weight: 700; margin-bottom: 8px; }
.review-q ul { list-style: none; margin: 6px 0; padding: 0; }
.review-q li { padding: 6px 10px; border-radius: 8px; margin: 4px 0; font-size: 14px; }
.review-q li.your { background: #fdecec; }
.review-q li.right { background: #e9f9ef; }
.review-q .exp { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- Timer ---------- */
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary);
}
.timer.danger { color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .app-header { padding: 10px 12px; }
  .brand-text { display: none; }
  .page-title { font-size: 21px; }
  .hero h1 { font-size: 22px; }
  .question { font-size: 16px; }
}
