/* =====================================================================
   Entrenador ECEP · Ciencias Naturales — Hoja de estilos
   Mobile-first. Soporta modo claro y oscuro.
   ===================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --border-strong: #c4cbd4;
  --text: #1a1f26;
  --text-soft: #5b6672;
  --text-faint: #8b95a1;

  --brand: #0f6e64;
  --brand-strong: #0a5249;
  --brand-soft: #e6f4f1;

  --ok: #1a7f4b;
  --ok-bg: #e8f6ee;
  --ok-border: #7cc79b;

  --bad: #c0322b;
  --bad-bg: #fdecea;
  --bad-border: #eda29d;

  --warn: #9a6700;
  --warn-bg: #fff4d6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);
  --maxw: 780px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #12151a;
    --surface: #1a1f26;
    --surface-2: #222933;
    --border: #2f3742;
    --border-strong: #3f4956;
    --text: #e8ecf1;
    --text-soft: #a8b2be;
    --text-faint: #7d8895;

    --brand: #4db6a8;
    --brand-strong: #6fc9bd;
    --brand-soft: #16302d;

    --ok: #5fd08d;
    --ok-bg: #122c1e;
    --ok-border: #2f7a50;

    --bad: #f28b82;
    --bad-bg: #2f1817;
    --bad-border: #8a3b35;

    --warn: #e0b341;
    --warn-bg: #2e2612;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .45);
  }
}

:root[data-tema="oscuro"] {
  --bg: #12151a; --surface: #1a1f26; --surface-2: #222933;
  --border: #2f3742; --border-strong: #3f4956;
  --text: #e8ecf1; --text-soft: #a8b2be; --text-faint: #7d8895;
  --brand: #4db6a8; --brand-strong: #6fc9bd; --brand-soft: #16302d;
  --ok: #5fd08d; --ok-bg: #122c1e; --ok-border: #2f7a50;
  --bad: #f28b82; --bad-bg: #2f1817; --bad-border: #8a3b35;
  --warn: #e0b341; --warn-bg: #2e2612;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

/* ---------- Layout ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.barra {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .6rem 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.barra .marca { font-weight: 700; font-size: .95rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: .5rem; }
.barra .marca span.pico { color: var(--brand); font-size: 1.15rem; line-height: 1; }
.barra .sep { flex: 1; }
.barra .usuario { font-size: .82rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }

.contenido { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 1rem 1rem 4rem; }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.tarjeta.plana { box-shadow: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .94rem;
  padding: .7rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand); color: #fff;
  cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secundario { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.fantasma { background: transparent; color: var(--brand); border-color: transparent; padding-inline: .5rem; }
.btn.peligro { background: transparent; color: var(--bad); border-color: var(--bad-border); }
.btn.ancho { width: 100%; }
.btn.chico { padding: .45rem .75rem; font-size: .85rem; min-height: 36px; }

.fila-btn { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- Formularios ---------- */
.campo { margin-bottom: .9rem; }
.campo label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-soft); }
.campo input[type="text"], .campo input[type="email"], .campo input[type="password"], .campo input[type="date"], .campo select {
  width: 100%; font: inherit; font-size: 1rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  min-height: 44px;
}
.campo input:focus, .campo select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .88rem; color: var(--text-soft); margin-bottom: .9rem; }
.check input { margin-top: .25rem; width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; }

.aviso { padding: .7rem .85rem; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: .9rem; }
.aviso.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.aviso.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border); }
.aviso.info { background: var(--brand-soft); color: var(--brand-strong); border: 1px solid var(--brand); }
.aviso.alerta { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }

/* ---------- Etiquetas ---------- */
.etiqueta {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 650; letter-spacing: .02em;
  padding: .18rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.etiqueta.verificada { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.etiqueta.propuesta { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.etiqueta.facil { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.etiqueta.media { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.etiqueta.dificil { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.etiquetas { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }

/* ---------- Quiz ---------- */
.progreso-barra { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: .35rem; }
.progreso-barra > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s ease; }
.progreso-texto { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-soft); margin-bottom: 1rem; }

.enunciado { font-size: 1rem; line-height: 1.6; }
.enunciado .extra { color: var(--text-soft); font-size: .95rem; }
.enunciado ol, .enunciado ul { padding-left: 1.3rem; margin: .5rem 0 .8rem; }
.enunciado li { margin-bottom: .3rem; }
.pregunta-directa { font-weight: 650; margin-top: .8rem; }

.opciones { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.opcion {
  display: flex; align-items: flex-start; gap: .7rem;
  width: 100%; text-align: left;
  font: inherit; font-size: .95rem; line-height: 1.5;
  padding: .8rem .9rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  color: var(--text);
}
.opcion:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.opcion:disabled { cursor: default; }
.opcion .letra {
  flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  font-weight: 700; font-size: .82rem;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.opcion.marcada { border-color: var(--brand); background: var(--brand-soft); }
.opcion.marcada .letra { background: var(--brand); color: #fff; border-color: var(--brand); }
.opcion.marcada .marca-res { color: var(--brand); }
.opcion.correcta { border-color: var(--ok-border); background: var(--ok-bg); }
.opcion.correcta .letra { background: var(--ok); color: #fff; border-color: var(--ok); }
.opcion.incorrecta { border-color: var(--bad-border); background: var(--bad-bg); }
.opcion.incorrecta .letra { background: var(--bad); color: #fff; border-color: var(--bad); }
.opcion > span:not(.letra):not(.marca-res) { flex: 1; min-width: 0; }
.opcion svg { display: block; width: 170px; max-width: 100%; height: auto; }
.opcion .tabla-envoltura { margin: 0; }
.opcion table.datos { font-size: .78rem; min-width: 280px; }
.opcion table.datos th, .opcion table.datos td { padding: .3rem .45rem; }
.opcion .marca-res { margin-left: auto; font-weight: 700; font-size: .78rem; flex-shrink: 0; padding-left: .4rem; }
.opcion.correcta .marca-res { color: var(--ok); }
.opcion.incorrecta .marca-res { color: var(--bad); }

.retro { border-radius: var(--radius-sm); padding: .85rem .95rem; margin: 1rem 0; border: 1px solid; font-size: .92rem; }
.retro.acierto { background: var(--ok-bg); border-color: var(--ok-border); }
.retro.fallo { background: var(--bad-bg); border-color: var(--bad-border); }
.retro .titulo { font-weight: 700; margin-bottom: .35rem; display: flex; align-items: center; gap: .4rem; }
.retro.acierto .titulo { color: var(--ok); }
.retro.fallo .titulo { color: var(--bad); }
.retro .detalle { color: var(--text); }
.retro .por-que { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid rgba(128,128,128,.25); }
.retro .por-que b { display: block; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); margin-bottom: .2rem; }

.concepto { background: var(--surface-2); border-left: 3px solid var(--brand); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: .75rem .9rem; font-size: .9rem; margin: 1rem 0; }
.concepto b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); margin-bottom: .25rem; }

/* ---------- Figuras y tablas ---------- */
.figura { margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .85rem; background: var(--surface-2); }
.figura .fig-titulo { font-size: .82rem; font-weight: 700; color: var(--text-soft); margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .03em; }
.figura .fig-desc { font-size: .88rem; color: var(--text-soft); }
.figura .fig-fuente { font-size: .74rem; color: var(--text-faint); margin-top: .5rem; font-style: italic; }
.figura svg { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }

.tabla-envoltura { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0; }
table.datos { border-collapse: collapse; width: 100%; font-size: .86rem; min-width: 320px; background: var(--surface); }
table.datos th, table.datos td { border: 1px solid var(--border-strong); padding: .45rem .6rem; text-align: center; }
table.datos th { background: var(--surface-2); font-weight: 700; }
table.datos td:first-child, table.datos th:first-child { text-align: left; }

/* ---------- Resultados ---------- */
.nivel-caja { text-align: center; padding: 1.5rem 1rem; }
.nivel-letra { font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.nivel-letra.n-A { color: var(--ok); }
.nivel-letra.n-B { color: var(--brand); }
.nivel-letra.n-C { color: var(--warn); }
.nivel-letra.n-D { color: var(--bad); }
.nivel-nombre { font-size: 1.05rem; font-weight: 650; margin-top: .25rem; }
.nivel-detalle { color: var(--text-soft); font-size: .9rem; margin-top: .35rem; }

.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.cifra { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem .5rem; text-align: center; }
.cifra .v { font-size: 1.5rem; font-weight: 750; line-height: 1.1; }
.cifra .e { font-size: .74rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; margin-top: .15rem; }
.cifra.buena .v { color: var(--ok); }
.cifra.mala .v { color: var(--bad); }

.dominio-fila { margin-bottom: .8rem; }
.dominio-cab { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .87rem; margin-bottom: .25rem; }
.dominio-cab .nom { font-weight: 600; }
.dominio-cab .pct { color: var(--text-soft); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.dominio-barra { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.dominio-barra > i { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }

/* ---------- Listas de selección ---------- */
.lista-op { display: flex; flex-direction: column; gap: .6rem; }
.item-op {
  display: flex; align-items: center; gap: .8rem;
  width: 100%; text-align: left; font: inherit;
  padding: .85rem .9rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.item-op:hover { border-color: var(--brand); background: var(--brand-soft); }
.item-op .icono { font-size: 1.3rem; flex-shrink: 0; width: 32px; text-align: center; }
.item-op .cuerpo { flex: 1; min-width: 0; }
.item-op .t { display: block; font-weight: 650; font-size: .95rem; }
.item-op .d { display: block; font-size: .82rem; color: var(--text-soft); margin-top: .1rem; line-height: 1.4; }
.item-op .flecha { color: var(--text-faint); flex-shrink: 0; }
.item-op[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); border-width: 2px; }

.pastillas { display: flex; flex-wrap: wrap; gap: .45rem; }
.pastilla {
  font: inherit; font-size: .85rem; font-weight: 600;
  padding: .45rem .8rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-soft);
  cursor: pointer; min-height: 38px;
}
.pastilla[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Utilidades ---------- */
.centro { text-align: center; }
.silencio { color: var(--text-soft); font-size: .88rem; }
.mini { font-size: .78rem; color: var(--text-faint); }
.mt { margin-top: 1rem; } .mb0 { margin-bottom: 0; }
.oculto { display: none !important; }
.cargando { text-align: center; padding: 3rem 1rem; color: var(--text-soft); }

.pie { text-align: center; padding: 1.5rem 1rem 2rem; font-size: .78rem; color: var(--text-faint); border-top: 1px solid var(--border); margin-top: 2rem; }

.cronometro { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; padding: .3rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); }
.cronometro.urgente { background: var(--bad-bg); color: var(--bad); }

/* ---------- Escritorio ---------- */
@media (min-width: 768px) {
  body { font-size: 16.5px; }
  h1 { font-size: 1.8rem; }
  .contenido { padding: 1.75rem 1.5rem 4rem; }
  .tarjeta { padding: 1.35rem; }
  .cifras { grid-template-columns: repeat(3, 1fr); }
  .opcion { padding: .9rem 1rem; }
}

@media (min-width: 1100px) {
  :root { --maxw: 860px; }
}

/* Respeta preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Impresión */
@media print {
  .barra, .fila-btn, .btn { display: none !important; }
  .tarjeta { box-shadow: none; border-color: #ccc; page-break-inside: avoid; }
}
