:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5d6679;
  --line: #e2e6ef;
  --brand: #3b5bdb;
  --brand-soft: #e7ecff;
  --ok: #2f9e44;
  --ok-soft: #e6f6ea;
  --bad: #d6336c;
  --bad-soft: #fde8ef;
  --warn: #e8590c;
  --warn-soft: #fff1e6;
  --fuente: #f8f5ec;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --card: #1b1f2a; --ink: #e8ebf2; --muted: #9aa3b5; --line: #2c3242;
    --brand: #7c96ff; --brand-soft: #232c4a; --ok: #51cf66; --ok-soft: #1b3324;
    --bad: #f783ac; --bad-soft: #3a1f2b; --warn: #ffa94d; --warn-soft: #3a2a1a; --fuente: #23231d;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --card: #1b1f2a; --ink: #e8ebf2; --muted: #9aa3b5; --line: #2c3242;
  --brand: #7c96ff; --brand-soft: #232c4a; --ok: #51cf66; --ok-soft: #1b3324;
  --bad: #f783ac; --bad-soft: #3a1f2b; --warn: #ffa94d; --warn-soft: #3a2a1a; --fuente: #23231d;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; margin-top: 1.4em; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.top {
  position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
}
.marca { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--ink); }
.migas { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.migas:empty { display: none; }
.migas a { color: var(--muted); }

main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }
.cargando { color: var(--muted); }

.tarjeta {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 10px 0; box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
a.tarjeta:active { transform: scale(.99); }
a.tarjeta:hover { border-color: var(--brand); }
.tarjeta h3 { margin: 0 0 2px; }
.fila { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.fila > div { min-width: 0; }
.chip {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.gris { background: var(--line); color: var(--muted); }
.icono { font-size: 1.6rem; line-height: 1; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 600; text-decoration: none;
}
.btn.sec { background: var(--brand-soft); color: var(--brand); }
.btn.peq { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.botones { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }

/* Plan de estudio */
.plan { list-style: none; padding: 0; margin: 0; }
.plan li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan li:last-child { border-bottom: 0; }
.plan input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--ok); }
.plan .hecho .txt { text-decoration: line-through; color: var(--muted); }
.plan .hoy { background: var(--warn-soft); margin: 0 -16px; padding: 10px 16px; }

/* Prueba */
.barra {
  position: sticky; top: 56px; z-index: 5; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0 16px; box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.barra .nota { font-size: 1.4rem; font-weight: 800; }
.progreso { height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; flex: 1 1 100%; }
.progreso > div { height: 100%; background: var(--brand); transition: width .2s; }
.info { background: var(--brand-soft); border-radius: var(--radius); padding: 12px 14px; font-size: .92rem; }
.parte h2 { border-bottom: 2px solid var(--brand); padding-bottom: 4px; }
.preg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.preg.ok { border-color: var(--ok); }
.preg.bad { border-color: var(--bad); }
.enun { font-weight: 600; margin-bottom: 8px; }
.enun .n { color: var(--brand); }
.bloom {
  display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 5px; vertical-align: middle; margin-left: 4px; background: var(--line); color: var(--muted);
}
.pts { float: right; font-size: .8rem; color: var(--muted); font-weight: 600; }
.fuente { background: var(--fuente); border-left: 4px solid #c9a227; border-radius: 8px; padding: 12px 14px; margin: 12px 0; font-size: .95rem; overflow-x: auto; }
.fuente table, .resp table { border-collapse: collapse; margin-top: 8px; font-size: .88rem; width: 100%; }
.fuente th, .fuente td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.ref { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.apoyo { margin: 6px 0 10px; }

.opc { display: block; position: relative; }
.opc input { position: absolute; opacity: 0; pointer-events: none; }
.opc > span {
  display: flex; gap: 10px; align-items: flex-start; border: 2px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0; cursor: pointer; min-height: 48px;
}
.opc > span > b { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: .85rem; }
.opc input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.opc input:checked + span > b { background: var(--brand); color: #fff; }
.opc input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.opc.correcta input + span { border-color: var(--ok); background: var(--ok-soft); }
.opc.correcta input + span > b { background: var(--ok); color: #fff; }
.opc.erronea input + span { border-color: var(--bad); background: var(--bad-soft); }
.opc.erronea input + span > b { background: var(--bad); color: #fff; }
.corregida .opc > span { cursor: default; }

.vf-opts { display: flex; gap: 10px; }
.vf-opts .opc { flex: 1; }
.vf-opts .opc > span { justify-content: center; font-weight: 700; }

textarea, select {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card);
}
textarea { min-height: 110px; resize: vertical; }
textarea:focus, select:focus { border-color: var(--brand); outline: none; }
.par { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.par:last-child { border-bottom: 0; }
.par.ok select { border-color: var(--ok); }
.par.bad select { border-color: var(--bad); }
.defs { list-style: none; padding: 0; margin: 0 0 10px; font-size: .93rem; }
.defs li { padding: 4px 0; }
.defs b { color: var(--brand); }

.resp { border-radius: 12px; padding: 12px; margin-top: 10px; font-size: .93rem; }
.resp.modelo { background: var(--ok-soft); }
.resp.tuya { background: var(--bg); border: 1px dashed var(--line); white-space: pre-wrap; }
.resp.explica { background: var(--brand-soft); }
.resp h4 { margin: 0 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.autoeval { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.autoeval h4 { margin: 0 0 6px; font-size: .9rem; }
.crit { margin: 10px 0; }
.crit > div:first-child { font-size: .92rem; margin-bottom: 6px; }
.niveles { display: flex; flex-wrap: wrap; gap: 8px; }
.nivel {
  border: 2px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 12px; cursor: pointer;
  min-height: 44px; text-align: left; font-size: .9rem; flex: 1 1 auto;
}
.nivel.sel { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.nivel b { display: block; font-size: .8rem; color: var(--brand); }
.pendiente { outline: 2px dashed var(--warn); outline-offset: 3px; }

.resultado { text-align: center; padding: 18px 16px; }
.resultado .grande { font-size: 3rem; font-weight: 800; line-height: 1; }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th, .tabla td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.tabla td.num, .tabla th.num { text-align: right; }

/* Tarjetas */
.flash { perspective: 1000px; margin: 16px 0; }
.flash .cara {
  min-height: 240px; display: grid; place-items: center; text-align: center; padding: 24px; font-size: 1.2rem;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; cursor: pointer; box-shadow: var(--shadow);
}
.flash .cara.reverso { background: var(--brand-soft); border-color: var(--brand); font-size: 1.05rem; }
.flash .pista { font-size: .8rem; color: var(--muted); margin-top: 8px; }

@media (min-width: 640px) {
  .top { display: flex; align-items: center; gap: 16px; }
  .migas { flex: 1; }
  .barra { top: 52px; }
}
@media print {
  .top, .barra, .botones { display: none; }
}
