/* Progresión — mobile-first, tema claro/oscuro según el sistema. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #15171c;
  --text-2: #5b6170;
  --line: #dcdfe6;
  --accent: #3550d8;
  --accent-ink: #ffffff;
  --accent-soft: #e3e8ff;
  --ok: #1f8a4c;
  --ok-soft: #dcf3e4;
  --warn: #b26a00;
  --warn-soft: #fdefd6;
  --danger: #c4312f;
  --danger-soft: #fbe0df;
  --band: #d9dffa;
  --radius: 14px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-2: #222631;
    --text: #eceef3;
    --text-2: #a2a8b8;
    --line: #2d3240;
    --accent: #8ea2ff;
    --accent-ink: #0f1115;
    --accent-soft: #252d52;
    --ok: #4cc583;
    --ok-soft: #173525;
    --warn: #f0a93b;
    --warn-soft: #3a2a10;
    --danger: #ff7470;
    --danger-soft: #3d1a1a;
    --band: #2a3260;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  overscroll-behavior-y: contain;
}
body.con-descanso { padding-bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom)); }
body.sin-nav { padding-bottom: 24px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0.4em 0; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ── Estructura ── */
.app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.cabecera { padding: 20px 0 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cabecera .sub { color: var(--text-2); font-size: 0.92rem; margin-top: 2px; }
.pila > * + * { margin-top: 12px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card + .card { margin-top: 12px; }
.card-titulo { font-size: 1rem; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card.destacada { border-color: var(--accent); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--text-2); font-size: 0.75rem; min-height: 44px;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.activo { color: var(--accent); font-weight: 600; }
body.sin-nav .nav { display: none; }

/* ── Botones ── */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 600; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(0.98); }
.btn-pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-sec { background: transparent; }
.btn-peligro { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-bloque { width: 100%; }
.btn-grande { min-height: 56px; font-size: 1.05rem; }
.btn-chico { min-height: 44px; padding: 0 12px; font-size: 0.9rem; }
.btn-icono { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; border-radius: 10px; }
.btn-link { background: none; border: 0; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 4px; cursor: pointer; }
.fila-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fila-btns > .btn { flex: 1; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.aviso { padding: 12px 14px; border-radius: 12px; font-size: 0.92rem; }
.aviso-ok { background: var(--ok-soft); color: var(--ok); }
.aviso-warn { background: var(--warn-soft); color: var(--warn); }
.aviso-danger { background: var(--danger-soft); color: var(--danger); }
.aviso-info { background: var(--accent-soft); color: var(--accent); }
.aviso + .aviso { margin-top: 8px; }

/* ── Formularios ── */
label.campo { display: block; }
label.campo > span { display: block; font-size: 0.85rem; color: var(--text-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
}
textarea { min-height: 72px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.segmentado { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.seg { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--text-2); cursor: pointer; padding: 0 8px; }
.seg.activo { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dias-sel .seg { min-width: 44px; }

/* ── Stepper ── */
.stepper { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stepper-etq { font-size: 0.75rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stepper-fila { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper-btn {
  width: 52px; height: 52px; flex: none; border: 0; background: transparent; font-size: 1.6rem;
  font-weight: 500; cursor: pointer; border-radius: 12px; touch-action: manipulation; user-select: none;
}
.stepper-btn:active { background: var(--line); }
.stepper-valor { flex: 1; text-align: center; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; }

.dolor-fila { display: flex; gap: 4px; }
.dolor-btn { flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid transparent; background: var(--surface-2); font-weight: 700; cursor: pointer; }
.dolor-btn.activo.d0 { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.dolor-btn.activo.d1 { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.dolor-btn.activo.d2, .dolor-btn.activo.d3 { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ── Sesión ── */
.ejercicio { padding: 0; overflow: hidden; }
.ejercicio > summary { list-style: none; padding: 14px 16px; cursor: pointer; display: flex; gap: 12px; align-items: center; min-height: 56px; }
.ejercicio > summary::-webkit-details-marker { display: none; }
.ejercicio > summary .titulo { flex: 1; min-width: 0; }
.ejercicio > summary .nombre { font-weight: 700; }
.ejercicio > summary .meta { font-size: 0.85rem; color: var(--text-2); }
.ejercicio .cuerpo { padding: 0 16px 16px; }
.ejercicio.hecho { opacity: 0.75; }
.ejercicio.bloqueado { border-color: var(--danger); }
.progreso-series { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.ejercicio.hecho .progreso-series { color: var(--ok); }

.serie { border-top: 1px solid var(--line); padding: 12px 0; }
.serie-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.serie-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.serie-grid .full { grid-column: 1 / -1; }
.serie.cerrada { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.serie.cerrada .resumen { font-variant-numeric: tabular-nums; }
.mensaje-motor { background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 0.92rem; margin: 4px 0 8px; }
.variante { font-size: 0.88rem; color: var(--warn); font-weight: 600; }

.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .texto { flex: 1; min-width: 0; }
.item .texto small { display: block; color: var(--text-2); }
.item.hecho .texto { text-decoration: line-through; color: var(--text-2); }
.btn-tiempo, .btn-crono {
  min-height: 44px; min-width: 76px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; padding: 0 10px;
}
.btn-tiempo.corriendo, .btn-crono.corriendo { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-listo { min-width: 44px; min-height: 44px; border-radius: 10px; border: 2px solid var(--line); background: transparent; font-weight: 700; cursor: pointer; }
.btn-listo.activo { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Descanso */
.descanso {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; min-height: 68px;
  background: var(--text); color: var(--bg); overflow: hidden;
}
body.sin-nav .descanso { bottom: 0; }
.descanso-progreso { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--accent); transform-origin: left; }
.descanso-info { flex: 1; display: flex; flex-direction: column; }
.descanso-tiempo { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.descanso-texto { font-size: 0.8rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-descanso { min-height: 48px; min-width: 56px; border-radius: 10px; border: 0; background: rgba(127, 127, 127, 0.25); color: inherit; font-weight: 700; cursor: pointer; }
.descanso.terminado { background: var(--ok); color: #fff; }

/* Modal y toast */
.modal-fondo { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.modal-fondo.visible { opacity: 1; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(20px); transition: transform 0.2s; }
.modal-fondo.visible .modal { transform: none; }
.modal-cab { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.modal-acciones { display: flex; gap: 8px; margin-top: 16px; }
.modal-acciones .btn { flex: 1; }
.toast { position: fixed; left: 16px; right: 16px; top: 16px; z-index: 60; padding: 14px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; opacity: 0; transform: translateY(-10px); transition: 0.25s; max-width: 528px; margin: 0 auto; }
.toast.visible { opacity: 1; transform: none; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
.toast-danger { background: var(--danger); color: #fff; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lista > li:last-child { border-bottom: 0; }
.lista a.fila { display: flex; justify-content: space-between; gap: 8px; text-decoration: none; color: inherit; min-height: 44px; align-items: center; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv b { font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.75rem; color: var(--text-2); }

/* Onboarding */
.pasos { display: flex; gap: 6px; margin: 4px 0 16px; }
.pasos span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.pasos span.activo { background: var(--accent); }

/* Video */
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.claves { margin: 0; padding-left: 20px; }
.claves li { margin: 6px 0; }

/* Gráficos */
.grafico { width: 100%; height: auto; display: block; overflow: visible; }
.grafico text { font-size: 11px; fill: var(--text-2); }
.grafico .g-etq { fill: var(--text); font-size: 12px; font-weight: 600; }
.grafico .g-sub { font-size: 10px; }
.grafico .g-valor { fill: var(--text); font-weight: 700; }
.g-banda { fill: var(--band); }
.g-barra.g-ok { fill: var(--accent); }
.g-barra.g-bajo { fill: var(--warn); }
.g-barra.g-alerta { fill: var(--danger); }
.g-barra.g-alto { fill: var(--text-2); }
.g-barra.g-prev { fill: var(--line); }
.g-umbral { stroke: var(--danger); stroke-dasharray: 3 3; stroke-width: 1; }
.g-grilla { stroke: var(--line); stroke-width: 1; }
.g-linea { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.g-punto { fill: var(--accent); }
.g-linea.sec { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.g-punto.sec { fill: var(--text-2); }
.g-linea.ok { stroke: var(--ok); }
.g-punto.ok { fill: var(--ok); }
.g-record { fill: none; stroke: var(--warn); stroke-width: 2.5; }
.g-hecho { fill: var(--ok); }
.g-libre { fill: var(--surface-2); }
.g-hoy { stroke: var(--accent); stroke-width: 2; }
.grafico-vacio { padding: 24px; text-align: center; color: var(--text-2); background: var(--surface-2); border-radius: 10px; font-size: 0.9rem; }
.leyenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-2); margin-top: 6px; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

details.plegable > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
.resultado { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.resultado:last-child { border-bottom: 0; }
.punto { width: 12px; height: 12px; border-radius: 50%; flex: none; margin-top: 5px; }
.punto.verde { background: var(--ok); }
.punto.gris { background: var(--text-2); }
.punto.ambar { background: var(--warn); }
.foto-miniaturas { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.foto-miniaturas img, .foto-miniaturas video { height: 120px; border-radius: 10px; flex: none; }

html, body { overflow-x: clip; }
.seg { min-width: 0; }
