:root {
  --negro: #0D0D0D;
  --panel: #1A1A1A;
  --linea: #2A2A2A;
  --naranja: #E8550A;
  --blanco: #FFFFFF;
  --gris: #9A9A9A;
  --verde: #2EB86B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--negro);
  color: var(--blanco);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

main { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px 24px; }

h1 { font-size: 28px; margin: 0 0 4px; font-weight: bold; }
h2 { font-size: 18px; margin: 28px 0 12px; font-weight: bold; text-transform: uppercase; letter-spacing: .04em; color: var(--naranja); }
h3 { font-size: 16px; margin: 0; font-weight: bold; }
p { margin: 0; }
.sub { color: var(--gris); font-size: 14px; }

button, .boton {
  font: inherit; font-weight: bold;
  border: 0; border-radius: 12px;
  padding: 14px 18px;
  background: var(--panel); color: var(--blanco);
  cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
}
button:active, .boton:active { transform: scale(.98); }
.primario { background: var(--naranja); color: var(--blanco); }
.ancho { width: 100%; }
.chico { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.peligro { color: #ff6b6b; }
button:disabled { opacity: .4; }

input, select, textarea {
  font: inherit; color: var(--blanco);
  background: var(--panel); border: 1px solid var(--linea); border-radius: 10px;
  padding: 12px; width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--gris); margin: 12px 0 6px; }

.tarjeta { background: var(--panel); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.fila { display: flex; gap: 8px; align-items: center; }
.fila > * { flex: 1; }
.fila > .fijo { flex: 0 0 auto; }

/* Ejercicio con video */
.ej { display: flex; gap: 12px; align-items: center; }
.ej video, .ej .sinvideo {
  width: 96px; height: 96px; flex: 0 0 96px;
  object-fit: cover; border-radius: 12px; background: #000;
}
.sinvideo { display: flex; align-items: center; justify-content: center; color: var(--gris); font-size: 12px; text-align: center; }
.ej .info { flex: 1; min-width: 0; }
.ej .meta { color: var(--gris); font-size: 14px; margin-top: 4px; }
.ej.hecho h3::after { content: "  ✓"; color: var(--verde); }
.ej.hecho { opacity: .6; }

/* Progreso */
.barra { height: 8px; background: var(--linea); border-radius: 8px; overflow: hidden; margin: 12px 0; }
.barra > div { height: 100%; background: var(--naranja); transition: width .3s; }
.racha { display: inline-block; background: var(--naranja); border-radius: 999px; padding: 4px 12px; font-weight: bold; font-size: 14px; margin-top: 8px; }

/* Comidas */
.comida { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.comida:last-child { border-bottom: 0; }
.comida input[type=checkbox] { width: 26px; height: 26px; flex: 0 0 26px; accent-color: var(--naranja); margin: 0; }
.comida .momento { font-size: 12px; color: var(--naranja); font-weight: bold; text-transform: uppercase; }
.comida.ok .texto { text-decoration: line-through; color: var(--gris); }

/* Días */
.dias { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0; }
.dias button { padding: 10px 0; font-size: 13px; border-radius: 10px; }
.dias button.activo { background: var(--naranja); }
.dias button.hoy:not(.activo) { outline: 2px solid var(--naranja); }

/* Navegación */
nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: #111; border-top: 1px solid var(--linea);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
nav a { flex: 1; text-align: center; padding: 16px 0; color: var(--gris); text-decoration: none; font-weight: bold; font-size: 14px; }
nav a.activo { color: var(--naranja); }

/* Modo gym */
#gym {
  position: fixed; inset: 0; z-index: 20; background: var(--negro);
  display: flex; flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}
#gym[hidden] { display: none; }
#gym .arriba { display: flex; justify-content: space-between; align-items: center; color: var(--gris); font-size: 14px; }
#gym video, #gym .sinvideo { width: 100%; flex: 1; min-height: 0; object-fit: contain; background: #000; border-radius: 16px; margin: 12px 0; }
#gym .nombre { font-size: 26px; font-weight: bold; }
#gym .detalle { font-size: 18px; color: var(--gris); margin: 6px 0 12px; }
#gym .serie { font-size: 20px; font-weight: bold; color: var(--naranja); }
#gym .botones { display: flex; gap: 8px; margin-top: 12px; }
#gym .botones button { flex: 1; padding: 18px; font-size: 18px; }
#gym .descanso { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
#gym .reloj { font-size: 96px; font-weight: bold; color: var(--naranja); font-variant-numeric: tabular-nums; }
#gym .fin { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 16px; }
#gym .fin h1 { font-size: 36px; }

/* Login */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.login input { font-size: 28px; text-align: center; letter-spacing: .4em; }
.error { color: #ff6b6b; font-size: 14px; min-height: 18px; }

.vacio { color: var(--gris); text-align: center; padding: 24px 8px; }
.aviso { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--verde); color: #fff; font-weight: bold; padding: 10px 18px; border-radius: 999px; z-index: 30; }
.subida { font-size: 13px; color: var(--naranja); margin-top: 8px; }

/* Grabación de audio */
button.grabando { background: #C62828; color: #fff; animation: latido 1s infinite; }
@keyframes latido { 50% { opacity: .7; } }

/* Alertas y caja */
.alerta { border: 2px solid var(--naranja); }
a.caja { display: flex; justify-content: space-between; align-items: flex-end; text-decoration: none; color: var(--blanco); margin-top: 16px; }
.montocaja { font-size: 28px; font-weight: bold; color: var(--naranja); }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-bottom: 90px; }
.separador { text-align: center; color: var(--gris); font-size: 12px; margin: 8px 0; text-transform: uppercase; letter-spacing: .05em; }
.burbuja { background: var(--panel); border-radius: 16px 16px 16px 4px; padding: 10px 12px; max-width: 85%; align-self: flex-start; }
.burbuja.mia { background: #3A1A08; border-radius: 16px 16px 4px 16px; align-self: flex-end; }
.burbuja audio { width: 240px; max-width: 100%; margin-top: 6px; display: block; }
.burbuja .etiqueta { font-size: 11px; font-weight: bold; color: var(--naranja); text-transform: uppercase; margin-bottom: 4px; }
.burbuja .hora { font-size: 11px; color: var(--gris); margin-top: 4px; }
.burbuja .hora a { color: var(--gris); }
.redactor {
  position: fixed; left: 0; right: 0; bottom: calc(53px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 10px 16px; background: var(--negro); border-top: 1px solid var(--linea); z-index: 9;
}
.redactor input { flex: 1; }
.redactor button { padding: 12px 14px; }
nav a { font-size: 13px; }

/* Guía de configuración */
.paso { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--linea); }
.paso:last-of-type { border-bottom: 0; }
.paso .marca { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 2px solid var(--gris); display: flex; align-items: center; justify-content: center; font-weight: bold; }
.paso.hecho .marca { background: var(--verde); border-color: var(--verde); color: #fff; }
.paso.hecho b { color: var(--gris); text-decoration: line-through; }

/* Sin señal */
#sinSenal {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: #C62828; color: #fff; font-weight: bold; font-size: 13px; text-align: center;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
}

/* Checklist con pruebas */
.check .marca { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; border: 2px solid var(--gris); display: flex; align-items: center; justify-content: center; font-weight: bold; }
.check.hecho .marca { background: var(--verde); border-color: var(--verde); color: #fff; }
.check.abierto { border: 2px solid var(--naranja); }
.check.falta { border: 2px solid #C62828; }
.check.falta .sub { color: #ff6b6b; }
.check.futuro { opacity: .75; }
.miniaturas { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.miniatura { flex: 0 0 auto; width: 96px; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--gris); }
.miniatura img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; display: block; }
.miniatura.invalida img { opacity: .4; outline: 2px solid #C62828; }
.miniatura button { padding: 6px; font-size: 12px; }
.fotochat { width: 200px; max-width: 100%; border-radius: 12px; margin-top: 6px; display: block; }

/* Botón flotante de cámara */
.fab {
  position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
  width: 68px; height: 68px; border-radius: 50%; background: var(--naranja); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); cursor: pointer;
}

/* Hoja para elegir el ítem de la foto */
.hoja { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; }
.hoja-caja { background: var(--panel); width: 100%; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.hoja-caja .sub { display: inline; margin-left: 6px; }
