/* Física por niveles · paleta "bordó". Contrastes verificados (AA, 4,5:1 o más) en claro y oscuro: texto, texto de acento
   sobre las superficies, texto de los botones sobre su color y los números de los gráficos. Los gráficos van en azul y
   violeta, no en bordó (parecería un error); el error se marca en rojo anaranjado, con borde punteado. */
:root {
  --bg: #FAF4F5;
  --surface: #FFFFFF;
  --pad: #FDF8F9;
  --text: #26141A;
  --muted: #634E55;
  --border: #EAD9DE;
  --accent: #8B2346;
  --accent-fill: #8B2346;   /* con texto blanco */
  --accent-ink: #FFFFFF;
  --accent-text: #7A1E3D;
  --warm: #E8A33D;
  --warm-ink: #3A2504;
  --error: #B8411C;
  --ok: #1F7A4D;
  --input: #FFFFFF;
  --g-grid: #EFE3E6;
  --g-axis: #3E2A31;
  --g-num: #634E55;
  --g-s0: #2F5E8A;
  --g-s1: #6B3FB8;
  --g-area: rgb(47 94 138 / 0.15);
  --g-dash: #8C7A80;
  --g-tan: #A15C00;
  --g-cursor: #634E55;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A0F12;
    --surface: #241519;
    --pad: #1F1216;
    --text: #F3E6EA;
    --muted: #C2A8B0;
    --border: #42282F;
    --accent: #F09AB5;
    --accent-fill: #F09AB5;
    --accent-ink: #1A0F12;
    --accent-text: #F5B3C8;
    --warm: #F2B960;
    --warm-ink: #2A1B04;
    --error: #FF9470;
    --ok: #6FD6A0;
    --input: #1A0F12;
    --g-grid: #35222A;
    --g-axis: #DCC8CE;
    --g-num: #C2A8B0;
    --g-s0: #8DB8EE;
    --g-s1: #C3A8F0;
    --g-area: rgb(141 184 238 / 0.18);
    --g-dash: #8C7A80;
    --g-tan: #F2B960;
    --g-cursor: #C2A8B0;
    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; }

/* Modos */
.modos { display: flex; gap: 6px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 14px; }
.modos button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--muted); }
.modos button[aria-selected="true"] { background: var(--accent-fill); color: var(--accent-ink); }

/* Gráficos (los dibuja _shared/fisica/graficos.js) */
.figura:empty { display: none; }
.figura { background: var(--pad); border: 1px solid var(--border); border-radius: 12px; padding: 6px; }
.gr-fig { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }
.gr-fig text { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.gr-grid { stroke: var(--g-grid); stroke-width: 1; }
.gr-axis { stroke: var(--g-axis); stroke-width: 1.6; }
.gr-num { fill: var(--g-num); font-size: 12px; font-variant-numeric: tabular-nums; }
.gr-marca { fill: var(--accent-text); font-weight: 700; }
.gr-lab { fill: var(--text); font-size: 13px; font-weight: 600; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.gr-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.gr-s0 { stroke: var(--g-s0); }
.gr-s1 { stroke: var(--g-s1); stroke-dasharray: 9 5; }
.gr-sl { font-size: 14px; font-weight: 700; }
.gr-sl0 { fill: var(--g-s0); }
.gr-sl1 { fill: var(--g-s1); }
.gr-area { fill: var(--g-area); stroke: none; }
.gr-dash { stroke: var(--g-dash); stroke-width: 1.2; stroke-dasharray: 4 4; }
.gr-dot { fill: var(--g-s0); stroke: var(--pad); stroke-width: 1.5; }
.gr-punto { fill: var(--g-tan); }
.gr-seg { fill: var(--g-s1); font-size: 14px; font-weight: 700; }
.gr-tan { stroke: var(--g-tan); stroke-width: 2.2; stroke-dasharray: 7 4; }
.gr-cursor { stroke: var(--g-cursor); stroke-width: 1.5; stroke-dasharray: 2 3; }

/* Tabla de datos */
.tabla-w { overflow-x: auto; }
.tabla { border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 0 auto; }
.tabla th, .tabla td { padding: 6px 10px; border: 1px solid var(--border); text-align: center; white-space: nowrap; }
.tabla th { color: var(--muted); font-weight: 600; text-align: left; background: var(--surface); }
.unidad { font-size: 1rem; color: var(--muted); }


/* Inicio: dificultad y temas */
.dificultad { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.temas { display: flex; flex-direction: column; gap: 14px; }
.tema h2 { font-size: 1.0625rem; letter-spacing: 0; text-transform: none; color: var(--text); margin-bottom: 10px; }
.niveles { display: flex; flex-direction: column; gap: 8px; }
.nivel-b {
  width: 100%; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--border); background: var(--pad);
  color: var(--text); text-align: left; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
}
.nivel-b:hover:not([aria-disabled="true"]) { border-color: var(--accent); }
.nivel-b .n-nombre { font-weight: 700; }
.nivel-b .n-estado { font-size: 0.8125rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.nivel-b .n-avance { grid-column: 1 / -1; font-size: 0.875rem; color: var(--muted); }
.nivel-b[data-estado="pasado"] .n-estado { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.nivel-b[data-estado="abierto"] { border-color: var(--accent); }
.nivel-b[data-estado="abierto"] .n-estado { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.nivel-b[aria-disabled="true"] { cursor: default; color: var(--muted); background: transparent; border-style: dashed; }
.borrar { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.conf { display: flex; flex-direction: column; gap: 10px; }
.btn.peligro { background: var(--error); color: var(--surface); }
.btn.chico { min-height: 40px; padding: 0 12px; font-size: 0.9375rem; }

/* Práctica */
.volver { margin-bottom: 10px; }
.cabeza { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.p-tema { font-size: 1.0625rem; letter-spacing: 0; text-transform: none; color: var(--text); margin: 0; }
.p-nivel { font-weight: 600; color: var(--accent-text); }
.barra { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.barra span { display: block; height: 100%; width: 0; background: var(--accent-fill); border-radius: 999px; transition: width 0.3s; }
.aviso { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--warm); color: var(--warm-ink); font-weight: 600; }
.aviso p { flex: 1 1 200px; }
.pista { border-left: 4px solid var(--warm); padding: 8px 12px; background: var(--pad); border-radius: 0 10px 10px 0; display: flex; flex-direction: column; gap: 4px; }
