/* Cónicas · paleta "violeta". La curva va en el color de la app; los demás elementos del gráfico tienen su propio color y forma
   (el foco y la directriz comparten color porque van juntos; las asíntotas, grises y punteadas). Contrastes verificados (AA,
   4,5:1 o más) en claro y oscuro: texto, rótulos del gráfico sobre su fondo y texto de los botones sobre su color. */
:root {
  --bg: #F7F5FB;
  --surface: #FFFFFF;
  --pad: #FCFBFE;
  --text: #1E1A27;
  --muted: #5C566A;
  --border: #DDD7E8;
  --accent: #6B3FB8;
  --accent-fill: #6B3FB8;   /* con texto blanco */
  --accent-ink: #FFFFFF;
  --accent-text: #5B32A3;
  --warm: #E8A33D;
  --warm-ink: #3A2504;
  --error: #B93A30;
  --ok: #1F7A4D;
  --input: #FFFFFF;
  /* gráfico */
  --g-grid: #E1DAEC;
  --g-eje: #3D3748;
  --g-num: #6A6478;
  --g-curva: #6B3FB8;
  --g-foco: #A34E00;       /* foco y directriz */
  --g-vertice: #0E6E87;
  --g-centro: #1E1A27;
  --g-asintota: #77708A;
  --g-sombra: #D9CCF2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141219;
    --surface: #1E1A26;
    --pad: #19161F;
    --text: #ECE8F3;
    --muted: #ACA4BC;
    --border: #3A3446;
    --accent: #C3A8F0;
    --accent-fill: #C3A8F0;
    --accent-ink: #141219;
    --accent-text: #CDB6F4;
    --warm: #F2B960;
    --warm-ink: #2A1B04;
    --error: #F07A6F;
    --ok: #6FD6A0;
    --input: #141219;
    --g-grid: #352E42;
    --g-eje: #CFC8DC;
    --g-num: #A39BB3;
    --g-curva: #C3A8F0;
    --g-foco: #F2B960;
    --g-vertice: #5ED3EA;
    --g-centro: #ECE8F3;
    --g-asintota: #9890A8;
    --g-sombra: #3D3254;
    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; }

/* 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); }

/* 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; }

/* Gráfico */
.grafico { max-width: 420px; width: 100%; margin: 0 auto; }
.mg { width: 100%; height: auto; display: block; background: var(--pad); border: 1px solid var(--border); border-radius: 12px; }
.mg-grid { stroke: var(--g-grid); stroke-width: 1; }
.mg-eje { stroke: var(--g-eje); stroke-width: 1.4; }
.mg-n { font: 11px system-ui, -apple-system, sans-serif; fill: var(--g-num); }
.mg-n.c { text-anchor: middle; }
.mg-n.e { text-anchor: end; }
.mg-n.it { font-style: italic; font-size: 13px; fill: var(--g-eje); }
.mg-curva { fill: none; stroke: var(--g-curva); stroke-width: 2.6; stroke-linejoin: round; }
.mg-recta { stroke-width: 1.6; stroke-dasharray: 6 5; }
.mg-recta.asintota { stroke: var(--g-asintota); }
.mg-recta.directriz { stroke: var(--g-foco); stroke-dasharray: 2 4; stroke-width: 2.2; stroke-linecap: round; }
.mg-sombra { fill: var(--g-sombra); opacity: 0.75; }
.mg-punto { fill: var(--g-curva); }
.mg-punto.abierto { fill: var(--pad); stroke: var(--g-curva); stroke-width: 2.2; }
.mg-punto.centro { fill: var(--g-centro); }
.mg-punto.foco { fill: var(--g-foco); }
.mg-punto.vertice { fill: var(--pad); stroke: var(--g-vertice); stroke-width: 2.6; }
.mg-rot { font: 700 12px system-ui, -apple-system, sans-serif; fill: var(--g-centro); paint-order: stroke; stroke: var(--pad); stroke-width: 3px; }
.mg-rot.e { text-anchor: end; }
.mg-rot.foco { fill: var(--g-foco); }
.mg-rot.vertice { fill: var(--g-vertice); }

.leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: -4px; font-size: 0.875rem; color: var(--muted); }
.leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.leyenda svg { flex: none; }

/* 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; }

/* Explorar */
.controles { display: flex; flex-direction: column; gap: 14px; }
.deslizadores { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; }
.desl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; }
.desl label { font-size: 0.875rem; font-weight: 700; color: var(--muted); }
.desl output { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }
.desl input { grid-column: 1 / -1; width: 100%; min-height: 36px; accent-color: var(--accent); margin: 0; }
.ecuaciones .ecuacion { font-size: 1.125rem; margin-bottom: 12px; overflow-x: auto; padding: 0.45em 2px 4px; } /* con overflow, los exponentes necesitan el aire de arriba */
.ecuaciones .ecuacion:last-child { margin-bottom: 0; }
.elementos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: baseline; margin-bottom: 12px; }
.elementos dt { color: var(--muted); font-size: 0.9rem; }
.elementos dd { line-height: 1.5; }
.nota { line-height: 1.5; }

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