/* ============================================================
   Rutina - tema oscuro para gimnasio.
   Regla: un solo acento (verde) SOLO para serie completada y
   timer corriendo. Todo lo demas en grises. Numeros protagonistas.
   ============================================================ */
:root {
  --bg: #0d0f12;
  --surface: #16191e;
  --surface-2: #1d2127;
  --surface-3: #252a31;
  --line: #2b313a;
  --line-soft: #21262d;
  --txt: #eef1f4;
  --txt-2: #9aa3ad;
  --txt-3: #828d9a;
  --accent: #37e08a;        /* unico acento */
  --accent-dim: #143f2b;
  --accent-ink: #04140b;
  --danger: #e0574d;        /* solo para errores criticos de red, muy puntual */
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --nav-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* Numeros protagonistas: peso condensado, alto, tabular */
.num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-stretch: condensed;
}

/* ---------- Layout ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--nav-h) + var(--safe-bot) + 24px);
  min-height: 100%;
}
.screen-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--txt-3);
  font-weight: 700;
  margin: 4px 2px 14px;
}

/* ---------- Barra de red / sync ---------- */
.netbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: calc(var(--safe-top) * -1 - 14px) -16px 12px;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  background: var(--surface-2);
  color: var(--txt-2);
  border-bottom: 1px solid var(--line);
}
.netbar--warn { color: #e8c37a; }
.netbar--sync { color: var(--txt-2); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ---------- HOME ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.hero__kicker { color: var(--txt-3); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700; }
.hero__day { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 2px; line-height: 1.1; }
.hero__sub { color: var(--txt-2); font-size: 15px; margin-bottom: 4px; }
.hero__meta { color: var(--txt-3); font-size: 13px; margin-top: 8px; }
.hero__rest { color: var(--txt-2); font-size: 16px; }

.btn-primary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 56px;
  background: var(--txt); color: var(--bg);
  font-size: 18px; font-weight: 800; letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}
.btn-primary:active { filter: brightness(0.9); }
.btn-ghost {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--tap);
  background: var(--surface-2); color: var(--txt);
  border: 1px solid var(--line);
  font-weight: 700; border-radius: var(--radius-sm);
}

/* Peso corporal + meta */
.weight-card .row { display: flex; align-items: baseline; justify-content: space-between; }
.weight-now { font-size: 40px; }
.weight-now small { font-size: 16px; color: var(--txt-2); font-weight: 600; margin-left: 4px; }
.weight-goal { color: var(--txt-3); font-size: 14px; text-align: right; }
.progressbar { height: 10px; background: var(--surface-3); border-radius: 6px; margin-top: 14px; overflow: hidden; }
.progressbar__fill { height: 100%; background: var(--txt-2); border-radius: 6px; }
.progress-legend { display: flex; justify-content: space-between; color: var(--txt-3); font-size: 12px; margin-top: 6px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.metric__val { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.metric__lbl { color: var(--txt-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.inline-input {
  min-height: var(--tap);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--txt);
  padding: 0 14px;
  font-size: 17px;
  width: 100%;
}

/* ---------- SESION: cards de ejercicio ---------- */
.session-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.session-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.session-head .dur { color: var(--txt-3); font-size: 13px; }
.session-progress { color: var(--txt-2); font-size: 13px; margin-bottom: 14px; }

.exq {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.exq--done { border-color: var(--accent-dim); }
.exq__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; min-height: var(--tap);
  width: 100%; text-align: left;
}
.exq__check {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: transparent; font-size: 15px; font-weight: 900;
}
.exq--done .exq__check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.exq__main { flex: 1 1 auto; min-width: 0; }
.exq__name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.exq__name .warn { font-size: 12px; color: var(--txt-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-weight: 700; }
.exq__sub { color: var(--txt-3); font-size: 13px; margin-top: 3px; }
.exq__target { text-align: right; flex: 0 0 auto; }
.exq__target .st { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.exq__target .last { color: var(--txt-3); font-size: 12px; margin-top: 2px; }
.exq__chev { flex: 0 0 auto; color: var(--txt-3); transition: transform .15s; }
.exq--open .exq__chev { transform: rotate(180deg); }

.exq__body { display: none; padding: 0 16px 14px; }
.exq--open .exq__body { display: block; }

.progress-hint {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px;
  font-size: 13px; color: var(--txt-2);
}
.progress-hint b { color: var(--txt); font-weight: 700; }

/* Filas de set */
.setrow {
  display: grid; grid-template-columns: 34px 1fr 1fr 48px; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line-soft);
}
.setrow--time { grid-template-columns: 34px 1fr 48px; }
.setrow--check { grid-template-columns: 34px 1fr 48px; }
.setrow__n { color: var(--txt-3); font-weight: 700; font-size: 14px; text-align: center; }
.setrow--done .setrow__n { color: var(--accent); }
.set-check {
  width: 48px; height: 48px; border-radius: 10px; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent; font-size: 18px; font-weight: 900;
}
.setrow--done .set-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Stepper */
.stepper { display: flex; align-items: stretch; height: var(--tap); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.stepper button { width: 48px; flex: 0 0 48px; font-size: 24px; font-weight: 700; color: var(--txt); display: grid; place-items: center; }
.stepper button:active { background: var(--surface-3); }
.stepper__val { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.stepper__val .n { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stepper__val .u { font-size: 10px; color: var(--txt-3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: -2px; }
.setrow--done .stepper { opacity: 0.6; }

/* RPE - 3 botones grandes */
.rpe {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px; margin-top: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.rpe__q { grid-column: 1 / -1; color: var(--txt-2); font-size: 14px; font-weight: 600; margin-bottom: 2px; text-align: center; }
.rpe button {
  min-height: 54px; border-radius: 11px; background: var(--surface-3);
  border: 1px solid var(--line); color: var(--txt);
  font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.rpe button small { color: var(--txt-3); font-size: 11px; font-weight: 600; margin-top: 2px; }
.rpe button:active { background: var(--line); }

/* Boton "ver ejercicio" dentro de card */
.exq__detail {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; width: 100%; margin-top: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--txt-2); font-weight: 600; font-size: 14px;
}
.solo-check {
  min-height: var(--tap); width: 100%; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--txt);
  font-weight: 700; font-size: 15px;
}
.setrow--done .solo-check, .solo-check.is-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Timer de descanso flotante ---------- */
.rest-timer {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bot));
  z-index: 40; padding: 0 12px 10px;
}
.rest-timer__inner {
  max-width: 616px; margin: 0 auto;
  background: var(--surface-3); border: 1px solid var(--accent);
  border-radius: 14px; padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.rest-timer__label { color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; align-self: center; }
.rest-timer__time { grid-row: 1 / 3; grid-column: 1; align-self: center; color: var(--accent); font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.rest-timer__btns { display: flex; gap: 8px; }
.rt-btn { flex: 1 1 auto; min-height: 48px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--txt); font-weight: 700; font-size: 14px; }
.rt-btn--skip { color: var(--txt-2); }
.rest-timer.done .rest-timer__inner { background: var(--accent); }
.rest-timer.done .rest-timer__label, .rest-timer.done .rest-timer__time { color: var(--accent-ink); }

/* ---------- Modal detalle ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal__panel {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + var(--safe-bot));
  -webkit-overflow-scrolling: touch;
}
.modal__close { position: absolute; top: 8px; right: 8px; width: 48px; height: 48px; font-size: 28px; color: var(--txt-2); }
.modal h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; padding-right: 40px; margin-bottom: 12px; }

.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1 1 auto; min-height: 48px; border-radius: 9px; color: var(--txt-2); font-weight: 700; font-size: 13px; }
.tabs button.active { background: var(--surface-3); color: var(--txt); }
.tabpane { display: none; }
.tabpane.active { display: block; }

.gif-wrap { background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; }
.gif-wrap img { display: block; width: 100%; height: auto; }
.gif-hint { color: var(--txt-3); font-size: 12px; margin-bottom: 12px; text-align: center; }
.videowrap { position: relative; padding-top: 56.25%; background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.videowrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-offline { padding: 22px 16px; text-align: center; color: var(--txt-2); font-size: 14px; }
.video-offline b { color: var(--txt); }
.list-clean li { padding: 7px 0 7px 20px; position: relative; color: var(--txt); }
.list-clean li::before { content: "\2013"; position: absolute; left: 2px; color: var(--txt-3); }
.cristiano { font-size: 16px; line-height: 1.55; color: var(--txt); }
.si-duele { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.si-duele h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--txt-2); margin-bottom: 6px; }
.si-duele .alt { font-weight: 700; font-size: 17px; margin-bottom: 4px; }

/* ---------- Guia (acordeones) ---------- */
.accordion { border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.accordion__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 16px; min-height: var(--tap); font-weight: 700; font-size: 16px; }
.accordion__head .chev { color: var(--txt-3); transition: transform .15s; }
.accordion.open .accordion__head .chev { transform: rotate(180deg); }
.accordion__body { display: none; padding: 0 16px 16px; color: var(--txt-2); font-size: 15px; line-height: 1.6; }
.accordion.open .accordion__body { display: block; }
.accordion__body p { margin-bottom: 10px; }
.accordion__body b, .accordion__body strong { color: var(--txt); }
.accordion__body a { color: var(--txt); text-decoration: underline; word-break: break-word; }
.source { display: block; margin-top: 8px; font-size: 13px; color: var(--txt-3); }
.source a { color: var(--txt-2); }

/* ---------- Progreso / charts ---------- */
.chart-card { padding: 16px; }
.chart-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.chart-card .cap { color: var(--txt-3); font-size: 12px; margin-bottom: 12px; }
.chart-canvas { width: 100%; height: 200px; display: block; }
.select-ex { width: 100%; min-height: var(--tap); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--txt); padding: 0 12px; font-size: 15px; margin-bottom: 12px; }
.empty { color: var(--txt-3); text-align: center; padding: 30px 12px; font-size: 14px; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  display: flex; background: rgba(13,15,18,.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--txt-3); font-size: 11px; font-weight: 600; }
.tab__ico { font-size: 15px; line-height: 1; }
.tab.active { color: var(--txt); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bot) + 16px);
  background: var(--surface-3); color: var(--txt);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; z-index: 70;
  max-width: 90%; text-align: center;
}

.hidden { display: none !important; }
