:root {
  --crema: #FAF8F2;
  --crema-2: #F1F6E4;
  --papel: #FFFDF8;
  --cafe: #3E2B1E;
  --cafe-medio: #93633A;
  --texto-suave: #5A4A3E;
  --verde: #5F7D0B;
  --lima: #A3C614;
  --azul: #1B6F9C;
  --rojo: #B3261E;
  --rojo-claro: #FBE9E7;
  --verde-claro: #EAF3D3;
  --borde: #E6E1D6;
  --sombra: 0 1px 3px rgba(62, 43, 30, .08), 0 4px 14px rgba(62, 43, 30, .06);
  --radio: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--crema);
  color: var(--cafe);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.45;
}
a { color: var(--azul); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
.envoltura { max-width: 1040px; margin: 0 auto; padding: 16px; }
.angosta { max-width: 520px; }

/* ------------------------------------------------ barra superior */
.barra {
  background: var(--cafe); color: var(--crema);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap;
}
.barra .marca { font-weight: 800; font-size: 1.25rem; color: var(--lima); text-decoration: none; letter-spacing: .3px; }
.barra .marca span { color: var(--crema); font-weight: 600; }
.barra .espacio { flex: 1; }
.barra a, .barra button.enlace { color: var(--crema); font-size: .95rem; }
.barra .quien { font-weight: 700; }

/* ------------------------------------------------ botones y formularios */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--verde); color: #fff; border: 0; border-radius: 999px;
  padding: 14px 28px; font: inherit; font-weight: 800; font-size: 1.1rem;
  cursor: pointer; text-decoration: none; min-height: 52px;
  box-shadow: 0 3px 0 #475e08;
}
.boton:hover { filter: brightness(1.05); }
.boton:active { transform: translateY(2px); box-shadow: 0 1px 0 #475e08; }
.boton:disabled { opacity: .5; cursor: default; }
.boton.azul { background: var(--azul); box-shadow: 0 3px 0 #13506f; }
.boton.cafe { background: var(--cafe-medio); box-shadow: 0 3px 0 #6c4827; }
.boton.claro { background: var(--papel); color: var(--cafe); border: 2px solid var(--borde); box-shadow: none; }
.boton.chico { padding: 8px 16px; min-height: 40px; font-size: .95rem; }
button.enlace { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--cafe); background: #fff;
  border: 2px solid var(--borde); border-radius: 12px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus, .boton:focus-visible { outline: 3px solid var(--lima); outline-offset: 1px; }
label { font-weight: 700; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.tarjeta {
  background: var(--papel); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 20px;
}
.mensajes { list-style: none; padding: 0; margin: 0 0 16px; }
.mensajes li { padding: 12px 16px; border-radius: 12px; background: var(--verde-claro); margin-bottom: 8px; }
.mensajes li.error { background: var(--rojo-claro); color: var(--rojo); }
.suave { color: var(--texto-suave); }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--crema-2); font-size: .85rem; font-weight: 700; }
.chip.alerta { background: var(--rojo-claro); color: var(--rojo); }

/* ------------------------------------------------ portada */
.portada { text-align: center; padding-top: 24px; }
.portada .logo { font-size: 3rem; font-weight: 900; color: var(--verde); margin: 0; letter-spacing: -1px; }
.portada .logo span { color: var(--cafe-medio); }
.portada .lema { font-size: 1.15rem; color: var(--texto-suave); margin: 4px 0 24px; }
.clave-grande {
  font-size: 2rem; text-align: center; letter-spacing: .25em; text-transform: uppercase;
  width: 100%; max-width: 320px; font-weight: 800;
}
.opciones-portada { display: grid; gap: 12px; margin-top: 24px; }
@media (min-width: 700px) { .opciones-portada { grid-template-columns: repeat(3, 1fr); } }

/* ------------------------------------------------ práctica */
.encabezado-hoja { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.encabezado-hoja .tema { font-weight: 800; font-size: 1.15rem; }
.relojes { display: flex; gap: 10px; flex-wrap: wrap; }
.reloj { background: var(--papel); border: 1px solid var(--borde); border-radius: 12px; padding: 6px 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.reloj small { display: block; font-weight: 600; font-size: .75rem; color: var(--texto-suave); }
.reloj.tarde { color: var(--cafe-medio); }
.reloj.poco { color: var(--rojo); }
.progreso { height: 10px; background: var(--crema-2); border-radius: 999px; overflow: hidden; margin: 6px 0 16px; }
.progreso > div { height: 100%; background: linear-gradient(90deg, var(--lima), var(--verde)); border-radius: 999px; }

.hoja { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .hoja.dos { grid-template-columns: 1fr 1fr; } }
.ejercicio {
  background: var(--papel); border: 2px solid var(--borde); border-radius: var(--radio);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; position: relative;
}
.ejercicio .num { position: absolute; top: 10px; left: 12px; font-size: .8rem; font-weight: 800; color: var(--texto-suave); }
.ejercicio .instruccion { display: flex; gap: 8px; align-items: flex-start; padding-left: 22px; font-weight: 700; }
.ejercicio .enunciado { font-size: 1.45rem; padding-left: 22px; overflow-x: auto; overflow-y: hidden; }
.ejercicio .dibujo { padding-left: 22px; }
.ejercicio .dibujo svg { max-width: 100%; height: auto; }
.ejercicio .responder { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 22px; font-size: 1.2rem; }
.ejercicio .responder input { font-size: 1.35rem; font-weight: 800; width: 9em; max-width: 100%; text-align: center; }
.ejercicio .responder input.ancho { width: 16em; text-align: left; }
.ejercicio .responder input.casilla { width: 5em; }
.ejercicio .responder .etiqueta { font-weight: 700; color: var(--texto-suave); }
.ejercicio .responder .etiqueta-casilla { display: flex; flex-direction: column; align-items: center; font-size: .8rem; font-weight: 700; color: var(--texto-suave); }
.ejercicio .vista-previa { padding-left: 22px; color: var(--texto-suave); font-size: 1.05rem; min-height: 1.4em; }
.ejercicio.bien { border-color: var(--lima); background: var(--verde-claro); }
.ejercicio.mal { border-color: var(--rojo); background: var(--rojo-claro); }
.ejercicio .marca { position: absolute; top: 8px; right: 12px; font-weight: 900; font-size: 1.3rem; }
.ejercicio.bien .marca { color: var(--verde); }
.ejercicio.mal .marca { color: var(--rojo); }
.opciones { display: flex; gap: 10px; flex-wrap: wrap; padding-left: 22px; }
.opciones button {
  font: inherit; font-size: 1.6rem; font-weight: 900; min-width: 72px; min-height: 64px;
  border-radius: 14px; border: 3px solid var(--borde); background: #fff; color: var(--cafe); cursor: pointer;
}
.opciones button.elegida { border-color: var(--azul); background: #E3F1F8; }
.bocina { border: 0; background: var(--crema-2); border-radius: 999px; width: 36px; height: 36px; flex: none; cursor: pointer; font-size: 1.1rem; }
.ayuda { align-self: flex-start; margin-left: 22px; }

.lienzo { position: relative; width: 100%; flex: 1 1 220px; }
.lienzo canvas {
  display: block; width: 100%; background: #fff; border: 2px solid var(--borde); border-radius: 12px;
  touch-action: none; cursor: crosshair;
}
.lienzo .borrar {
  position: absolute; top: 6px; right: 6px; border: 0; border-radius: 999px; padding: 4px 10px;
  background: var(--crema-2); color: var(--texto-suave); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.lienzo.bloqueado canvas { background: transparent; border-style: dashed; cursor: default; }
.lienzo.bloqueado .borrar { display: none; }
.ejercicio .responder .etiqueta-casilla .lienzo { min-width: 160px; }
.modo { margin-left: auto; }
.ejercicio .operacion { padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.ejercicio .operacion .lienzo { max-width: 640px !important; }
.ejercicio .operacion .lienzo canvas { background: #fffef9; border-style: dashed; }
.chip.sinproc { background: #FFF1D6; color: #8A5300; align-self: flex-start; margin-left: 22px; }
.dialogo .chip { margin: 4px 4px 12px; }
.chip.tiempo-azul { background: #E3F1F8; color: #1B6F9C; }
.chip.tiempo-verde { background: var(--verde-claro); color: #4A6309; }
.chip.tiempo-rojo { background: var(--rojo-claro); color: var(--rojo); }
.calif-excelente { color: #1B6F9C; font-weight: 800; }
.calif-a_tiempo { color: #4A6309; font-weight: 800; }
.calif-lento { color: var(--rojo); font-weight: 800; }
.pausa { position: fixed; inset: 0; z-index: 55; background: var(--crema); display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }
.pausa .grande { font-size: 4rem; margin: 0; }
body.en-pausa main > :not(.pausa):not(.velo) { visibility: hidden; }
.ejercicio .rotulo { font-size: .85rem; font-weight: 800; color: var(--texto-suave); }

.pie-hoja { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--crema) 30%); display: flex; justify-content: center; gap: 12px; margin-top: 12px; }

.tema-nuevo { border-left: 6px solid var(--azul); margin-bottom: 16px; }
.tema-nuevo .ejemplo { background: #fff; border-radius: 12px; padding: 12px 16px; margin: 12px 0; border: 1px dashed var(--borde); }
.pasos { margin: 8px 0 0; padding-left: 1.2em; }
.pasos li { margin: 4px 0; font-size: 1.1rem; }

.velo { position: fixed; inset: 0; background: rgba(62, 43, 30, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.velo[hidden] { display: none; }
.dialogo { background: var(--papel); border-radius: 22px; padding: 28px 24px; max-width: 520px; width: 100%; text-align: center; box-shadow: var(--sombra); max-height: 90vh; overflow: auto; }
.dialogo .grande { font-size: 3.5rem; margin: 0; }
.dialogo .datos { display: flex; justify-content: center; gap: 24px; margin: 16px 0; flex-wrap: wrap; }
.dialogo .datos div { font-weight: 800; font-size: 1.4rem; }
.dialogo .datos small { display: block; font-size: .8rem; color: var(--texto-suave); font-weight: 600; }
.dialogo.izquierda { text-align: left; }

/* ------------------------------------------------ pizarra del profe */
.pz-velo { position: fixed; inset: 0; background: rgba(30, 22, 15, .78); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 12px; }
.pz-caja { width: min(1100px, 100%); background: var(--papel); border-radius: 20px; padding: 12px 14px 14px; box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 10px; max-height: 96vh; }
.pz-cab { display: flex; align-items: center; gap: 12px; }
.pz-titulo { font-weight: 800; font-size: 1.1rem; flex: 1; }
.pz-cerrar { border: 0; background: var(--crema-2); border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }
.pz-marco {
  width: 100%; aspect-ratio: 16 / 9; max-height: 64vh; border-radius: 14px; overflow: hidden;
  border: 10px solid #8a5a32; box-shadow: inset 0 0 40px rgba(0,0,0,.45);
  background: radial-gradient(ellipse at 30% 20%, #3f6b52 0%, #2c4f3c 60%, #243f31 100%);
}
.pz-tablero { position: relative; width: 100%; height: 100%; font-family: "Nunito", sans-serif; }
.pz-tex, .pz-linea, .pz-lineav { position: absolute; color: var(--tiza); opacity: 0; white-space: nowrap; }
.pz-tex { line-height: 1; padding: .08em .12em; border-radius: .25em; text-shadow: 0 0 1px rgba(255,255,255,.35); }
.pz-tex .katex { font-size: 1em; }
.pz-linea { border-top: .08em solid var(--tiza); height: 0; }
.pz-lineav { border-left: .08em solid var(--tiza); width: 0; }
.pz-visible { animation: pz-escribir .55s ease-out forwards; }
.pz-visible.pz-ya { animation: none; opacity: 1; clip-path: none; }
@keyframes pz-escribir {
  from { opacity: 1; clip-path: inset(-.5em 100% -.5em -.5em); }
  to { opacity: 1; clip-path: inset(-.5em -.5em -.5em -.5em); }
}
.pz-resaltado { background: rgba(246, 226, 122, .22); box-shadow: 0 0 0 .06em #F6E27A; }
.pz-tenue { opacity: .35 !important; }
.pz-tachado::after { content: ""; position: absolute; left: -.1em; right: -.1em; top: 50%; border-top: .08em solid #F4A7B9; transform: rotate(-8deg); }
.pz-subtitulo { margin: 0; min-height: 3em; font-size: 1.05rem; font-weight: 600; text-align: center; color: var(--cafe); }
.pz-controles { display: flex; justify-content: center; align-items: center; gap: 10px; }
.pz-boton { border: 2px solid var(--borde); background: #fff; border-radius: 999px; width: 52px; height: 52px; font-size: 1.2rem; cursor: pointer; color: var(--cafe); }
.pz-boton:disabled { opacity: .4; cursor: default; }
.pz-contador { font-weight: 800; color: var(--texto-suave); min-width: 4em; text-align: center; }
.boton-profe { background: #2c4f3c; box-shadow: 0 3px 0 #1d3428; }

/* ------------------------------------------------ tablas del maestro */
table.lista { width: 100%; border-collapse: collapse; background: var(--papel); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
table.lista th, table.lista td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--borde); font-size: .95rem; }
table.lista th { background: var(--crema-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.tabla-scroll { overflow-x: auto; }
.rejilla { display: grid; gap: 16px; }
@media (min-width: 760px) { .rejilla.dos { grid-template-columns: 1fr 1fr; } .rejilla.tres { grid-template-columns: repeat(3, 1fr); } }
.calendario { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendario div { border-radius: 10px; padding: 6px 4px; text-align: center; font-size: .8rem; background: var(--crema-2); }
.calendario div.si { background: var(--lima); color: var(--cafe); font-weight: 800; }
.cifra { font-size: 2rem; font-weight: 900; }

/* ------------------------------------------------ programa */
.nivel-prog { margin-bottom: 14px; }
.nivel-prog summary { cursor: pointer; font-weight: 800; font-size: 1.1rem; }
.nivel-prog ol { margin: 10px 0 0; }
.etapa { margin: 28px 0 10px; color: var(--cafe-medio); text-transform: uppercase; letter-spacing: .08em; font-size: .9rem; }

/* ------------------------------------------------ tarjetas de claves (imprimir) */
.claves { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.clave-tarjeta { border: 2px dashed var(--cafe-medio); border-radius: 14px; padding: 14px; background: #fff; break-inside: avoid; }
.clave-tarjeta .c { font-size: 1.7rem; font-weight: 900; letter-spacing: .15em; color: var(--verde); }
@media print {
  .barra, .no-imprimir { display: none !important; }
  body { background: #fff; }
}
