/* Mobile-first de verdad: el objetivo es 380px, una mano, sin lentes.
   Nada acá baja de 46px de alto tocable ni de 17px de tipografía en inputs
   (por debajo de 17px iOS hace zoom al enfocar y te saca de la pantalla). */

:root {
  --bg: #0c0e12;
  --card: #161a20;
  --card-2: #1d222a;
  --line: #272d37;
  --fg: #f0f3f7;
  --muted: #8a94a4;
  --ok: #2fbf71;
  --ok-dim: #17331f;
  --accent: #4d8dff;
  --warn: #f0a12e;
  --warn-dim: #33270f;
  --radio: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 96px;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; }
.oculto { display: none !important; }

/* ------------------------------------------------------------ barra fija */

header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(12, 14, 18, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}
.barra { display: flex; align-items: center; gap: 10px; }
.barra h1 { font-size: 17px; margin: 0; flex: 1; line-height: 1.2; }
.barra h1 small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.chip {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--muted);
  min-height: 44px;
}
.chip.activo { color: var(--fg); border-color: var(--accent); }

/* ------------------------------------------------------------ ejercicios */

main { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.ejercicio {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); overflow: hidden;
}
.ejercicio.completo { opacity: .55; }
.ejercicio.abierto { border-color: #3a4353; }

.ej-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; width: 100%; text-align: left; min-height: 62px;
}
.ej-nombre { flex: 1; font-size: 17px; font-weight: 600; line-height: 1.25; }
.ej-presc { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 3px; }
.ej-contador {
  font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted);
  background: var(--card-2); border-radius: 999px; padding: 5px 10px;
}
.ej-contador.listo { color: var(--ok); background: var(--ok-dim); }

.aviso-gym {
  margin: 0 14px 12px; padding: 9px 11px; border-radius: 9px;
  background: var(--warn-dim); color: var(--warn); font-size: 13px;
  border: 1px solid rgba(240, 161, 46, .28);
}

.ej-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }

/* ----------------------------------------------------------------- serie */

.serie { background: var(--card-2); border-radius: var(--radio); padding: 12px; }

.serie-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 13px; color: var(--muted);
}
.serie-n { font-weight: 600; color: var(--fg); }
.serie-prev { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }
/* Chip visualmente chico, pero con 44px reales para el dedo. */
.ec {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0 12px; font-size: 11px; letter-spacing: .04em; min-height: 44px;
}
.ec.on { background: var(--warn-dim); color: var(--warn); border-color: var(--warn); }

.steppers { display: flex; gap: 10px; }
.stepper { flex: 1; }
.stepper > label {
  display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px;
}
.stepper-row {
  display: flex; align-items: stretch;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.step {
  width: 46px; font-size: 24px; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.step:active { background: var(--line); color: var(--fg); }
.num {
  flex: 1; min-width: 0; width: 100%;
  background: transparent; border: none; color: var(--fg);
  font-size: 23px; font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums; padding: 12px 0;
  -moz-appearance: textfield;
}
.num::-webkit-outer-spin-button, .num::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.num:focus { outline: none; background: rgba(77, 141, 255, .1); }

/* Tres botones grandes, no un campo de texto. */
.rir-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.rir-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; width: 30px;
}
.rir {
  flex: 1; min-height: 50px; font-size: 20px; font-weight: 600;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted);
}
/* Heredado de la sesión anterior: confirmable de un toque, pero se nota. */
.rir.heredado { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.rir.activo {
  background: var(--accent); border-color: var(--accent); color: #fff; border-style: solid;
}
.rir-mas { width: 40px; min-height: 50px; color: var(--muted); font-size: 18px; }
.rir-extra { display: flex; gap: 8px; margin-top: 8px; padding-left: 38px; }
.rir-extra .rir { flex: 0 0 60px; }

.confirmar {
  width: 100%; min-height: 54px; margin-top: 12px;
  background: var(--ok); color: #04140a; border-radius: 10px;
  font-size: 17px; font-weight: 700;
}
.confirmar:active { filter: brightness(.9); }
.confirmar[disabled] { opacity: .4; }

/* Serie ya guardada: se colapsa y deja de ocupar pantalla. */
.hecha {
  display: flex; align-items: center; gap: 10px;
  background: var(--ok-dim); border-radius: 10px; padding: 13px 12px;
  font-size: 15px; min-height: 50px;
}
.hecha .tick { color: var(--ok); font-weight: 700; }
.hecha .datos { flex: 1; font-variant-numeric: tabular-nums; }
.hecha .corregir { color: var(--muted); font-size: 17px; padding: 6px 10px; }

.agregar {
  border: 1px dashed var(--line); border-radius: 10px;
  min-height: 46px; color: var(--muted); font-size: 14px;
}

/* ----------------------------------------------------------------- login */

.centro {
  min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 24px; gap: 14px;
}
.centro h2 { margin: 0 0 6px; font-size: 22px; }
.perfil {
  width: 100%; min-height: 62px; font-size: 19px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radio);
}
.perfil.sel { border-color: var(--accent); background: var(--card-2); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button {
  min-height: 62px; font-size: 24px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radio);
}
.pin-vista {
  text-align: center; font-size: 30px; letter-spacing: .35em;
  min-height: 44px; color: var(--accent);
}

/* ------------------------------------------------------------------ pie */

.pie {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  display: flex; gap: 10px;
}
.pie button {
  flex: 1; min-height: 50px; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line);
}

.aviso {
  position: fixed; left: 14px; right: 14px; bottom: 76px; z-index: 20;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.5);
}
.aviso.error { border-color: #b3453f; color: #ffb3ae; }

dialog {
  background: var(--card); color: var(--fg); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 18px; width: min(340px, calc(100vw - 28px));
}
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h3 { margin: 0 0 12px; font-size: 17px; }
dialog .fila { display: flex; gap: 10px; margin-top: 14px; }
dialog .fila button { flex: 1; min-height: 48px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
dialog textarea, dialog input[type=text] {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; color: var(--fg); font-size: 17px; padding: 12px;
  font-family: inherit;
}
.hist { font-size: 14px; max-height: 52vh; overflow-y: auto; }
.hist .dia { border-top: 1px solid var(--line); padding: 9px 0; }
.hist .dia:first-child { border-top: none; }
.hist .fecha { color: var(--muted); font-size: 12px; }
.hist .sets { font-variant-numeric: tabular-nums; }
.vacio { color: var(--muted); text-align: center; padding: 40px 20px; font-size: 15px; }

/* Notas de la prescripción: el "arranque S1: 79 kg" y las claves de ejecución.
   Sin esto la primera sesión del módulo se registra a ciegas. */
.ej-notas {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 9px;
  background: rgba(77, 141, 255, .09); border: 1px solid rgba(77, 141, 255, .25);
  color: #bcd3ff; font-size: 13px; line-height: 1.45;
}
.ej-tecnica {
  margin: -4px 0 10px; padding: 0 2px;
  color: var(--muted); font-size: 12.5px; line-height: 1.45;
}
.barra h1 small.descarga { color: var(--warn); font-weight: 600; }

/* ------------------------------------------------------- Fase 2: pestañas */

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; min-height: 56px; font-size: 13px; color: var(--muted);
  border-top: 2px solid transparent;
}
#tabs button.sel { color: var(--fg); border-top-color: var(--accent); }
body { padding-bottom: 130px; }
.pie { bottom: 57px; }

/* --------------------------------------------------------- Fase 2: fichas */

#cuerpo, #tendencias { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }

.tarjeta {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 16px;
}
.tarjeta h2 { margin: 0 0 10px; font-size: 17px; }
.tarjeta h3.sub {
  margin: 16px 0 8px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.tarjeta .nota { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; }
.aviso-falta { border-color: var(--warn); background: var(--warn-dim); }
.aviso-falta h2 { color: var(--warn); }

.dato-grande { font-size: 40px; font-weight: 700; line-height: 1.1; }
.dato-grande span { font-size: 18px; color: var(--muted); font-weight: 400; }
.dato-medio { font-size: 27px; font-weight: 600; margin-top: 14px; }
.dato-medio .margen { font-size: 15px; color: var(--warn); font-weight: 400; }
.dato-sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.campo > label {
  display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.campo .num {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 8px; font-size: 18px;
}

.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macros div {
  background: var(--card-2); border-radius: 10px; padding: 10px 4px; text-align: center;
}
.macros b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.macros span { font-size: 10px; color: var(--muted); }

.sugerencia {
  margin-top: 14px; padding: 12px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--line);
}
.sugerencia.activa { border-color: var(--accent); background: rgba(77,141,255,.08); }
.sugerencia b { font-size: 16px; }
.sugerencia p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.selector {
  width: 100%; min-height: 48px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; font-size: 16px;
  padding: 0 10px; margin-bottom: 10px;
}

/* --------------------------------------------------------- Fase 2: gráficos */

.grafico { width: 100%; height: auto; display: block; margin-top: 6px; overflow: visible; }
.g-grid { stroke: var(--line); stroke-width: 1; }
.g-eje { fill: var(--muted); font-size: 9px; text-anchor: end; }
.g-eje.g-izq { text-anchor: start; }
.g-eje.g-der { text-anchor: end; }
.g-linea { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.g-punto { fill: var(--accent); }
.g-crudo { fill: var(--muted); opacity: .45; }

.barra { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.barra-tag { width: 96px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-riel { flex: 1; height: 14px; background: var(--card-2); border-radius: 7px; overflow: hidden; }
.barra-riel i { display: block; height: 100%; background: var(--accent); border-radius: 7px; }
.barra-n { width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
