/* ==========================================================================
   Anchor — "sala de halterofilia"
   Tokens: acero bruñido de fondo, texto tiza, latón viejo como marca.
   FIRMA: los week_types se codifican con los COLORES DE LOS DISCOS de
   competición, donde el peso del disco ES la intensidad de la semana:
     rojo 25 kg  = intensification / high_stimulus
     azul 20 kg  = variation / accumulation
     amarillo 15 = hsr_* (rehab)
     verde 10 kg = deload
     acero       = standard
   Estructura que informa, no decoración.
   ========================================================================== */

:root {
  --steel-950: #101216;
  --steel-900: #15171c;
  --steel-800: #1a1d23;
  --steel-700: #232730;
  --steel-600: #2e333e;
  --line: #343a46;
  --chalk: #ece8df;
  --chalk-dim: #b9b4a7;
  --chalk-faint: #8b877c;
  --brass: #c9a227;
  --brass-bright: #e0bb45;
  --brass-dim: rgba(201, 162, 39, 0.14);
  --plate-red: #c23b3b;
  --plate-blue: #3567b0;
  --plate-yellow: #d9a821;
  --plate-green: #3e8e5a;
  --plate-steel: #6a7383;
  --danger: #d96a6a;
  --ok: #58b380;
  --radius: 10px;
  --font-display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Liberation Sans Narrow", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(201, 162, 39, 0.05), transparent 60%),
    var(--steel-900);
  color: var(--chalk);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

.shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.75rem 1rem 4rem;
}

/* --------------------------------------------------------------------------
   App bar
   -------------------------------------------------------------------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: rgba(16, 18, 22, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.appbar-brand { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }

.appbar-logo {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 7px;
  background: linear-gradient(160deg, var(--brass-bright), var(--brass) 65%);
  color: var(--steel-950);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  flex: none;
}

.appbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
}

.appbar-brand p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--chalk-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-actions { display: flex; gap: 0.4rem; flex: none; }

.appbar-actions button {
  padding: 0.4rem 0.7rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--chalk-dim);
  font-size: 0.8rem;
  cursor: pointer;
}

.appbar-actions button:hover { border-color: var(--brass); color: var(--brass-bright); }

/* --------------------------------------------------------------------------
   Constructor de programas (plegable)
   -------------------------------------------------------------------------- */

.builder {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel-800);
  overflow: hidden;
}

.builder > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.builder > summary::-webkit-details-marker { display: none; }
.builder > summary::after { content: "+"; color: var(--brass); font-size: 1.2rem; }
.builder[open] > summary::after { content: "–"; }
.builder-hint { font-family: var(--font-body); font-size: 0.75rem; font-weight: 400; color: var(--chalk-faint); text-transform: none; letter-spacing: 0; }

.builder form { padding: 0 1rem 1rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem 1rem;
}

.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select, input {
  width: 100%;
  padding: 0.6rem 0.65rem;
  background: var(--steel-700);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--chalk);
  font-size: 1rem;
  font-family: var(--font-body);
}

select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.derived-field { margin: 0; align-self: end; font-size: 0.85rem; color: var(--chalk-dim); }
.derived-field strong { font-family: var(--font-mono); color: var(--chalk); }
.hint { font-size: 0.75rem; color: var(--chalk-faint); }

#submit_button {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem;
  background: linear-gradient(160deg, var(--brass-bright), var(--brass) 70%);
  border: none;
  border-radius: 8px;
  color: var(--steel-950);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#submit_button:disabled { opacity: 0.55; cursor: progress; }

#status { min-height: 1.2rem; margin: 0.5rem 0; color: var(--chalk-dim); font-size: 0.9rem; }

.save-program-btn {
  display: block;
  width: 100%;
  margin: 0.5rem 0 1rem;
  padding: 0.7rem 1rem;
  background: var(--brass-dim);
  border: 1px solid var(--brass);
  border-radius: 8px;
  color: var(--brass-bright);
  font-size: 0.95rem;
  cursor: pointer;
}

.save-program-btn:disabled { opacity: 0.85; cursor: default; }

.core-warnings {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.8rem;
  background: rgba(217, 168, 33, 0.07);
  border-left: 3px solid var(--plate-yellow);
  border-radius: 0 6px 6px 0;
}

.core-warnings p { margin: 0.3rem 0; font-size: 0.85rem; color: var(--chalk-dim); }

/* Aviso de método EXPERIMENTAL sin validación clínica (poblaciones
   vulnerables): destacado, no se puede pasar por alto. */
.experimental-banner {
  margin: 0.9rem 0;
  padding: 0.7rem 0.9rem;
  background: rgba(194, 59, 59, 0.12);
  border: 1px solid var(--plate-red);
  border-left-width: 4px;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: var(--chalk);
  line-height: 1.4;
}
.experimental-banner::before { content: "🔬 "; }
.experimental-banner strong { color: var(--plate-red); }

/* --------------------------------------------------------------------------
   LA FIRMA: la barra del ciclo — un segmento por semana, coloreado como el
   disco cuyo peso corresponde a la intensidad de esa semana. Clic = saltar.
   -------------------------------------------------------------------------- */

.cycle-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 1.25rem 0 0.5rem;
  padding: 0 0.25rem;
}

.cycle-bar::before, .cycle-bar::after {
  content: "";
  flex: 1;
  height: 6px;
  background: linear-gradient(180deg, var(--steel-600), var(--steel-700));
  border-radius: 3px;
}

.cycle-seg {
  flex: none;
  width: 2.2rem;
  height: 2.6rem;
  border: none;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

.cycle-seg[data-plate="red"]    { background: var(--plate-red); }
.cycle-seg[data-plate="blue"]   { background: var(--plate-blue); }
.cycle-seg[data-plate="yellow"] { background: var(--plate-yellow); color: #1d1a10; }
.cycle-seg[data-plate="green"]  { background: var(--plate-green); }
.cycle-seg[data-plate="steel"]  { background: var(--plate-steel); }

.cycle-seg:hover { transform: translateY(-2px); }

/* --------------------------------------------------------------------------
   Programa: semanas y sesiones
   -------------------------------------------------------------------------- */

.week { margin: 1.75rem 0; }

.week h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
}

.week h3 {
  margin: 1.1rem 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

/* Badges de week_type = discos */
.badge {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--plate-steel);
}

.badge--variation, .badge--accumulation { background: var(--plate-blue); }
.badge--intensification, .badge--high_stimulus { background: var(--plate-red); }
.badge--deload { background: var(--plate-green); }
[class*="badge--hsr"] { background: var(--plate-yellow); color: #1d1a10; }
.badge--superset { background: var(--steel-600); color: var(--chalk-dim); font-weight: 500; }

/* Tabla de ejercicios */
table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chalk-faint);
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid rgba(52, 58, 70, 0.55);
  font-size: 0.95rem;
  vertical-align: top;
}

td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.range { font-family: var(--font-mono); font-size: 0.8rem; color: var(--chalk-faint); }

.role-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--steel-700);
  color: var(--chalk-dim);
}

.role-chip--primary { background: var(--brass-dim); color: var(--brass-bright); }

.exercise-name { font-weight: 500; }

.execution-note { font-size: 0.78rem; color: var(--brass); font-style: italic; margin-top: 0.15rem; }

/* Swap */
.swap-btn {
  margin-left: 0.45rem;
  padding: 0 0.4rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--chalk-faint);
  font-size: 0.9rem;
  cursor: pointer;
}

.swap-btn:hover { border-color: var(--brass); color: var(--brass-bright); }

.swap-chip {
  margin-left: 0.45rem;
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
  background: var(--brass-dim);
  border: 1px solid var(--brass);
  border-radius: 999px;
  color: var(--brass-bright);
  cursor: pointer;
}

.swap-panel td { padding: 0.5rem; background: var(--steel-800); }
.swap-list { display: flex; flex-direction: column; gap: 0.45rem; }

.swap-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem 0.75rem;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--steel-700);
}

.swap-item .swap-warning { grid-column: 1 / -1; font-size: 0.78rem; color: var(--chalk-dim); }
.swap-item--hidden { display: none; }

/* Explicación del mesociclo (el porqué, anclado al programa) */
.why-card {
  margin: 0.75rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel-800);
}
.why-card > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.why-card > summary::-webkit-details-marker { display: none; }
.why-card > summary::after { content: "+"; color: var(--brass); font-size: 1.2rem; }
.why-card[open] > summary::after { content: "\2013"; }
.why-card .why-panel { padding: 0 1rem 1rem; }

/* Marcas iniciales (onboarding opcional) */
.marks-card {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel-800);
  padding: 0.75rem 1rem;
}
.marks-card summary {
  cursor: pointer;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--chalk);
}
.marks-optional { color: var(--chalk-faint); text-transform: none; letter-spacing: 0; }
.marks-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.6rem 0; }
.marks-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--steel-700);
}
.marks-row label { color: var(--chalk-dim); font-size: 0.8rem; display: flex; align-items: center; gap: 0.3rem; }
/* display:flex pisa la regla [hidden] del navegador — reafirmarla con más
   especificidad, o el modo 1RM no oculta reps/esfuerzo de verdad. */
.marks-row label[hidden] { display: none; }
.marks-row input { width: 4.2rem; }
.marks-mode { font-size: 0.8rem; }
.marks-name { color: var(--chalk); font-size: 0.9rem; }
.marks-save {
  background: var(--brass-dim);
  border: 1px solid var(--brass);
  color: var(--brass-bright);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}
.marks-status { margin-left: 0.6rem; color: var(--chalk-dim); font-size: 0.85rem; }
@media (max-width: 640px) {
  .marks-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .marks-row label { justify-content: space-between; }
}
/* Cabeceras de categoría del selector de métodos: no seleccionables,
   en clarito; las opciones recuperan el color pleno. */
#core_id optgroup { color: var(--chalk-faint); font-style: normal; font-size: 0.8rem; }
#core_id option { color: var(--chalk); font-size: 1rem; }
.swap-more {
  align-self: flex-start;
  background: none;
  border: 1px dashed var(--line);
  color: var(--chalk-dim);
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}
.swap-more:hover { color: var(--chalk); border-color: var(--chalk-dim); }

.swap-tier { font-size: 0.68rem; padding: 0.12rem 0.5rem; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.swap-tier--1 { background: rgba(88, 179, 128, 0.15); border: 1px solid var(--ok); color: var(--ok); }
.swap-tier--2 { background: var(--brass-dim); border: 1px solid var(--brass); color: var(--brass-bright); }
.swap-tier--3 { background: rgba(217, 106, 106, 0.12); border: 1px solid var(--danger); color: var(--danger); }

.swap-actions { display: flex; gap: 0.4rem; }

.swap-actions button {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--chalk);
}

.swap-actions button:hover { border-color: var(--brass); }

.swap-footnote { font-size: 0.85rem; color: var(--chalk-faint); font-style: italic; margin: 0.75rem 0; }

/* Registro */
.log-btn {
  margin: 0.5rem 0 1.25rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--steel-800);
  color: var(--chalk-dim);
  font-size: 0.88rem;
  width: 100%;
}

.log-btn--done { border-color: var(--ok); color: var(--ok); background: rgba(88, 179, 128, 0.06); }

.log-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 1.25rem;
  padding: 0.75rem;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  background: var(--steel-800);
}

.log-line { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.log-line .log-name { flex: 1 1 12rem; font-size: 0.9rem; min-width: 10rem; }
.log-line label { font-size: 0.72rem; display: flex; gap: 0.3rem; align-items: center; color: var(--chalk-faint); text-transform: uppercase; }
.log-line input { width: 4.6rem; padding: 0.45rem 0.4rem; font-family: var(--font-mono); text-align: center; }

.log-form button {
  align-self: stretch;
  padding: 0.65rem;
  cursor: pointer;
  background: var(--brass-dim);
  border: 1px solid var(--brass);
  border-radius: 8px;
  color: var(--brass-bright);
  font-size: 0.95rem;
}

/* Paneles (historial / porqué) */
.panel {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel-800);
}

.why-panel { border-color: rgba(201, 162, 39, 0.55); }

.panel h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.why-panel h4 { margin: 1.1rem 0 0.3rem; font-family: var(--font-display); letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.95rem; color: var(--brass-bright); }
.why-panel .why-note { font-size: 0.83rem; color: var(--chalk-faint); font-style: italic; }
.why-panel li { margin: 0.25rem 0; font-size: 0.92rem; }

.session-note { font-size: 0.85rem; color: var(--chalk-dim); }

/* --------------------------------------------------------------------------
   Móvil: la tabla se apila en tarjetas (etiqueta por celda via data-label)
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .shell { padding: 0.5rem 0.6rem 4rem; }
  .appbar-brand p { display: none; }
  .appbar-actions button { padding: 0.35rem 0.55rem; font-size: 0.72rem; }

  thead { display: none; }
  table, tbody { display: block; }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.15rem 0.5rem;
    padding: 0.6rem 0.65rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--steel-800);
  }

  tbody tr.swap-panel { display: block; padding: 0; border: none; background: none; }
  tbody tr.swap-panel td { display: block; }

  tbody td { display: block; padding: 0; border: none; }

  /* fila 1: rol + nombre (a lo ancho) */
  tbody td:nth-child(1) { grid-column: 1 / -1; order: 0; }
  tbody td:nth-child(2) { grid-column: 1 / -1; order: 1; font-size: 1.02rem; margin: 0.1rem 0 0.25rem; }
  /* fila 2: series / reps / rir con su etiqueta */
  tbody td[data-label] { order: 2; font-family: var(--font-mono); font-size: 1.05rem; }
  tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-body);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--chalk-faint);
  }
  tbody td.range { grid-column: 1 / -1; order: 3; font-size: 0.75rem; }
  tbody td:last-child { grid-column: 1 / -1; order: 4; padding: 0; }
  tbody td:last-child:empty { display: none; }

  .swap-item { grid-template-columns: 1fr auto; }
  .swap-actions { grid-column: 1 / -1; }
  .swap-actions button { flex: 1; padding: 0.5rem; }

  .log-line { border-bottom: 1px dashed var(--line); padding-bottom: 0.5rem; }
  .log-line .log-name { flex-basis: 100%; }
  .log-line input { width: 4.2rem; }

  .cycle-seg { width: 2rem; height: 2.4rem; }
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-box {
  max-width: 22rem;
  margin: 12vh auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel-800);
}

.login-box label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; color: var(--chalk-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.login-box button {
  padding: 0.8rem;
  background: linear-gradient(160deg, var(--brass-bright), var(--brass) 70%);
  border: none;
  border-radius: 8px;
  color: var(--steel-950);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.login-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; margin: 0; }

/* La página de login reutiliza el header simple */
body > header:not(.appbar) { padding: 2rem 1rem 0; text-align: center; }
body > header:not(.appbar) h1 { font-family: var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }
body > header:not(.appbar) p { color: var(--chalk-faint); }

/* --------------------------------------------------------------------------
   Accesibilidad e impresión
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .cycle-seg:hover { transform: none; }
}

@media print {
  body { background: #fff; color: #111; }
  .appbar, .builder, #status, .save-program-btn, .swap-btn, .swap-panel,
  .swap-actions, .log-btn, .log-form, .cycle-bar { display: none !important; }
  .week { page-break-inside: avoid; }
  .badge { border: 1px solid #999; color: #111; background: none; }
  tbody td { border-bottom: 1px solid #ddd; }
  .panel { border: 1px solid #ccc; }
}

/* Ficha (i) y descanso */
.info-btn { font-style: italic; font-family: Georgia, serif; font-weight: 700; }
.info-body { padding: 0.25rem 0.25rem 0.4rem; }
.info-body p { margin: 0.3rem 0; font-size: 0.88rem; }
.info-pattern { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--brass-bright); }
.info-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.info-chips span {
  padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.72rem;
  background: var(--steel-600); color: var(--chalk-dim);
}
.info-why { color: var(--chalk-dim); font-style: italic; }
.rest-chip {
  display: inline-block; margin: 0.25rem 0.45rem 0 0;
  padding: 0.15rem 0.6rem; font-size: 0.75rem;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  background: var(--steel-700); border: 1px solid var(--line);
  border-radius: 999px; color: var(--chalk-dim); cursor: pointer;
}
.rest-chip--running { border-color: var(--brass); color: var(--brass-bright); }
@media print { .rest-chip { border: 1px solid #999; } .info-btn { display: none; } }

/* Mapa de calor muscular */
.hm-week-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.5rem 0; }
.hm-week-chips button {
  width: 1.9rem; height: 1.9rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--steel-700); color: var(--chalk-dim);
  font-family: var(--font-display); font-weight: 700; cursor: pointer;
}
.hm-week-chips button[data-plate="red"] { border-color: var(--plate-red); }
.hm-week-chips button[data-plate="blue"] { border-color: var(--plate-blue); }
.hm-week-chips button[data-plate="yellow"] { border-color: var(--plate-yellow); }
.hm-week-chips button[data-plate="green"] { border-color: var(--plate-green); }
.hm-week-chips .hm-chip--active { background: var(--chalk); color: var(--steel-950); }
.hm-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0 0.75rem; }
.hm-svg { width: min(340px, 100%); height: auto; flex: none; }
.hm-svg [data-group] { stroke: var(--line); stroke-width: 1; transition: fill-opacity 0.25s; }
.hm-outline { fill: none; stroke: var(--steel-600); stroke-width: 2; }
.hm-label { fill: var(--chalk-faint); font-size: 11px; text-anchor: middle; font-family: var(--font-body); }
.hm-legend { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; color: var(--chalk-dim); }
.hm-legend i { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; margin-right: 0.35rem; vertical-align: -2px; }
@media (max-width: 640px) { .hm-wrap { flex-direction: column; align-items: flex-start; } }

/* La onda del ciclo */
.ic-svg { width: min(360px, 100%); height: auto; display: block; margin: 0.4rem 0 0.75rem; }
.ic-label { fill: var(--chalk-faint); font-size: 9px; text-anchor: middle; font-family: var(--font-mono); }

/* Generación en curso: filas visibles pero sin interacción */
.generating .swap-btn, .generating .info-btn, .generating .rest-chip, .generating .log-btn {
  pointer-events: none;
  opacity: 0.35;
}

/* MODO ENTRENO: overlay a pantalla completa */
.workout-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--steel-950);
}
body.workout-open { overflow: hidden; }
.workout-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; padding-top: max(0.9rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); flex: none;
}
.workout-head h2 {
  margin: 0; font-family: var(--font-display); font-size: 1.4rem;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.workout-head p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--chalk-faint); }
.workout-close {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--steel-700); border: 1px solid var(--line);
  color: var(--chalk); font-size: 1rem; cursor: pointer;
}
.workout-body {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  max-width: 640px; width: 100%; margin: 0 auto;
}
.workout-card {
  padding: 0.9rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--steel-800);
}
.workout-ex-name { margin: 0; font-size: 1.15rem; font-weight: 600; }
.workout-prescription { margin: 0.2rem 0 0.7rem; font-size: 0.85rem; color: var(--brass-bright); font-family: var(--font-mono); }
.workout-prescription em { color: var(--chalk-dim); font-family: var(--font-body); }
.workout-inputs { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.workout-inputs label {
  flex: 1 1 4.5rem; display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--chalk-faint);
}
.workout-inputs input {
  padding: 0.7rem 0.3rem; text-align: center; font-size: 1.25rem;
  font-family: var(--font-mono);
}
.workout-card .rest-chip { margin-top: 0.7rem; }
.rest-chip--big { font-size: 0.95rem; padding: 0.45rem 1rem; width: 100%; text-align: center; }
.workout-foot {
  flex: none; padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  max-width: 640px; width: 100%; margin: 0 auto;
}
.workout-save {
  width: 100%; padding: 0.95rem;
  background: linear-gradient(160deg, var(--brass-bright), var(--brass) 70%);
  border: none; border-radius: 10px; color: var(--steel-950);
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
@media print { .workout-overlay { display: none; } }

/* ==========================================================================
   Navegación de 3 vistas + barra de pestañas
   ========================================================================== */
.shell { padding-bottom: 5.5rem; }  /* hueco para la tabbar fija */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: rgba(16, 18, 22, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 0.55rem 0.3rem;
  background: none; border: none; cursor: pointer;
  color: var(--chalk-faint);
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.tab-icon { font-size: 1.25rem; line-height: 1; }
.tab--active { color: var(--brass-bright); }
.tab--active .tab-icon { filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.5)); }

/* Constructor como vista (antes era un <details>) */
.builder-form { padding: 0.25rem 0 1rem; }

/* Cabecera de Mi plan: método + opciones en chips */
.plan-header { margin: 0.5rem 0 1rem; }
.plan-title {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--chalk);
}
.plan-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.plan-chip {
  display: inline-flex; flex-direction: column;
  padding: 0.35rem 0.6rem;
  background: var(--steel-800);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.15;
}
.plan-chip-k {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--chalk-faint);
}
.plan-chip-v { font-size: 0.9rem; color: var(--chalk); font-weight: 600; }

/* --- Vista Entrena -------------------------------------------------------- */
.entrena-head {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0.5rem 0;
}
.entrena-title { flex: 1; text-align: center; }
.entrena-title h2 {
  margin: 0; font-family: var(--font-display); font-size: 1.35rem;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.entrena-title p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--chalk-faint); }
.entrena-nav {
  flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: var(--steel-700); border: 1px solid var(--line);
  color: var(--chalk); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.entrena-nav:disabled { opacity: 0.3; cursor: default; }
.entrena-due {
  color: var(--brass-bright); font-weight: 700;
}
.entrena-done { color: var(--ok); font-size: 0.7rem; }
.entrena-crono {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  margin: 0 0 0.9rem;
}
.entrena-hint {
  margin: 0 0 0.9rem; padding: 0.6rem 0.8rem;
  background: rgba(201, 162, 39, 0.07);
  border-left: 3px solid var(--brass); border-radius: 0 6px 6px 0;
  font-size: 0.85rem; color: var(--chalk-dim);
}
.entrena-complete {
  margin: 0 0 0.9rem; padding: 0.7rem 0.9rem;
  background: rgba(88, 179, 128, 0.1);
  border: 1px solid var(--ok); border-radius: var(--radius);
  color: var(--ok); font-size: 0.9rem; text-align: center;
}
.entrena-empty {
  text-align: center; padding: 3rem 1rem; color: var(--chalk-dim);
}
.entrena-cta {
  margin-top: 1rem; padding: 0.8rem 1.6rem;
  background: linear-gradient(160deg, var(--brass-bright), var(--brass) 70%);
  border: none; border-radius: 8px; color: var(--steel-950);
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer;
}
.linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--brass-bright); text-decoration: underline; font: inherit;
}
/* En la vista Entrena la sesión no es overlay: el body no bloquea scroll */
#view_entrena .workout-body { padding: 0; max-width: 100%; }
#view_entrena .workout-save { margin-top: 1rem; }

/* Registro por series efectivas: una fila por serie */
.set-list { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.3rem; }
.set-row {
  display: flex; align-items: flex-end; gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--steel-900); border: 1px solid var(--steel-700);
  border-radius: 8px;
}
.set-num {
  flex: none; width: 1.9rem; text-align: center;
  font-family: var(--font-display); font-size: 1rem; color: var(--brass);
  padding-bottom: 0.55rem;
}
.set-row label {
  flex: 1 1 3rem; display: flex; flex-direction: column; gap: 0.2rem;
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--chalk-faint);
}
.set-row input {
  padding: 0.5rem 0.2rem; text-align: center; font-size: 1.1rem;
  font-family: var(--font-mono);
}
.entrena-disclaimer {
  margin: 0 0 0.9rem; padding: 0.5rem 0.8rem;
  background: var(--steel-800); border: 1px solid var(--line);
  border-radius: 8px;
}
.entrena-disclaimer > summary {
  cursor: pointer; font-size: 0.85rem; color: var(--chalk-dim);
  list-style: none;
}
.entrena-disclaimer > summary::-webkit-details-marker { display: none; }
.entrena-disclaimer > summary::before { content: "⚠️ "; }
.entrena-disclaimer p { margin: 0.5rem 0 0.2rem; font-size: 0.82rem; color: var(--chalk-dim); }

/* Estadísticas */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.stat-card { padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--steel-700); }
.stat-name { margin: 0 0 0.5rem; font-weight: 600; font-size: 0.95rem; }
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.stat-row div { display: flex; flex-direction: column; }
.stat-num { font-family: var(--font-mono); font-size: 1.2rem; color: var(--brass-bright); }
.stat-lbl { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--chalk-faint); }
.spark { width: 100%; height: 28px; display: block; }
.stat-raw { margin-top: 0.75rem; }
.stat-raw summary { cursor: pointer; color: var(--chalk-dim); font-size: 0.85rem; }

/* Silueta del mapa de calor */
.hm-body { fill: var(--steel-700); stroke: var(--steel-600); stroke-width: 1.5; }
.hm-svg [data-group] { stroke: rgba(16, 18, 22, 0.55); }

/* v4-Kilos: carga prescrita con su porqué */
.kg-chip { margin-top: 0.25rem; }
.kg-chip strong { color: var(--brass-bright); font-family: var(--font-mono); font-size: 0.95rem; }
.kg-note { display: block; font-size: 0.72rem; color: var(--chalk-faint); font-style: italic; margin-top: 0.1rem; }
.workout-card .kg-note { margin: -0.4rem 0 0.5rem; }

/* Crono del modo entreno */
.workout-crono { display: flex; align-items: center; gap: 0.4rem; }
.crono-time {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 1.3rem; min-width: 3.2rem; text-align: right; color: var(--chalk-dim);
}
.crono-time--running { color: var(--brass-bright); }
.crono-play, .crono-reset {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--steel-700); border: 1px solid var(--line);
  color: var(--chalk); font-size: 0.9rem; cursor: pointer;
}
.crono-play:hover, .crono-reset:hover { border-color: var(--brass); }
