/* Factorización · paleta "ocre". Contrastes verificados (AA, 4,5:1 o más) en claro y oscuro: texto, texto de acento sobre
   las superficies y texto de los botones sobre su color. */
:root {
  --bg: #FAF6EE;
  --surface: #FFFFFF;
  --pad: #FDFAF4;
  --text: #241C0E;
  --muted: #5E5340;
  --border: #E4D9C3;
  --accent: #8A5A00;
  --accent-fill: #8A5A00;   /* con texto blanco */
  --accent-ink: #FFFFFF;
  --accent-text: #7A4E00;
  --warm: #E8A33D;
  --warm-ink: #3A2504;
  --error: #B93A30;
  --ok: #1F7A4D;
  --input: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130B;
    --surface: #221C10;
    --pad: #1C170D;
    --text: #F1EADB;
    --muted: #B8AB91;
    --border: #3E3522;
    --accent: #E3B04F;
    --accent-fill: #E3B04F;
    --accent-ink: #17130B;
    --accent-text: #F0C46B;
    --warm: #F2B960;
    --warm-ink: #2A1B04;
    --error: #F07A6F;
    --ok: #6FD6A0;
    --input: #17130B;
    color-scheme: dark;
  }
}

.muted { color: var(--muted); font-size: 0.9rem; }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 12px; }
.logo { border-radius: 10px; flex: none; }
h1 { font-size: 1.5rem; line-height: 1.2; color: var(--accent-text); }
.tagline { color: var(--muted); font-size: 0.95rem; }
.intro { color: var(--muted); margin-bottom: 14px; }
h2 { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
[hidden] { display: none !important; }
.card { margin-bottom: 14px; }

/* Campos */
.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo label, .campo-l { font-size: 0.875rem; font-weight: 700; color: var(--muted); }
.campo select {
  width: 100%; min-height: 48px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 1rem;
}
.fila-tema { display: flex; flex-direction: column; gap: 12px; }
.aciertos { font-weight: 600; font-variant-numeric: tabular-nums; }
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opciones .chip { min-height: 44px; padding: 0 14px; font-weight: 600; }

/* Fórmulas (las dibuja el motor de expresiones) */
.mx { font-family: 'Cambria Math', 'STIX Two Math', 'Latin Modern Math', Georgia, 'Times New Roman', serif; font-size: 1.1em; white-space: nowrap; font-weight: 400; }
.mx .mv { font-style: italic; }
.mx .mfnn { font-style: normal; }
.mo { margin: 0 0.2em; }
.mneg { margin: 0 0.04em 0 0; }
.mrel { margin: 0 0.4em; }
.mj { margin-left: 0.12em; }
.mf { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.15em; line-height: 1.15; }
.mfn { border-bottom: 1.5px solid currentColor; padding: 0 0.25em 0.08em; }
.mfd { padding: 0.08em 0.25em 0; }
.mf .mf { font-size: 0.92em; }
.mx sup { font-size: 0.68em; vertical-align: 0.75em; line-height: 0; margin-left: 0.06em; }
.mjf { margin-left: 0.28em; }
.mr { white-space: nowrap; }
.mra { border-top: 1.5px solid currentColor; padding: 0.05em 0.1em 0; margin-left: 0.04em; }
.mri { margin-right: -0.35em; vertical-align: 1em; }
.mlim { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin-right: 0.3em; line-height: 1.1; }
.mlims { font-size: 0.66em; }
.mint { font-size: 1.6em; vertical-align: middle; line-height: 1; }
/* En el texto, una ecuación larga puede partirse después del signo igual (y solo ahí: las piezas no se cortan) */
.enunciado .mx, .op .mx, .sol .mx { white-space: normal; }
.mx > * { white-space: nowrap; }

/* Ejercicio */
.ejercicio { display: flex; flex-direction: column; gap: 12px; }
.enunciado { line-height: 1.6; font-size: 1.0625rem; }
.enunciado .mx { font-size: 1.15em; }
.filas { display: flex; flex-direction: column; gap: 10px; }
.fila { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 1.125rem; }
.fila-r { font-size: 1rem; font-weight: 600; color: var(--muted); }
.fila .mx { font-size: 1.05em; }
.fila input {
  width: 6.5em; min-width: 0; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--input); color: var(--text); font-size: 1.0625rem; font-variant-numeric: tabular-nums;
}
.fila.slots input { width: 4.2em; text-align: center; }
.fila input.ancho { flex: 1 1 12em; width: auto; }
.fila input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.fila input.bien { border-color: var(--ok); }
.fila input.mal { border-color: var(--error); border-style: dashed; }
.fila input[readonly] { opacity: 1; }
.plantilla { font-family: 'Cambria Math', 'STIX Two Math', Georgia, 'Times New Roman', serif; white-space: nowrap; }

.teclas { display: flex; flex-wrap: wrap; gap: 6px; }
.teclas button { min-width: 48px; min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-size: 1.125rem; font-weight: 600; }
.teclas button:hover { border-color: var(--accent); }
/* Con el teclado del celular abierto, la barra flota justo arriba de él (la ubica _shared/teclado) */
.teclas.flota {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0;
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgb(0 0 0 / 0.08);
}
.teclas.flota::-webkit-scrollbar { display: none; }
.teclas.flota button { flex: 0 0 auto; }

.ops { display: flex; flex-direction: column; gap: 8px; }
.op {
  width: 100%; min-height: 48px; padding: 10px 14px; text-align: left; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.0625rem; line-height: 1.5;
}
.op:hover:not([disabled]) { border-color: var(--accent); }
.op.mal { border-color: var(--error); border-style: dashed; color: var(--muted); }
.op.bien { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.op[disabled] { cursor: default; }

/* Práctica */
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.estado { min-height: 1.5rem; margin-bottom: 4px; line-height: 1.4; }
.estado.ok { color: var(--ok); font-weight: 600; }
.estado.mal { color: var(--error); font-weight: 600; }
.margen { margin-bottom: 14px; }
.sol-r { line-height: 1.7; margin-bottom: 14px; }
.sol-r .mx { font-size: 1.1em; }
.pasos { list-style: decimal; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; line-height: 1.6; }

.foot { margin: 32px 0 16px; display: flex; flex-direction: column; gap: 6px; }
