/* estilos.css — Modo oscuro con los colores de los discos olímpicos:
   amarillo (acción principal), rojo (molestia / peligro), azul, verde y blanco
   para las actividades. Todo lo que cambia de color está en :root. */

:root {
  --fondo: #161B24;
  --superficie: #1F2632;
  --superficie-2: #29323F;
  --borde: #364152;
  --texto: #EDF0F5;
  --texto-2: #A3AEBF;

  --amarillo: #F2C14E;   /* disco de 15 kg: acción principal y gimnasio */
  --sobre-amarillo: #1E1702;
  --rojo: #EF6A5F;       /* disco de 25 kg: molestia fuerte y borrar */
  --azul: #5B9BFF;       /* disco de 20 kg */
  --verde: #4CC38A;      /* disco de 10 kg */
  --blanco: #E8E3D6;     /* disco de 5 kg */
  --morado: #B58CF5;

  --radio: 14px;
  --radio-grande: 22px;
  --toque: 48px;         /* tamaño mínimo cómodo para tocar */

  --letra: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --letra-numeros: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--letra);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 0.95rem; color: var(--texto-2); font-weight: 600; margin: 1.2rem 0 0.4rem; }
h4 { font-size: 0.85rem; color: var(--texto-2); font-weight: 600; margin: 1rem 0 0.3rem; }

p { margin: 0.3rem 0; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Estructura ---------- */

.principal {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 160px);
}

.cabecera { margin-bottom: 1rem; }
.subtitulo { color: var(--texto-2); }
.volver {
  display: inline-flex; align-items: center; min-height: 40px;
  color: var(--amarillo); text-decoration: none; font-weight: 600;
}
.volver::before { content: "‹"; font-size: 1.6rem; margin-right: 6px; line-height: 1; }

.vacio { color: var(--texto-2); padding: 2rem 0; }
.ayuda { color: var(--texto-2); font-size: 0.9rem; }

/* ---------- Barra inferior ---------- */

.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(22, 27, 36, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--borde);
}
.pestanas a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: var(--toque); padding-top: 4px;
  color: var(--texto-2); text-decoration: none; font-size: 0.72rem; font-weight: 600;
}
.pestanas svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.pestanas a[aria-current] { color: var(--amarillo); }

/* ---------- Botones ---------- */

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--toque); padding: 0 18px;
  border: 1px solid var(--borde); border-radius: var(--radio);
  background: var(--superficie-2); color: var(--texto);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.boton:active { transform: scale(0.98); }
.boton:disabled { opacity: 0.4; }
.boton.primario { background: var(--amarillo); color: var(--sobre-amarillo); border-color: var(--amarillo); }
.boton.peligro { color: var(--rojo); }
.boton.bloque { display: flex; width: 100%; margin-top: 10px; }
.boton.pequeno { min-height: 40px; padding: 0 12px; font-size: 0.9rem; border-radius: 11px; }
.boton.icono { min-width: 40px; padding: 0 10px; }
.boton.grande { min-height: 56px; font-size: 1.1rem; flex: 1; }

.boton-texto {
  display: block; margin: 1.5rem auto 0; min-height: var(--toque); padding: 0 12px;
  background: none; border: 0; color: var(--texto-2); font: inherit; text-decoration: underline;
}
.boton-texto.peligro { color: var(--rojo); }

.fila-botones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.fila-botones .boton { flex: 1; }

.chip {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--borde); border-radius: 999px;
  background: transparent; color: var(--texto-2); font: inherit; font-size: 0.9rem; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--texto); color: var(--fondo); border-color: var(--texto); }
.molestia .molestia-0[aria-pressed="true"] { background: var(--superficie-2); color: var(--texto); border-color: var(--texto-2); }

.etiqueta {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  background: var(--superficie-2); color: var(--texto-2); font-size: 0.75rem; font-weight: 600;
  vertical-align: middle;
}

/* ---------- Formularios ---------- */

input, select, textarea {
  width: 100%; min-height: var(--toque); padding: 10px 12px;
  border: 1px solid var(--borde); border-radius: 12px;
  background: var(--fondo); color: var(--texto);
  font: inherit; font-size: 17px; /* 16 px o más: así iOS no hace zoom */
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--amarillo); }

label { display: block; font-size: 0.9rem; color: var(--texto-2); }
label > input, label > select, label > textarea { margin-top: 4px; }

.formulario label, .formulario fieldset { margin-top: 12px; }
.formulario h2 { margin-top: 0; }

fieldset { border: 1px solid var(--borde); border-radius: var(--radio); padding: 8px 12px 12px; margin: 0; }
legend { padding: 0 6px; color: var(--texto-2); font-size: 0.9rem; }

.fila-campos { display: flex; gap: 10px; }
.fila-campos > label { flex: 1; min-width: 0; }
.fila-campos > .estrecho { flex: 0 0 90px; }

.casilla { display: flex; align-items: center; gap: 10px; min-height: var(--toque); color: var(--texto); font-size: 1rem; }
.casilla input { margin: 0; flex: none; }

.boton-archivo { position: relative; color: var(--texto); }
.boton-archivo input { position: absolute; inset: 0; opacity: 0; min-height: 0; }

/* ---------- Hoja inferior ---------- */

.hoja {
  width: 100%; max-width: 640px; max-height: 88vh;
  margin: auto auto 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  border: 0; border-radius: var(--radio-grande) var(--radio-grande) 0 0;
  background: var(--superficie); color: var(--texto);
  overflow-y: auto;
}
.hoja::backdrop { background: rgba(5, 8, 12, 0.65); }
.hoja h2 { margin: 0 0 8px; font-size: 1.3rem; }
.botones-hoja { display: flex; gap: 10px; margin-top: 20px; }
.botones-hoja .boton { flex: 1; }
.menu .boton.bloque { justify-content: flex-start; }

/* ---------- Aviso ---------- */

.aviso {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px;
  background: var(--texto); color: var(--fondo); font-weight: 600; white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Inicio ---------- */

.banda-aviso {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 12px 14px; margin-bottom: 12px; border-radius: var(--radio);
  border: 1px solid var(--amarillo); color: var(--amarillo);
}

.en-curso {
  display: grid; gap: 2px; padding: 16px; margin-bottom: 8px;
  border-radius: var(--radio-grande);
  background: var(--amarillo); color: var(--sobre-amarillo); text-decoration: none;
}
.en-curso-etiqueta { font-size: 0.85rem; font-weight: 600; opacity: 0.8; }
.en-curso-nombre { font-size: 1.3rem; font-weight: 800; }
.en-curso-ir { font-weight: 700; text-decoration: underline; }

.fila-titulo { display: flex; align-items: baseline; justify-content: space-between; }
.contador { color: var(--texto-2); }
.contador strong { font-family: var(--letra-numeros); font-size: 1.4rem; color: var(--texto); }
.contador.cumplido strong { color: var(--amarillo); }

.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; list-style: none; padding: 0; margin: 0; }
.dia-semana {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; border-radius: 12px; background: var(--superficie);
}
.dia-semana .letra { font-size: 0.75rem; color: var(--texto-2); font-weight: 600; }
.dia-semana .numero { font-family: var(--letra-numeros); font-weight: 700; }
.dia-semana.hoy { outline: 2px solid var(--texto-2); }
.dia-semana.con-gimnasio { background: var(--amarillo); color: var(--sobre-amarillo); }
.dia-semana.con-gimnasio .letra { color: var(--sobre-amarillo); }

.marcas { display: flex; gap: 3px; min-height: 8px; }
.marcas i, .leyenda i, .fila-dia i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.m-gimnasio { background: var(--amarillo); }
.con-gimnasio .m-gimnasio { background: var(--sobre-amarillo); }
.act-escalada { background: var(--azul); }
.act-senderismo { background: var(--verde); }
.act-padel { background: var(--blanco); }
.act-kickboxing { background: var(--rojo); }
.act-otra { background: var(--morado); }

.plantillas { display: grid; gap: 8px; }
.plantilla {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 64px; padding: 0 16px;
  border: 1px solid var(--borde); border-radius: var(--radio);
  background: var(--superficie); color: var(--texto); font: inherit; text-align: left;
}
.plantilla-nombre { font-weight: 700; font-size: 1.05rem; }
.plantilla-hace { color: var(--texto-2); font-size: 0.9rem; white-space: nowrap; }
.plantilla-hace.atrasada { color: var(--amarillo); }

/* ---------- Entreno ---------- */

.cabecera-entreno { margin-bottom: 8px; }
.cabecera-entreno h1 { font-size: 1.7rem; }
.cabecera-datos { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--texto-2); font-size: 0.9rem; }
.fecha-entreno input { width: auto; min-height: 40px; padding: 4px 10px; }

.ejercicio {
  margin-top: 14px; padding: 16px;
  border-radius: var(--radio-grande); background: var(--superficie);
}
.ejercicio.es-calentamiento { background: transparent; border: 1px dashed var(--borde); }
.ej-cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ej-titulo { min-width: 0; }
.ej-hueco { color: var(--texto-2); font-size: 0.85rem; font-weight: 600; margin: 0; }
.ej-nombre { margin: 2px 0 0; font-size: 1.15rem; }
.ej-nombre a { text-decoration: none; }
.ej-botones { display: flex; gap: 6px; flex: none; }

.ultimo { color: var(--texto-2); font-size: 0.92rem; margin-top: 10px; font-family: var(--letra-numeros); }
.ultimo span { font-family: var(--letra); }
.objetivo { color: var(--texto-2); font-size: 0.85rem; }
.aviso-paron { color: var(--amarillo); font-size: 0.9rem; }

.series { margin-top: 8px; }
.serie-hecha { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--borde); }
.serie-texto {
  flex: 1; display: flex; align-items: center; gap: 12px; min-height: 52px;
  background: none; border: 0; color: var(--texto); font: inherit; text-align: left; padding: 0;
}
.serie-valor { font-family: var(--letra-numeros); font-size: 1.25rem; font-weight: 700; }
.serie-n {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--superficie-2); color: var(--texto-2);
  font-family: var(--letra-numeros); font-size: 0.85rem; font-weight: 700;
}
.serie-hecha .serie-n { background: var(--amarillo); color: var(--sobre-amarillo); }
.serie-pendiente { display: flex; align-items: center; gap: 12px; color: var(--texto-2); opacity: 0.6; min-height: 40px; margin: 0; }

.serie-activa { margin-top: 10px; padding: 12px; border-radius: var(--radio); background: var(--superficie-2); }
.serie-activa-titulo { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-weight: 700; }
.pasos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.paso { display: flex; align-items: stretch; border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; background: var(--fondo); }
.paso-boton {
  flex: none; width: 46px; border: 0; background: transparent; color: var(--texto);
  font-size: 1.6rem; font-weight: 500;
}
.paso-boton:active { background: var(--superficie); }
.paso-valor { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 0; }
.paso-valor input {
  width: 100%; min-height: 40px; margin: 0; padding: 0;
  border: 0; background: transparent; text-align: center;
  font-family: var(--letra-numeros); font-size: 1.6rem; font-weight: 800;
}
.paso-valor span { font-size: 0.72rem; color: var(--texto-2); margin-top: -2px; }
.serie-activa-botones { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.anadir-serie { margin-top: 10px; }

.molestia { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; color: var(--texto-2); font-size: 0.9rem; }
.molestia span { margin-right: 4px; }
.molestia .chip { min-height: 36px; padding: 0 12px; }
.molestia .molestia-1[aria-pressed="true"] { background: var(--amarillo); border-color: var(--amarillo); color: var(--sobre-amarillo); }
.molestia .molestia-2[aria-pressed="true"] { background: var(--rojo); border-color: var(--rojo); color: #210604; }
.etiqueta.molestia-1 { color: var(--amarillo); }
.etiqueta.molestia-2 { color: var(--rojo); }

/* Calentamiento: cada serie es un disco que se toca al terminarla */
.calentamiento p { color: var(--texto-2); font-size: 0.9rem; margin-top: 8px; }
.discos { display: flex; gap: 12px; margin-top: 10px; }
.disco {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid var(--borde); background: transparent; color: var(--texto-2);
  font-family: var(--letra-numeros); font-size: 1.2rem; font-weight: 800;
}
.disco.hecho { border-color: var(--amarillo); background: var(--amarillo); color: var(--sobre-amarillo); }

.nota-sesion { margin-top: 20px; }
.pie-entreno { margin-top: 16px; }
.terminado { color: var(--texto-2); }

/* Cronómetro de descanso */
.descanso {
  position: fixed; left: 16px; right: 16px; z-index: 11;
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  max-width: 608px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(242, 193, 78, 0.28) calc(var(--progreso, 0) * 100%), transparent 0) ,
    var(--superficie-2);
  border: 1px solid var(--borde);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.descanso[hidden] { display: none; }
.descanso-texto { color: var(--texto-2); font-weight: 600; }
.descanso-tiempo { font-family: var(--letra-numeros); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.descanso.listo { background: var(--amarillo); border-color: var(--amarillo); }
.descanso.listo .descanso-texto, .descanso.listo .descanso-tiempo { color: var(--sobre-amarillo); }

/* Selector de máquina */
.opcion-maquina, .fila-dia {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 8px 12px; margin-top: 6px;
  border: 1px solid var(--borde); border-radius: var(--radio);
  background: var(--fondo); color: var(--texto); font: inherit; text-align: left; text-decoration: none;
}
.opcion-maquina.actual { border-color: var(--amarillo); }
.opcion-detalle { color: var(--texto-2); font-size: 0.85rem; font-family: var(--letra-numeros); white-space: nowrap; }
.selector details { margin-top: 14px; }
.selector summary { min-height: var(--toque); display: flex; align-items: center; color: var(--amarillo); font-weight: 600; }

/* ---------- Calendario ---------- */

.cabecera-mes { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cabecera-mes h1 { font-size: 1.7rem; text-align: center; }
.cabecera-mes .anyo { color: var(--texto-2); font-weight: 600; }
.cabecera-mes .boton { font-size: 1.5rem; }

.calendario { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.calendario th { color: var(--texto-2); font-size: 0.75rem; font-weight: 600; padding-bottom: 4px; }
.calendario th:last-child, .calendario td:last-child { width: 40px; }
.calendario td { padding: 0; }
.dia {
  width: 100%; aspect-ratio: 1 / 1.15; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-radius: 10px; background: var(--superficie); color: var(--texto); font: inherit;
}
.dia .numero { font-family: var(--letra-numeros); font-weight: 700; font-size: 0.95rem; }
.dia.fuera { opacity: 0.3; }
.dia.hoy { outline: 2px solid var(--texto-2); }
.dia.con-gimnasio { background: var(--amarillo); color: var(--sobre-amarillo); }
.total-semana { text-align: center; font-family: var(--letra-numeros); font-size: 0.8rem; color: var(--texto-2); }
.total-semana.cumplido { color: var(--amarillo); font-weight: 800; }

.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 14px 0; font-size: 0.85rem; color: var(--texto-2); }
.leyenda li { display: flex; align-items: center; gap: 6px; }
.resumen-mes strong { font-family: var(--letra-numeros); font-size: 1.3rem; }

/* ---------- Máquinas y plantillas ---------- */

.segmentos { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radio); background: var(--superficie); margin-bottom: 12px; }
.segmentos a { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 10px; text-decoration: none; color: var(--texto-2); font-weight: 600; }
.segmentos a[aria-current] { background: var(--superficie-2); color: var(--texto); }

.barra-busqueda { display: flex; gap: 8px; }
.barra-busqueda input { flex: 1; }

.grupo-maquinas h2 { font-size: 0.95rem; color: var(--texto-2); margin-top: 1.2rem; }
.fila-maquina {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 58px; padding: 8px 2px; border-bottom: 1px solid var(--borde); text-decoration: none;
}
.fila-maquina[hidden], .grupo-maquinas[hidden] { display: none; }
.fila-maquina-nombre { font-weight: 600; }
.fila-maquina .opcion-detalle { white-space: normal; }
.fila-maquina.archivada { opacity: 0.6; }
.ver-archivadas { margin-top: 16px; }

.musculos { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; }
.musculos li { padding: 4px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.musculo-principal { background: var(--amarillo); color: var(--sobre-amarillo); }
.musculo-secundario { border: 1px solid var(--borde); color: var(--texto-2); }
.datos-maquina { padding-left: 18px; color: var(--texto-2); margin: 0 0 8px; }
.nota-maquina { padding: 10px 12px; border-left: 3px solid var(--amarillo); background: var(--superficie); border-radius: 0 10px 10px 0; margin-bottom: 12px; }

.historial { list-style: none; padding: 0; margin: 0; }
.historial-fila a { display: grid; grid-template-columns: 64px 1fr; gap: 2px 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--borde); text-decoration: none; }
.historial-fecha { color: var(--texto-2); font-size: 0.9rem; }
.historial-series { font-family: var(--letra-numeros); font-weight: 600; }
.historial-fila .etiqueta { grid-column: 2; justify-self: start; }

.lista-plantillas { margin-bottom: 12px; }
.hueco { margin-top: 12px; padding: 14px; border-radius: var(--radio); background: var(--superficie); }
.hueco > label { margin-top: 10px; }
.alternativas { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 0.9rem; }
.alternativas span { color: var(--texto-2); }
.casillas { display: flex; gap: 18px; }
.titulo-editable input { font-size: 1.3rem; font-weight: 800; border-color: transparent; background: transparent; padding-left: 0; }
.titulo-editable input:focus { border-color: var(--borde); padding-left: 10px; }
.grupo-casillas { margin-top: 12px; }
.grupo-casillas .casilla { min-height: 44px; margin-top: 0; }

/* ---------- Ajustes ---------- */

.estado-copia { font-weight: 600; margin: 10px 0 4px; }
