/* Preparación CAST — hoja de estilos única. */
:root {
  --ink: #14213d;
  --muted: #5b667a;
  --brand: #0b3d91;
  --brand-dark: #082c69;
  --brand-soft: #e8eefb;
  --accent: #f5b301;
  --ok: #1a7f4b;
  --ok-soft: #e4f5ec;
  --bad: #b83227;
  --bad-soft: #fbe9e7;
  --warn: #a15c00;
  --warn-soft: #fff4d6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #d9dfec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 4px 14px rgba(20, 33, 61, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin-top: 0.2em; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 0.8em; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
small { color: var(--muted); }

.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link { position: absolute; left: -999px; top: 0; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip-link:focus { left: 8px; top: 8px; }
/* Anillo doble (oscuro + claro) para que el foco se vea sobre cualquier fondo. */
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 6px #fff; }
.site-header :focus-visible, .rail :focus-visible, .calculator :focus-visible { outline-color: var(--accent); box-shadow: none; }

/* Cabecera y pie */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--brand); color: #fff;
}
.site-header a { color: #fff; text-decoration: none; }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a:hover { text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-dark); color: var(--accent); font-size: 1rem;
}
.site-footer { padding: 24px clamp(16px, 4vw, 40px) 40px; color: var(--muted); font-size: 0.86rem; text-align: center; }
.site-footer p { max-width: 760px; margin: 0 auto; }

.page { max-width: 1040px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 8px; }
.page > section { margin-bottom: 34px; }

/* Avisos */
.flash { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.flash-error { background: var(--bad-soft); border-color: #efc1bb; color: #7c1f17; }
.flash-info { background: var(--brand-soft); border-color: #c7d5f3; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid #f1d58a;
}
.notice-actions { display: flex; gap: 8px; align-items: center; }

/* Botones */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: background-color 0.12s, border-color 0.12s;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-large { padding: 12px 22px; font-size: 1.05rem; }
.button-secondary { background: #fff; color: var(--brand); }
.button-secondary:hover { background: var(--brand-soft); color: var(--brand-dark); }
.button-ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.button-ghost:hover { background: var(--brand-soft); color: var(--ink); border-color: #b9c6e4; }
.button-ghost.is-active, .button-ghost[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.link-button { background: none; border: 0; padding: 0; color: var(--bad); font: inherit; cursor: pointer; text-decoration: underline; }
.inline-form { display: inline; }

/* Tarjetas y rejillas */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 4px; }
.card-quiet { box-shadow: none; }
.card-primary {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  border-left: 6px solid var(--accent);
}
.card-primary > div { flex: 1 1 340px; }
.card-primary p { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
form.card { display: flex; flex-direction: column; gap: 6px; }
form.card .button { margin-top: auto; align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.92rem; color: var(--muted); margin-bottom: 8px; }
select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); max-width: 120px; }

/* Portada */
.hero { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; justify-content: space-between; }
.hero > div { flex: 1 1 380px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 56ch; }
.format-table { border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 0.93rem; box-shadow: var(--shadow); }
.format-table caption { caption-side: top; text-align: left; font-weight: 700; padding: 0 0 6px; }
.format-table th, .format-table td { padding: 7px 14px; text-align: center; border-bottom: 1px solid var(--line); }
.format-table thead th { background: var(--brand-soft); font-weight: 600; }
.format-table tbody th { text-align: left; font-weight: 600; }
.format-table tr:last-child th, .format-table tr:last-child td { border-bottom: 0; }
.tally { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.recent { list-style: none; margin: 0 0 12px; padding: 0; }
.recent li { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recent-scores { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

/* Etiquetas */
.chip, .tag, .badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.chip { background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; }
.tag { background: #eef0f5; color: var(--muted); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-you { background: var(--brand-soft); color: var(--brand-dark); }
.badge-ok { background: var(--ok); color: #fff; }
.badge-bad { background: var(--bad); color: #fff; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }

meter.score-meter { width: 110px; height: 10px; vertical-align: middle; }

/* Presentación de una prueba */
.intro { max-width: 1040px; margin: 24px auto; padding: 28px 30px; }
.intro-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 28px; align-items: start; margin-bottom: 22px; }
.intro-columns .instructions, .intro-columns .real-exam { margin-bottom: 0; }
.facts { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.facts div { flex: 1 1 140px; padding: 10px 14px; border-radius: 10px; background: var(--brand-soft); }
.facts dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 1.1rem; }
.instructions { padding-left: 20px; margin: 0 0 22px; }
.instructions li { margin-bottom: 6px; }
.intro form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.real-exam { margin: 0 0 22px; padding: 14px 18px; border: 1px solid #f1d58a; border-left: 5px solid var(--accent); border-radius: 10px; background: var(--warn-soft); }
.real-exam h2 { margin: 0 0 6px; font-size: 1.02rem; }
.real-exam ul { margin: 0; padding-left: 20px; font-size: 0.94rem; }
.real-exam li { margin-bottom: 4px; }
.real-exam li:last-child { margin-bottom: 0; }

/* Preguntas: material, enunciado y opciones (los comparten el test y la corrección) */
.question { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow); }
.passage { font-size: 1.06rem; line-height: 1.7; padding: 14px 18px; background: #fafbfe; border-left: 4px solid var(--brand); border-radius: 6px; margin-bottom: 16px; }
.passage p:last-child { margin-bottom: 0; }
.prompt { font-weight: 700; font-size: 1.05rem; margin: 14px 0 10px; }

.options { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; list-style: none; }
.option {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start;
  padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
ul.options .option { cursor: default; grid-template-columns: auto 1fr auto; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:hover { border-color: #b3c2e6; }
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.option:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 6px #fff; }
.option:has(input:disabled) { cursor: default; }
.option-key {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: #eef0f5; font-weight: 700; font-size: 0.9rem; flex: none;
}
.option:has(input:checked) .option-key { background: var(--brand); color: #fff; }
.option-text { padding-top: 2px; }
.option-tags { display: inline-flex; gap: 6px; align-items: center; }
/* Estados de corrección: más específicos que el de «opción seleccionada». */
.options .option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.options .option.is-correct .option-key { background: var(--ok); color: #fff; }
.options .option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.options .option.is-wrong .option-key { background: var(--bad); color: #fff; }
.why { grid-column: 2 / -1; display: block; margin: 0; font-size: 0.92rem; color: #3d4860; }

/* Opciones con figuras o solo con letras (razonamiento abstracto) */
.options-figures, .options-letters { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.options-figures .option, .options-letters .option { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 10px 8px; }
.options-figures .why, .options-letters .why, .options-figures .option-tags, .options-letters .option-tags { grid-column: 1; }
ul.options-figures .option, ul.options-letters .option { grid-template-columns: 1fr; }
.option-figure { display: block; width: 100%; max-width: 132px; }
.options-letters .option { padding: 14px 8px; }

.series { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; align-items: center; }
.series li { max-width: 140px; }
.series-next {
  aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed #6b7893; border-radius: 4px;
  font-size: 2rem; font-weight: 700; color: #6b7893;
}
.series svg, .option-figure svg { display: block; width: 100%; height: auto; }
.figure-missing { font-size: 0.8rem; color: var(--bad); }
.official-figure { display: block; max-width: 100%; height: auto; margin: 0 auto 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* Tablas de datos */
.data-table { margin: 0 0 14px; }
.data-table figcaption { font-weight: 700; margin-bottom: 8px; }
.table-scroll { overflow-x: auto; }
.data-table table, .plain-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { border: 1px solid #c9d1e3; padding: 8px 12px; text-align: right; white-space: nowrap; }
.data-table thead th { background: var(--brand-soft); text-align: center; white-space: normal; }
.data-table tbody th { text-align: left; background: #f6f8fd; }
.data-table tbody tr:nth-child(even) td { background: #fbfcff; }
.table-note { font-size: 0.86rem; color: var(--muted); margin: 6px 0 0; }
.plain-table th, .plain-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.plain-table thead th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.plain-table .chip { margin-right: 4px; }

/* Corrección */
.feedback, .explanation { margin-top: 16px; padding: 14px 18px; border-radius: 10px; background: #f6f8fd; border: 1px solid var(--line); }
.feedback h3, .explanation h4 { margin-bottom: 6px; }
.feedback-ok { background: var(--ok-soft); border-color: #b5dfc8; }
.feedback-bad { background: var(--bad-soft); border-color: #efc1bb; }
.steps { margin: 6px 0 0; padding-left: 22px; }
.steps li { margin-bottom: 4px; }

/* Pantalla del test. Misma estructura que la plataforma del examen (herramientas a la izquierda;
   avance, pruebas y cronómetro arriba; una pregunta por pantalla), con la paleta propia. */
.runner-page { padding: 0; }
.runner {
  --rail-bg: #0c1730;
  --rail-ink: #c5d1ee;
  --seg-unvisited: #d5dae5;
  --seg-unvisited-line: #7b869d;
  --seg-visited: #a9c0f5;
  --seg-visited-line: #4a6fc9;
  --seg-flagged: #d97706;
  --topbar-height: 96px;
  display: grid; grid-template-columns: 88px minmax(0, 1fr); min-height: 100vh;
}
.runner .icon { display: block; flex: none; }
.runner.is-closing [data-lock] { opacity: 0.55; pointer-events: none; }

/* Barra lateral de herramientas */
.runner .rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 8px 0; background: var(--rail-bg);
}
.runner .rail-button {
  display: grid; justify-items: center; gap: 5px; padding: 13px 4px 11px; border: 0; background: transparent;
  color: var(--rail-ink); font: inherit; font-size: 0.74rem; font-weight: 600; cursor: pointer;
}
.runner .rail-button .icon { width: 28px; height: 28px; }
.runner .rail-button:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.runner .rail-button[aria-expanded="true"] { background: var(--brand); color: #fff; }
.runner .rail-finish { margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.16); }
.runner .rail :focus-visible { outline-offset: -4px; }

/* Barra superior: leyenda, avance, pruebas del test y cronómetro */
.runner .stage { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.runner .topbar {
  position: sticky; top: 0; z-index: 20; padding: 10px clamp(14px, 2.4vw, 28px) 8px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.runner .topbar-row { display: flex; align-items: center; gap: 14px; min-height: 42px; }
.runner .legend-toggle {
  flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--brand);
  color: #fff; font: inherit; font-size: 1.15rem; font-weight: 800; line-height: 1; cursor: pointer;
}
.runner .legend-toggle:hover, .runner .legend-toggle[aria-expanded="true"] { background: var(--brand-dark); }
.runner .progress {
  --progress: 0%;
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; margin: 0; border-radius: 50%;
  background: radial-gradient(closest-side, var(--card) 79%, transparent 81%), conic-gradient(var(--ok) var(--progress), var(--line) 0);
  font-size: 0.68rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.runner .parts { flex: 1 1 auto; display: flex; min-width: 0; margin: 0; padding: 0; list-style: none; overflow: hidden; }
.runner .part {
  display: grid; justify-items: center; align-content: center; gap: 1px; min-width: 0; padding: 2px 16px 5px;
  border-bottom: 2px solid var(--line); color: var(--muted); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;
}
.runner .part + .part { box-shadow: -1px 0 0 var(--line); }
.runner .part-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.runner .part small { display: inline-flex; align-items: center; gap: 4px; color: inherit; font-size: 0.74rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.runner .part small .icon { width: 13px; height: 13px; }
.runner .part.is-current { color: var(--brand); border-bottom-color: var(--brand); }
.runner .timer {
  flex: none; display: inline-flex; align-items: center; gap: 8px; margin: 0 0 0 auto; color: var(--brand);
  font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.runner .timer .icon { width: 26px; height: 26px; }
.runner .timer.is-final { color: var(--bad); }
.runner .timer-free { font-size: 0.95rem; font-weight: 700; }

/* Barra de preguntas: un segmento por pregunta; el color indica su estado */
.runner .qbar { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.runner .seg {
  position: relative; flex: 1 1 0; min-width: 12px; max-width: 62px; height: 26px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer;
}
.runner .seg::before { content: ""; position: absolute; inset: 8px 0; border-radius: 999px; }
.runner .seg::before, .runner .legend-swatch { background: var(--seg-unvisited); border: 1px solid var(--seg-unvisited-line); }
.runner .seg[data-state="visited"]::before, .runner .legend-swatch[data-state="visited"] { background: var(--seg-visited); border-color: var(--seg-visited-line); }
.runner .seg[data-state="answered"]::before, .runner .seg[data-state="right"]::before,
.runner .legend-swatch[data-state="answered"], .runner .legend-swatch[data-state="right"] { background: var(--ok); border-color: var(--ok); }
.runner .seg[data-state="flagged"]::before, .runner .legend-swatch[data-state="flagged"] { background: var(--seg-flagged); border-color: var(--seg-flagged); }
.runner .seg[data-state="wrong"]::before, .runner .legend-swatch[data-state="wrong"] { background: var(--bad); border-color: var(--bad); }
.runner .seg.is-current[data-state="visited"]::before, .runner .legend-swatch[data-state="current"] { background: var(--brand); border-color: var(--brand); }
.runner .seg:hover::before { filter: brightness(0.9); }
/* Marca circular: «reproducir» en la pregunta actual; ✓ o ✗ en las ya comprobadas (práctica). */
.runner .seg-mark {
  position: absolute; top: 50%; left: 50%; display: none; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 800; line-height: 1;
  transform: translate(-50%, -50%);
}
.runner .seg.is-current .seg-mark { display: grid; width: 24px; height: 24px; }
.runner .seg[data-state="right"] .seg-mark, .runner .seg[data-state="wrong"] .seg-mark { display: grid; }
.runner .seg[data-state="answered"] .seg-mark, .runner .seg[data-state="right"] .seg-mark { background: var(--ok); }
.runner .seg[data-state="flagged"] .seg-mark { background: var(--seg-flagged); }
.runner .seg[data-state="wrong"] .seg-mark { background: var(--bad); }
.runner .seg[data-state="right"] .seg-mark::after { content: "✓"; }
.runner .seg[data-state="wrong"] .seg-mark::after { content: "✗"; }
.runner .seg.is-current .seg-mark::after {
  content: ""; margin-left: 3px; border-style: solid; border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #fff;
}
.runner .seg::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 4px); left: 50%; z-index: 5; padding: 4px 11px;
  border-radius: 8px; background: var(--card); color: var(--brand-dark); font-size: 0.8rem; font-weight: 700;
  white-space: nowrap; box-shadow: 0 0 0 1px var(--line), 0 6px 16px rgba(20, 33, 61, 0.16);
  opacity: 0; pointer-events: none; transform: translateX(-50%);
}
.runner .seg:hover::after, .runner .seg:focus-visible::after { opacity: 1; }
.runner .legend-pop {
  position: absolute; top: 56px; left: clamp(14px, 2.4vw, 28px); z-index: 30; width: min(370px, calc(100vw - 130px));
  padding: 14px 18px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  box-shadow: 0 12px 34px rgba(20, 33, 61, 0.22);
}
.runner .legend-pop h2 { margin: 0 0 10px; font-size: 1rem; color: var(--brand); }
.runner .legend-pop ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; font-size: 0.9rem; }
.runner .legend-pop li { display: flex; align-items: center; gap: 12px; }
.runner .legend-swatch { flex: none; width: 34px; height: 10px; border-radius: 999px; }

/* Zona de trabajo: borrador (solo numérico) y tarjeta de la pregunta */
.runner .workspace {
  flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 26px; align-items: start;
  padding: 14px clamp(14px, 2.4vw, 28px) 30px;
}
.runner .workspace:has(> .draft:not([hidden])) { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); }
.runner .content { width: 100%; min-width: 0; max-width: 1080px; margin: 0 auto; }
.runner .section-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 10px; font-size: 1.3rem; color: var(--brand); }
.runner .section-title small { font-size: 0.86rem; font-weight: 500; color: var(--muted); }

.runner .draft { position: sticky; top: calc(var(--topbar-height) + 14px); display: grid; gap: 10px; }
.runner .draft-title { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-size: 1rem; text-align: center; }
.runner .draft-warning { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--brand-dark); font-size: 0.86rem; line-height: 1.4; }
.runner .draft-warning .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--warn); }
.runner .draft textarea {
  width: 100%; height: calc(100vh - var(--topbar-height) - 190px); min-height: 220px; max-height: 640px;
  padding: 12px 14px; border: 1px solid #e6cf7a; border-radius: 10px; background: #fff6cf; color: var(--ink);
  font: inherit; line-height: 1.5; resize: vertical;
}

/* Tarjeta de la pregunta */
.runner .question { padding: 18px 28px 20px; }
.runner .passage { line-height: 1.6; margin-bottom: 12px; }
.runner .prompt { margin: 12px 0 8px; }
/* La tabla no ocupa todo el ancho: deja sitio a la derecha para la calculadora. */
.runner .data-table table { width: auto; min-width: min(100%, 640px); }
.runner .question-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.runner .question-number { margin: 0; font-size: 1.04rem; font-weight: 800; color: var(--brand-dark); text-decoration: underline; text-underline-offset: 4px; }
.runner .points { padding: 2px 11px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.runner .bookmark {
  display: grid; place-items: center; width: 40px; height: 40px; margin: -6px -10px -6px auto; padding: 0;
  border: 0; border-radius: 9px; background: transparent; color: var(--seg-flagged); cursor: pointer;
}
.runner .bookmark:hover { background: var(--warn-soft); }
.runner .bookmark .icon { width: 26px; height: 26px; }
.runner .bookmark[aria-pressed="true"] .icon { fill: currentColor; }

/* Opciones del test: lista vertical con botón de radio y letra, como en el examen */
.runner .options { gap: 2px; }
.runner .option { grid-template-columns: auto auto 1fr; gap: 2px 10px; padding: 6px 12px; border-color: transparent; }
.runner .option:hover { border-color: #b3c2e6; background: #f6f8fd; }
.runner .option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.runner .option input {
  position: static; opacity: 1; pointer-events: auto; width: 18px; height: 18px; margin: 4px 0 0;
  accent-color: var(--brand); cursor: inherit;
}
.runner .option input:focus-visible { outline: none; box-shadow: none; }
.runner .option-key { display: inline; width: auto; height: auto; border-radius: 0; background: none; font-size: 1rem; }
.runner .option-key::after { content: "."; }
.runner .option-text { padding-top: 0; }
.runner .option:has(input:checked) .option-key { background: none; color: var(--brand-dark); }
.runner .options .option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.runner .options .option.is-correct .option-key { background: none; color: var(--ok); }
.runner .options .option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.runner .options .option.is-wrong .option-key { background: none; color: var(--bad); }
.runner .why { grid-column: 3; }
.runner .options-figures, .runner .options-letters { gap: 12px; }
.runner .options-figures .option, .runner .options-letters .option {
  grid-template-columns: 1fr 1fr; grid-template-areas: "figure figure" "radio key"; justify-items: start;
  align-items: center; gap: 8px; padding: 10px 8px; border-color: var(--line);
}
.runner .options-letters .option { grid-template-areas: "radio key"; padding: 14px 8px; }
.runner .options-figures .option input, .runner .options-letters .option input { grid-area: radio; justify-self: end; margin: 0; }
.runner .options-figures .option-key, .runner .options-letters .option-key { grid-area: key; }
.runner .option-figure { grid-area: figure; justify-self: center; }
.runner .options-figures .why, .runner .options-letters .why { grid-column: 1 / -1; }

.runner .practice-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.runner .question-nav { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-top: 12px; }
.runner .question-nav .nav-forward { margin-left: auto; }
.runner .arrow-button {
  display: inline-grid; place-items: center; min-width: 66px; height: 40px; padding: 0 18px; border: 1.5px solid var(--brand);
  border-radius: 999px; background: var(--card); color: var(--brand); cursor: pointer; transition: background-color 0.12s;
}
.runner .arrow-button:hover { background: var(--brand-soft); }
.runner .arrow-button.is-primary { background: var(--brand); color: #fff; }
.runner .arrow-button.is-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.runner .button-danger { background: var(--bad); border-color: var(--bad); border-radius: 999px; color: #fff; }
.runner .button-danger:hover { background: #962419; border-color: #962419; color: #fff; }
.runner .shortcuts { display: flex; gap: 8px; align-items: flex-start; max-width: 62ch; margin-top: 26px; font-size: 0.84rem; color: var(--muted); cursor: pointer; }
.runner .shortcuts input { margin-top: 3px; }
.runner .shortcuts small { display: block; }
/* Estado del guardado: discreto si todo va bien, bien visible si hay respuestas sin guardar. */
.runner .save-status {
  position: fixed; left: calc(50% + 44px); bottom: 10px; z-index: 15; max-width: min(620px, calc(100vw - 130px)); margin: 0;
  border-radius: 999px; color: var(--muted); font-size: 0.82rem; pointer-events: none; transform: translateX(-50%);
}
.runner .save-status:not(:empty) { padding: 4px 12px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px var(--line); }
.runner .save-status.is-error {
  padding: 9px 16px; border-radius: 10px; background: var(--bad-soft); color: #7c1f17; font-size: 0.92rem; font-weight: 700;
  box-shadow: 0 0 0 1px #e0a59d, 0 8px 22px rgba(20, 33, 61, 0.22);
}

/* Calculadora flotante (solo en la prueba numérica); se coloca desde calculator.js */
.runner .calculator {
  position: fixed; top: 208px; left: 120px; z-index: 40; width: 308px; padding: 0 9px 10px; border-radius: 12px;
  background: var(--rail-bg); color: #fff; box-shadow: 0 18px 50px rgba(12, 23, 48, 0.5);
}
.runner .calculator:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 18px 50px rgba(12, 23, 48, 0.5); }
.runner .calculator :focus-visible { outline-offset: 1px; }
.runner .calc-titlebar { display: flex; align-items: center; gap: 8px; padding: 7px 2px 7px 4px; cursor: move; touch-action: none; user-select: none; }
.runner .calc-titlebar .icon-move { width: 20px; height: 20px; }
.runner .calc-title { flex: 1 1 auto; margin: 0; font-size: 0.86rem; font-weight: 700; }
.runner .calc-close { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #fff; cursor: pointer; }
.runner .calc-close:hover { background: rgba(255, 255, 255, 0.16); }
.runner .calc-close .icon { width: 18px; height: 18px; }
.runner .calc-screen { display: grid; align-content: end; min-height: 78px; margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; background: #050b1a; text-align: right; }
.runner .calc-expression { min-height: 1.3em; margin: 0; overflow: hidden; color: #aebbdb; font-size: 0.8rem; white-space: nowrap; }
.runner .calc-value { display: block; overflow: hidden; font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; }
.runner .calc-value.is-long { font-size: 1.45rem; }
.runner .calc-value.is-longer { font-size: 1.1rem; }
.runner .calc-value.is-error { color: #ffb4a8; }
.runner .calc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.runner .calc-keys button {
  height: 44px; padding: 0; border: 0; border-radius: 7px; background: #2b3650; color: #fff;
  font: inherit; font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.runner .calc-keys button:hover { filter: brightness(1.2); }
.runner .calc-keys button:active { transform: translateY(1px); }
.runner .calc-keys sup { font-size: 0.62em; }
.runner .calc-keys .key-function { background: #56617a; }
.runner .calc-keys .key-small { font-size: 0.86rem; }
.runner .calc-keys .key-operator { background: var(--accent); color: var(--ink); font-size: 1.3rem; }
.runner .calc-keys .key-all-clear { background: var(--bad); }
.runner .calc-keys .key-equals { background: #2f5fc4; font-size: 1.3rem; }
.runner .key-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.runner .key-split button:first-child { border-radius: 7px 0 0 7px; }
.runner .key-split button:last-child { border-radius: 0 7px 7px 0; }
.runner .calc-hint { margin: 8px 2px 0; color: #aebbdb; font-size: 0.72rem; line-height: 1.35; }

/* Diálogos */
.dialog {
  width: min(460px, calc(100vw - 32px)); max-width: none; padding: 24px 26px; border: 0; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(20, 33, 61, 0.35); color: var(--ink);
}
.dialog::backdrop { background: rgba(20, 33, 61, 0.55); }
.dialog:focus-visible { outline: none; box-shadow: 0 20px 60px rgba(20, 33, 61, 0.35); }
.dialog h2 { color: var(--brand-dark); }
.dialog-wide { width: min(620px, calc(100vw - 32px)); }
.dialog .instructions { margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.dialog-jumps { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog-warning {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding: 10px 14px; border: 1px solid #f1d58a;
  border-radius: 9px; background: var(--warn-soft); color: #5c3a00; font-weight: 700;
}
.dialog-warning .icon { flex: none; color: var(--warn); }
.dialog-stack { display: grid; gap: 9px; margin-top: 16px; }
.code-input {
  width: 100%; padding: 9px 12px; border: 1.5px solid #9fb0d6; border-radius: 9px; color: var(--brand-dark);
  font: inherit; font-size: 1.35rem; font-weight: 800; letter-spacing: 0.3em; text-align: center;
}
.dialog-timeup { text-align: center; }
.timeup-count { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 0; color: var(--bad); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timeup-count .icon { width: 30px; height: 30px; color: var(--brand); }

/* Resultados */
.verdict { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 14px 18px; border-radius: var(--radius); margin: 12px 0 18px; }
.verdict strong { font-size: 1.3rem; }
.verdict-ok { background: var(--ok-soft); border: 1px solid #b5dfc8; color: #0f5a33; }
.verdict-bad { background: var(--bad-soft); border: 1px solid #efc1bb; color: #7c1f17; }
.big-score { font-size: 2.3rem; font-weight: 800; line-height: 1; margin: 6px 0 8px; }
.big-score span { font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.result-cards .card p { margin-bottom: 4px; }
.verdict-lines { list-style: none; padding: 0; margin: 16px 0 0; }
.verdict-lines li { padding-left: 22px; position: relative; margin-bottom: 4px; }
.verdict-lines li::before { position: absolute; left: 0; font-weight: 700; }
.verdict-lines .ok::before { content: "✓"; color: var(--ok); }
.verdict-lines .bad::before { content: "✗"; color: var(--bad); }

.review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.review-filter { display: flex; gap: 8px; }
.review-section { margin: 22px 0 10px; font-size: 1.12rem; }
.review-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.review-item summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; cursor: pointer; font-weight: 600; }
.review-item .summary-answer { margin-left: auto; font-weight: 400; }
.review-body { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: none; }
.status { font-size: 0.86rem; padding: 2px 10px; border-radius: 999px; }
.status-correct { background: var(--ok-soft); color: var(--ok); }
.status-wrong { background: var(--bad-soft); color: var(--bad); }
.status-blank { background: #eef0f5; color: var(--muted); }
.review.only-failed .review-correct { display: none; }
.page-actions { display: flex; gap: 10px; margin: 26px 0; }

@media (max-width: 900px) {
  .intro-columns { grid-template-columns: minmax(0, 1fr); }
  .runner { grid-template-columns: 66px minmax(0, 1fr); }
  .runner .rail-button { font-size: 0.62rem; }
  .runner .part:not(.is-current) { display: none; }
  .runner .workspace:has(> .draft:not([hidden])) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .runner .draft { position: static; }
  .runner .draft textarea { height: 150px; min-height: 110px; }
  .options-figures, .options-letters { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .runner .options-figures, .runner .options-letters { gap: 6px; }
  .series { gap: 6px; }
  .question, .runner .question { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (forced-colors: active) {
  .option:has(input:checked) { outline: 3px solid Highlight; }
  .option.is-correct { outline: 3px solid LinkText; }
  /* Los colores de la barra de preguntas son información: se conservan. */
  .runner .seg::before, .runner .seg-mark, .runner .legend-swatch { forced-color-adjust: none; }
}

/* Selector de nivel de la portada */
.level-picker {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 14px 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
}
.level-picker h2 { font-size: 1.05rem; margin: 0 0 2px; }
.level-picker p { margin: 0; max-width: 62ch; font-size: 0.92rem; }
.level-options { display: flex; flex-wrap: wrap; gap: 8px; }

/* Acceso con contraseña (versión publicada) */
.login-card { max-width: 420px; margin: 48px auto; padding: 28px 30px; }
.login-form { display: grid; gap: 10px; margin-top: 12px; }
.login-form input[type="password"] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.logout-form { display: inline; margin: 0; }
.site-header .logout-button { color: #fff; text-decoration: none; font: inherit; }
.site-header .logout-button:hover { text-decoration: underline; }
