@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #15161A;
  --surface: #1D2024;
  --surface-2: #262A30;
  --border: #34383F;
  --text: #F3F1EC;
  --text-muted: #93979F;
  --accent: #C7D94A;
  --accent-ink: #14150F;
  --fase-1: #E2543C;
  --fase-2: #E2A23C;
  --fase-3: #4C8FB8;
  --fase-4: #5FA085;
  --radius: 12px;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(78px + var(--safe-bottom));
  background: var(--bg);
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------- Top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 10px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.usuario-switch {
  display: flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}

.usuario-switch button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}

.usuario-switch button.activo {
  background: var(--user-color, var(--accent));
  color: var(--accent-ink);
}

/* ---------------- Content ---------------- */

.pantalla {
  padding: 6px 20px 28px;
  display: none;
}

.pantalla.activa {
  display: block;
}

/* ---------------- Hero (hoy) ---------------- */

.hero {
  border-radius: var(--radius);
  padding: 22px 20px;
  background: linear-gradient(155deg, var(--surface) 0%, var(--surface) 60%, color-mix(in srgb, var(--fase-color, var(--accent)) 22%, var(--surface)) 100%);
  border-left: 4px solid var(--fase-color, var(--accent));
  margin: 10px 0 18px;
}

.hero .eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fase-color, var(--accent));
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.05;
  margin: 0 0 4px;
  font-weight: 600;
}

.hero .subt {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.hero .progreso-texto {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.hero .progreso-barra {
  margin-top: 6px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.hero .progreso-barra > span {
  display: block;
  height: 100%;
  background: var(--fase-color, var(--accent));
}

.descanso-card {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.descanso-card .icono {
  font-family: var(--font-display);
  font-size: 44px;
  color: var(--text);
  margin-bottom: 6px;
}

/* ---------------- Ejercicios ---------------- */

.ejercicio {
  border-top: 1px solid var(--border);
  padding: 16px 0;
}

.ejercicio:last-child { border-bottom: 1px solid var(--border); }

.ejercicio-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.ejercicio-num {
  font-family: var(--font-display);
  color: var(--text-muted);
  font-size: 13px;
  min-width: 20px;
}

.ejercicio-nombre {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}

.ejercicio-objetivo {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.ejercicio-referencia {
  font-size: 12px;
  color: color-mix(in srgb, var(--accent) 80%, var(--text-muted));
  margin-top: 3px;
}

.ejercicio-sugerido {
  font-size: 12px;
  color: var(--fase-3);
  margin-top: 2px;
  font-weight: 600;
}

.ejercicio-sugerido-base {
  font-weight: 400;
  color: var(--text-muted);
}

.ejercicio-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all .15s ease;
}

.ejercicio-check.hecho {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.sets-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 28px 1fr 1fr 32px;
  gap: 8px 10px;
  align-items: center;
}

.sets-grid .cabecera-mini {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.sets-grid .set-num {
  font-family: var(--font-display);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.sets-grid input[type=number] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 8px;
  font-family: var(--font-body);
  -moz-appearance: textfield;
}

.sets-grid input[type=number]::-webkit-outer-spin-button,
.sets-grid input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

.sets-grid input:focus {
  outline: none;
  border-color: var(--accent);
}

.set-toggle {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}

.set-toggle.hecho {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---------------- Botonera acciones ---------------- */

.acciones-dia {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

.btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 13px 18px;
  flex: 1;
  text-align: center;
}

.btn.principal {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn.pequeno {
  flex: none;
  padding: 9px 14px;
  font-size: 13px;
}

.btn.peligro {
  color: var(--fase-1);
}

/* ---------------- Notas ---------------- */

textarea.notas {
  width: 100%;
  margin-top: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 54px;
}

/* ---------------- Historial ---------------- */

.seccion-titulo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 14px 0 12px;
}

.historial-item {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.historial-item:last-child { border-bottom: 1px solid var(--border); }

.historial-fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.historial-fecha {
  font-family: var(--font-display);
  font-size: 15px;
}

.historial-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.estado-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.estado-pill.completa { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.estado-pill.parcial { background: color-mix(in srgb, var(--fase-2) 25%, transparent); color: var(--fase-2); }
.estado-pill.vacia { background: var(--surface-2); color: var(--text-muted); }

.historial-detalle {
  display: none;
  margin-top: 10px;
  padding-left: 2px;
}

.historial-detalle.abierto { display: block; }

.historial-detalle .fila-set {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.vacio-estado {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------------- Estadísticas ---------------- */

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-card .valor {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}

.stat-card .etiqueta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.grafico-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.grafico-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}

.grafico-card canvas {
  max-height: 200px;
}

select.selector-ejercicio {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13.5px;
  margin-bottom: 12px;
  font-family: var(--font-body);
}

.comparativa-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.comparativa-fila .nombre {
  width: 60px;
  font-weight: 600;
  font-size: 13px;
}

.comparativa-fila .barra-fondo {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
}

.comparativa-fila .barra-fondo > span {
  display: block;
  height: 100%;
}

.comparativa-fila .valor-num {
  font-size: 12.5px;
  color: var(--text-muted);
  width: 42px;
  text-align: right;
}

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

.campo {
  margin-bottom: 18px;
}

.campo label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.campo input[type=text], .campo input[type=date] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: var(--font-body);
}

.programa-opciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.color-opciones {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.color-opciones button {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.color-opciones button.activo {
  border-color: var(--text);
}

.usuario-ajuste {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* ---------------- Nav inferior ---------------- */

.nav-inferior {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(29, 32, 36, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 20;
}

.nav-inferior button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 10px;
}

.nav-inferior button svg {
  width: 21px; height: 21px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.nav-inferior button.activo {
  color: var(--accent);
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 40;
  white-space: nowrap;
}

.toast.mostrar {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 480px) {
  body { background: #0c0d0f; }
}

/* ---------------- Editor de ejercicios ---------------- */

.seccion-titulo-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
}

.seccion-titulo-fila .seccion-titulo {
  margin: 0;
}

.btn-volver {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 13.5px;
  padding: 6px 0;
  cursor: pointer;
}

.bloque-editor-titulo {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 22px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ejercicio-editor-item {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.ejercicio-editor-item:last-child { border-bottom: 1px solid var(--border); }

.ejercicio-editor-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.ejercicio-editor-nombre {
  font-weight: 600;
  font-size: 14.5px;
  flex: 1;
}

.ejercicio-editor-nombre.inactivo {
  color: var(--text-muted);
  text-decoration: line-through;
}

.badge-inactivo {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.ejercicio-editor-form {
  display: none;
  margin-top: 14px;
}

.ejercicio-editor-form.abierto {
  display: block;
}

.ejercicio-editor-form .campo {
  margin-bottom: 12px;
}

.fase-objetivos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.fase-objetivo-campo label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.fase-objetivo-campo input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 13px;
  box-sizing: border-box;
}

.fase-objetivo-campo input:focus {
  outline: none;
  border-color: var(--accent);
}

.ejercicio-editor-acciones {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn-agregar-ejercicio {
  margin-top: 10px;
  width: 100%;
}
