/* ====== Simulacro B-IIb — estilos ====== */
:root {
  color-scheme: light dark;
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5c6474;
  --border: #dde2ec;
  --primary: #b3261e;        /* rojo institucional peruano (texto de acento) */
  --primary-bg: #b3261e;     /* fondos con texto blanco */
  --primary-bg-hover: #8f1d17;
  --accent: #1a56a5;
  --ok: #1e7d3c;
  --ok-bg: #e5f5ea;
  --bad: #c62828;
  --bad-bg: #fdeaea;
  --flag: #d98b00;
  --shadow: 0 1px 3px rgba(20, 30, 55, .08), 0 4px 14px rgba(20, 30, 55, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --card: #1e242e;
    --text: #e8ebf2;
    --muted: #9aa3b5;
    --border: #323a48;
    --primary: #ff8a80;      /* texto de acento legible sobre --card */
    --primary-bg: #8f2620;   /* fondo con texto blanco, contraste AA */
    --primary-bg-hover: #a63029;
    --accent: #6ea8ff;
    --ok: #4caf6e;
    --ok-bg: #17321f;
    --bad: #ef6b62;
    --bad-bg: #3a1d1b;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--primary-bg);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1060px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.brand { font-size: 1.15rem; font-weight: 700; }
.brand-sub { font-size: .85rem; opacity: .92; }

#app { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 22px 16px 40px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.slim { padding: 12px 18px; }
h1 { margin: 0 0 10px; font-size: 1.7rem; line-height: 1.25; }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
a { color: var(--accent); }

/* ---- botones ---- */
.btn {
  font: inherit; cursor: pointer;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 16px;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; text-align: left; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-bg-hover); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small-btn { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.home-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.home-actions.row { flex-direction: row; flex-wrap: wrap; }
.home-actions.row .btn { width: auto; }
.pill {
  background: var(--bad); color: #fff; border-radius: 999px;
  font-size: .75rem; padding: 1px 8px; margin-left: 6px;
}
.pill:empty { display: none; }

/* ---- historial ---- */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap;
}
.history-item .date { color: var(--muted); font-size: .85rem; }
.history-item .score { font-weight: 700; }
.tag { border-radius: 6px; padding: 2px 8px; font-size: .8rem; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- quiz ---- */
.quiz-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
.quiz-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mode-label { font-weight: 700; color: var(--primary); }
.quiz-tools { display: flex; align-items: center; gap: 12px; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem;
  padding: 3px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok);
}
.timer.warning { background: var(--bad-bg); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .timer.warning { animation: none; }
  .btn:active:not(:disabled) { transform: none; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tally { font-size: .9rem; color: var(--muted); }

.quiz-body { display: grid; grid-template-columns: 1fr 250px; gap: 18px; align-items: start; }
@media (max-width: 800px) { .quiz-body { grid-template-columns: 1fr; } }

.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.q-number { font-weight: 700; color: var(--muted); }
.btn-flag-on { color: var(--flag); border-color: var(--flag); }
.q-text { font-size: 1.08rem; font-weight: 600; margin: 6px 0 14px; white-space: pre-line; }
.q-images { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.q-images img {
  max-width: 100%; max-height: 190px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; padding: 6px;
}

.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  width: 100%; font: inherit; cursor: pointer;
  background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 13px;
  transition: border-color .12s, background .12s;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled:not(.correct):not(.wrong) { opacity: .65; }
.option .letter {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1.5px solid var(--border);
  font-weight: 700; font-size: .85rem; text-transform: uppercase;
}
.option.selected { border-color: var(--accent); background: var(--bg); }
.option.selected { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.option.selected .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.option:disabled { cursor: default; }

.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }

.q-nav { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.q-nav .btn { flex: 1; min-width: 120px; }

/* ---- navegador ---- */
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.nav-cell {
  font: inherit; font-size: .8rem; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  padding: 6px 0; text-align: center; position: relative;
}
.nav-cell.answered { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.nav-cell.current { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.nav-cell.flagged::after {
  content: ""; position: absolute; top: 2px; right: 2px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--flag);
}
.legend { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-answered { background: var(--ok); }
.dot-flagged { background: var(--flag); }
.dot-current { background: var(--accent); }

/* ---- resultados ---- */
.result-summary { text-align: center; }
.result-badge { font-size: 2rem; font-weight: 800; margin-bottom: 6px; }
.result-badge.ok { color: var(--ok); }
.result-badge.bad { color: var(--bad); }
.result-detail { color: var(--muted); margin-bottom: 14px; }
.result-summary .home-actions { justify-content: center; }
.review-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.check { display: flex; gap: 7px; align-items: center; font-size: .9rem; color: var(--muted); cursor: pointer; }
.review-item { border-top: 1px solid var(--border); padding: 16px 2px; }
.review-item .q-text { font-size: 1rem; }
.review-item .verdict { font-size: .85rem; font-weight: 700; margin-bottom: 4px; }
.review-item .verdict.ok { color: var(--ok); }
.review-item .verdict.bad { color: var(--bad); }
.review-opt { padding: 6px 10px; border-radius: 8px; margin-top: 5px; font-size: .95rem; }
.review-opt.correct { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.review-opt.chosen-wrong { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(10, 14, 22, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box { max-width: 420px; margin: 16px; }
.modal-actions { justify-content: flex-end; display: flex; gap: 10px; margin-top: 14px; }

.footer { text-align: center; padding: 14px; }
