:root {
  --pizarra: #1d2a24;
  --pizarra-2: #24342d;
  --marco: #6b4a2f;
  --tiza: #f1eee4;
  --tiza-2: #c9c6bb;
  --tiza-3: #8e968f;
  --amarillo: #f3d36b;
  --rojo: #ff9b8f;
  --verde: #a6e3a1;
  --azul: #9fd3ef;
  --linea: rgba(241, 238, 228, .14);
  --hoja: #f7f5ef;
  --hoja-texto: #1f2421;
  --hoja-suave: #6c716d;
  --hoja-borde: #e2ded3;
  --acento: #2f6b4f;
  --mano: 'Kalam', 'Comic Sans MS', cursive;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-alto: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.05), transparent 55%),
    radial-gradient(ellipse at 90% 80%, rgba(255,255,255,.035), transparent 50%),
    var(--pizarra);
  color: var(--tiza);
  font-family: var(--ui);
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

#app {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--nav-alto) + env(safe-area-inset-bottom) + 90px);
}

/* ---------- navegación ---------- */
#nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(20, 30, 25, .94); backdrop-filter: blur(10px);
  border-top: 3px solid var(--marco);
}
#nav a {
  flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 12px; font-size: 12px; color: var(--tiza-3);
}
#nav a span { font-size: 20px; line-height: 1; }
#nav a.activo { color: var(--tiza); background: rgba(255,255,255,.06); }

/* ---------- cabecera ---------- */
.cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.fecha { font-family: var(--mano); font-size: 17px; color: var(--tiza-2); }
.titulo { font-family: var(--mano); font-weight: 700; font-size: 34px; line-height: 1.05; margin: 2px 0 8px; }
.subrayado { height: 3px; width: 120px; border-radius: 3px; background: var(--tiza); opacity: .55; margin-bottom: 14px; transform: rotate(-.6deg); }
.nota-entrenador {
  font-family: var(--mano); color: var(--amarillo); font-size: 18px; line-height: 1.3;
  margin: 0 0 16px; white-space: pre-wrap;
}
.etiqueta {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 99px; border: 1px solid var(--linea); color: var(--tiza-2);
}
.etiqueta.hecha { color: var(--verde); border-color: rgba(166,227,161,.4); }
.etiqueta.curso { color: var(--amarillo); border-color: rgba(243,211,107,.4); }
.volver { font-size: 15px; color: var(--tiza-2); display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; }

/* ---------- líneas de la pizarra ---------- */
.lineas { list-style: none; margin: 0; padding: 0; }
.linea { position: relative; padding: 14px 0 14px 34px; border-bottom: 1px dashed var(--linea); }
.linea .num {
  position: absolute; left: 0; top: 14px; font-family: var(--mano); font-size: 22px; color: var(--tiza-3); width: 26px;
}
.linea .fila { display: flex; align-items: flex-start; gap: 8px; }
.linea .nombre {
  flex: 1; text-align: left; font-family: var(--mano); font-size: 23px; line-height: 1.15; font-weight: 700;
}
.linea .nombre .fl { color: var(--tiza-3); font-weight: 400; }
.linea .menu { width: 36px; height: 32px; border-radius: 10px; color: var(--tiza-2); font-size: 20px; flex: none; }
.linea .menu:active { background: rgba(255,255,255,.08); }
.tachado { text-decoration: line-through; text-decoration-color: var(--rojo); text-decoration-thickness: 2px; color: var(--tiza-3); }
.antes { font-family: var(--mano); font-size: 15px; color: var(--rojo); margin-top: 2px; }
.antes .tachado { color: var(--rojo); opacity: .8; }
.plan {
  display: inline-flex; align-items: baseline; gap: 6px; margin-top: 4px;
  font-family: var(--mano); font-size: 22px; color: var(--tiza); padding: 2px 8px 0; margin-left: -8px; border-radius: 10px;
}
.plan:active { background: rgba(255,255,255,.08); }
.plan .x { color: var(--tiza-3); font-size: 18px; }
.plan .kg { color: var(--azul); }
.plan.cambiado { color: var(--azul); }
.nota-linea { font-family: var(--mano); color: var(--amarillo); font-size: 16px; margin-top: 2px; line-height: 1.25; }
.motivo { font-family: var(--mano); color: var(--rojo); font-size: 15px; }
.series { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.serie {
  min-width: 52px; height: 44px; padding: 0 10px; border-radius: 22px;
  border: 2px dashed rgba(241,238,228,.45); color: var(--tiza-2);
  font-family: var(--mano); font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
}
.serie small { font-size: 13px; color: var(--tiza-3); }
.serie.hecha { border: 2px solid var(--verde); background: rgba(166,227,161,.14); color: var(--verde); }
.serie.hecha small { color: var(--verde); opacity: .8; }
.serie.mas { min-width: 44px; border-style: dotted; color: var(--tiza-3); }
.linea.saltado .nombre, .linea.saltado .plan { opacity: .45; text-decoration: line-through; }
.linea.hecho .num { color: var(--verde); }

.acciones { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.boton {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border-radius: 14px; padding: 0 18px; font-weight: 600; font-size: 16px;
}
.boton.tiza { border: 2px dashed rgba(241,238,228,.5); color: var(--tiza); font-family: var(--mano); font-size: 20px; font-weight: 700; }
.boton.lleno { background: var(--tiza); color: var(--pizarra); }
.boton.suave { background: rgba(255,255,255,.07); color: var(--tiza); }

.vacio { text-align: center; padding: 40px 10px 10px; }
.vacio .grande { font-family: var(--mano); font-size: 30px; font-weight: 700; margin: 0 0 8px; }
.vacio p { color: var(--tiza-2); line-height: 1.5; margin: 0 0 6px; }
.tarjeta {
  display: block; text-align: left; width: 100%; border: 1px solid var(--linea); border-radius: 14px;
  padding: 12px 14px; margin-top: 12px; background: rgba(255,255,255,.03);
}
.tarjeta .t { font-family: var(--mano); font-size: 20px; font-weight: 700; }
.tarjeta .s { color: var(--tiza-2); font-size: 13px; margin-top: 2px; line-height: 1.4; }

/* ---------- historial ---------- */
.mes { font-family: var(--mano); color: var(--tiza-3); font-size: 18px; margin: 18px 0 4px; }
.sesion-fila { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--linea); width: 100%; text-align: left; }
.sesion-fila .dia { width: 44px; text-align: center; font-family: var(--mano); flex: none; }
.sesion-fila .dia b { display: block; font-size: 24px; line-height: 1; }
.sesion-fila .dia span { font-size: 13px; color: var(--tiza-3); }
.sesion-fila .q { flex: 1; min-width: 0; }
.sesion-fila .q .t { font-family: var(--mano); font-size: 19px; font-weight: 700; }
.sesion-fila .q .s { font-size: 13px; color: var(--tiza-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- ficha (página de papel) ---------- */
.ficha { background: var(--hoja); color: var(--hoja-texto); border-radius: 20px; padding: 18px 16px 20px; margin: 0 -4px; }
.ficha .volver { color: var(--hoja-suave); }
.ficha h1 { font-family: var(--mano); font-size: 30px; line-height: 1.1; margin: 0; }
.ficha .otro { color: var(--hoja-suave); font-size: 14px; margin-top: 4px; }
.ficha .gif { margin: 14px 0; border-radius: 16px; overflow: hidden; background: #fff; border: 1px solid var(--hoja-borde); }
.ficha .gif img { display: block; width: 100%; max-height: 360px; object-fit: contain; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: #ebe7dc; color: var(--hoja-texto); }
.chip.fuerte { background: var(--acento); color: #fff; }
.ficha h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--hoja-suave); margin: 22px 0 8px; }
.ficha ol { margin: 0; padding-left: 22px; line-height: 1.55; }
.ficha ol li { margin-bottom: 6px; }
.consejo { background: #fff6d6; border: 1px solid #efdf9f; border-radius: 14px; padding: 12px 14px; line-height: 1.5; white-space: pre-wrap; }
.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cifra { background: #fff; border: 1px solid var(--hoja-borde); border-radius: 14px; padding: 10px; }
.cifra b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.cifra span { font-size: 12px; color: var(--hoja-suave); }
.grafica { margin-top: 10px; background: #fff; border: 1px solid var(--hoja-borde); border-radius: 14px; padding: 10px; }
.grafica svg { display: block; width: 100%; height: 110px; }
.hist-fila { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hoja-borde); font-size: 14px; }
.hist-fila .f { width: 74px; flex: none; color: var(--hoja-suave); }
.hist-fila .v { font-variant-numeric: tabular-nums; }
.suave { color: var(--hoja-suave); }

/* ---------- hoja inferior ---------- */
#velo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
#hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 88dvh; overflow: auto;
  background: var(--hoja); color: var(--hoja-texto); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; animation: sube .18s ease-out;
}
@keyframes sube { from { transform: translateY(30px); opacity: .6 } to { transform: none; opacity: 1 } }
#hoja .asa { width: 40px; height: 5px; border-radius: 3px; background: #d6d1c4; margin: 0 auto 12px; }
#hoja h3 { margin: 0 0 4px; font-size: 19px; }
#hoja .sub { color: var(--hoja-suave); font-size: 14px; margin: 0 0 14px; }
#hoja .opcion { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; border-bottom: 1px solid var(--hoja-borde); text-align: left; font-size: 16px; }
#hoja .opcion:last-child { border-bottom: 0; }
#hoja .opcion .ic { width: 28px; text-align: center; font-size: 18px; }
#hoja .opcion.peligro { color: #b3261e; }
.pasos { display: grid; gap: 12px; margin: 6px 0 16px; }
.paso { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.paso label { font-weight: 600; }
.paso .ctrl { display: flex; align-items: center; gap: 8px; }
.paso .ctrl button { width: 44px; height: 44px; border-radius: 12px; background: #ebe7dc; font-size: 22px; font-weight: 600; }
.paso .ctrl input { width: 84px; height: 44px; text-align: center; border: 1px solid var(--hoja-borde); border-radius: 12px; font-size: 18px; background: #fff; color: var(--hoja-texto); }
.campo { width: 100%; border: 1px solid var(--hoja-borde); border-radius: 12px; padding: 12px; font-size: 16px; background: #fff; color: var(--hoja-texto); }
textarea.campo { min-height: 80px; resize: vertical; }
.fila-botones { display: flex; gap: 10px; margin-top: 8px; }
.fila-botones .boton { flex: 1; }
#hoja .boton.lleno { background: var(--acento); color: #fff; }
#hoja .boton.suave { background: #ebe7dc; color: var(--hoja-texto); }
.motivos { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.motivos button { padding: 8px 12px; border-radius: 99px; border: 1px solid var(--hoja-borde); background: #fff; font-size: 14px; }
.motivos button.sel { background: var(--acento); color: #fff; border-color: var(--acento); }
.resultado { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 0; border-bottom: 1px solid var(--hoja-borde); text-align: left; }
.resultado img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #fff; border: 1px solid var(--hoja-borde); flex: none; }
.resultado .q { flex: 1; min-width: 0; }
.resultado .q b { display: block; font-weight: 600; font-size: 15px; }
.resultado .q span { font-size: 12px; color: var(--hoja-suave); }
.resultado .ya { font-size: 11px; background: #dcefe3; color: var(--acento); padding: 2px 7px; border-radius: 99px; flex: none; }
.titulo-seccion { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--hoja-suave); margin: 14px 0 2px; }

/* ---------- descanso y aviso ---------- */
#descanso {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-alto) + env(safe-area-inset-bottom) + 12px); z-index: 30;
  max-width: 616px; margin: 0 auto; background: var(--tiza); color: var(--pizarra);
  border-radius: 16px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
#descanso .t { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 600; min-width: 64px; }
#descanso .barra { flex: 1; height: 6px; background: rgba(0,0,0,.12); border-radius: 3px; overflow: hidden; }
#descanso .barra i { display: block; height: 100%; background: var(--acento); }
#descanso button { font-weight: 600; font-size: 14px; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.08); }
#aviso {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translateX(-50%); z-index: 60;
  background: var(--tiza); color: var(--pizarra); padding: 10px 16px; border-radius: 12px; font-weight: 500; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: calc(100% - 32px);
}

/* ---------- entrar ---------- */
.entrar { max-width: 360px; margin: 14vh auto 0; text-align: center; }
.entrar h1 { font-family: var(--mano); font-size: 44px; margin: 0 0 6px; }
.entrar p { color: var(--tiza-2); margin: 0 0 22px; }
.entrar input { width: 100%; height: 52px; border-radius: 14px; border: 2px dashed rgba(241,238,228,.4); background: transparent; color: var(--tiza); padding: 0 16px; font-size: 18px; text-align: center; margin-bottom: 12px; }
.entrar .boton { width: 100%; }
.error { color: var(--rojo); margin-top: 10px; min-height: 20px; }

.cargando { text-align: center; color: var(--tiza-3); font-family: var(--mano); font-size: 22px; padding-top: 30vh; }

/* ---------- petición al entrenador ---------- */
.pedido { border: 2px dashed rgba(243,211,107,.45); border-radius: 16px; padding: 12px 14px; margin: 0 0 16px; }
.pedido .s { font-size: 13px; color: var(--tiza-2); line-height: 1.4; }
.pedido .r { font-family: var(--mano); color: var(--amarillo); font-size: 19px; line-height: 1.3; margin-top: 4px; white-space: pre-wrap; }
.pedido.error { border-color: rgba(255,155,143,.5); }
.pedido.error .r { color: var(--rojo); }
.escribiendo { font-family: var(--mano); font-size: 22px; color: var(--amarillo); margin-bottom: 2px; }
.escribiendo span { animation: punto 1.2s infinite; opacity: .2; }
.escribiendo span:nth-child(2) { animation-delay: .2s; }
.escribiendo span:nth-child(3) { animation-delay: .4s; }
@keyframes punto { 40% { opacity: 1 } }
.vacio + .acciones { margin-top: 6px; }

#hoja .opcion.guardado .q { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#hoja .opcion.guardado b { font-size: 16px; }
#hoja .opcion.guardado span { font-size: 13px; color: var(--hoja-suave); }
#hoja .hist-fila .f { width: 70px; }
.fila-botones + .fila-botones { margin-top: 10px; }
.cab .etiqueta { background: none; cursor: pointer; }
