/* GRIT — mobile-first dark UI (estilo Heria Pro) */
:root {
  --bg: #0B0B0D;
  --card: #17171B;
  --card2: #1F1F25;
  --line: #2A2A32;
  --text: #F5F5F7;
  --muted: #9B9BA6;
  --accent: #D4FF3F;
  --accent-dim: rgba(212, 255, 63, 0.14);
  --danger: #FF5A5F;
  --red: #E8261F;
  --ok: #4CD97B;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

#app { max-width: 560px; margin: 0 auto; }

#view {
  padding: calc(18px + var(--safe-top)) 18px calc(96px + var(--safe-bottom));
  min-height: 100dvh;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: flex;
  background: rgba(15, 15, 18, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  z-index: 50;
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 6px 0; cursor: pointer;
}
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.active { color: var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card.tappable:active { transform: scale(0.98); transition: transform .1s; }

.row { display: flex; align-items: center; gap: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.grow { flex: 1; }

/* ---------- Home ---------- */
.home-header { margin-bottom: 18px; }
.home-header .date { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }

.streak-card {
  background: linear-gradient(135deg, #1C1F0E 0%, var(--card) 60%);
  border: 1px solid rgba(212, 255, 63, 0.25);
  display: flex; align-items: center; gap: 16px;
}
.streak-flame { font-size: 42px; line-height: 1; }
.streak-num { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1; }
.streak-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.today-card { border: 1px solid var(--line); }
.today-tag {
  display: inline-block; background: var(--accent-dim); color: var(--accent);
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px; margin-bottom: 10px;
}
.today-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.today-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.btn {
  display: block; width: 100%; text-align: center;
  background: var(--accent); color: #0B0B0D;
  border: none; border-radius: 14px;
  font-size: 16px; font-weight: 800;
  padding: 15px; cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.small-btn { padding: 10px 14px; font-size: 13px; width: auto; display: inline-block; border-radius: 10px; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px; text-align: center;
}
.stat .v { font-size: 22px; font-weight: 800; color: var(--text); }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* Reminders */
.reminder { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.reminder:last-child { border-bottom: none; }
.reminder .check {
  width: 24px; height: 24px; min-width: 24px; border-radius: 8px;
  border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 14px; font-weight: 800; cursor: pointer;
}
.reminder.done .check { background: var(--accent); border-color: var(--accent); color: #0B0B0D; }
.reminder.done .txt { color: var(--muted); text-decoration: line-through; }
.reminder .del { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.add-reminder { display: flex; gap: 8px; margin-top: 12px; }
.add-reminder input {
  flex: 1; background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 14px; outline: none;
}

/* ---------- Programs ---------- */
.program-card { position: relative; overflow: hidden; cursor: pointer; }
.program-card .level {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 6px;
}
.program-card h3 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.program-card .desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
}
.badge.active-badge { background: var(--accent-dim); border-color: rgba(212,255,63,.3); color: var(--accent); }

.back-btn {
  background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 700;
  cursor: pointer; padding: 0; margin-bottom: 14px; display: inline-flex; align-items: center; gap: 4px;
}

.day-card { cursor: pointer; }
.day-card .num {
  width: 44px; height: 44px; min-width: 44px; border-radius: 12px;
  background: var(--card2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.day-card.next .num { background: var(--accent); color: #0B0B0D; border-color: var(--accent); }
.day-card.done-cycle .num { background: rgba(76,217,123,.15); color: var(--ok); border-color: rgba(76,217,123,.3); }
.day-card h4 { font-size: 16px; font-weight: 700; }
.day-card .focus { color: var(--muted); font-size: 12px; margin-top: 2px; }
.chev { color: var(--muted); font-size: 20px; }

/* Routine detail */
.exercise-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.exercise-row:last-child { border-bottom: none; }
.exercise-row .idx {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  background: var(--card2); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.exercise-row .name { font-weight: 700; font-size: 15px; }
.exercise-row .detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.sticky-cta {
  position: fixed; bottom: calc(78px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  width: calc(100% - 36px); max-width: 524px; z-index: 40;
}
.sticky-cta .btn { box-shadow: 0 8px 30px rgba(0,0,0,.55); }

/* ---------- Player ---------- */
.player {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  max-width: 560px; margin: 0 auto;
}
.player.hidden, .hidden { display: none !important; }

/* Header estilo Heria: X | cronometro | pausa + sonido */
.ph-top { display: flex; align-items: center; margin-bottom: 12px; }
.ph-left, .ph-right { display: flex; gap: 8px; flex: 1; }
.ph-right { justify-content: flex-end; }
.ph-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card2); border: none; color: var(--text);
  font-size: 18px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ph-timer {
  font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums;
  letter-spacing: -1px; text-align: center;
}
.ph-timer.paused { color: var(--muted); }

.progress-track { height: 4px; background: var(--card2); border-radius: 99px; margin-bottom: 14px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--red); border-radius: 99px; transition: width .3s ease; }

/* Panel de media (placeholder de video) */
.ph-media {
  background: linear-gradient(160deg, #1E1E24 0%, #121216 100%);
  border-radius: 14px; aspect-ratio: 16/10;
  display: flex; align-items: center; justify-content: center;
  position: relative; margin-bottom: 8px; overflow: hidden;
}
.ph-media svg { width: 72px; height: 72px; fill: #3A3A44; }
.ph-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph-media .tag {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  background: #000; color: #fff; font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; padding: 4px 8px; border-radius: 4px;
}

.ph-info { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 0; }
.ph-big { font-size: 52px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.ph-big.timed { font-variant-numeric: tabular-nums; font-size: 72px; }
.ph-name { color: var(--muted); font-size: 24px; font-weight: 700; margin-top: 6px; }
.ph-set { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-top: 12px; }

/* Descanso: panel que se drena de rojo con el tiempo */
.ph-rest {
  flex: 1; background: #26262B; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  min-height: 0; margin-bottom: 8px;
  position: relative; overflow: hidden;
}
.ph-rest-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background: var(--red);
}
.ph-rest-num { position: relative; z-index: 1; font-size: 130px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -4px; }

/* NEXT UP sheet */
.ph-sheet { background: #141418; border-radius: 18px 18px 0 0; margin: 0 -20px calc(0px - var(--safe-bottom)); padding: 16px 20px calc(20px + var(--safe-bottom)); }
.ph-nextlabel {
  font-size: 13px; font-weight: 800; letter-spacing: 2px; color: var(--text);
  padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.ph-nextrow { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ph-thumb {
  width: 76px; height: 56px; min-width: 76px; border-radius: 8px;
  background: var(--card2); display: flex; align-items: center; justify-content: center;
}
.ph-thumb svg { width: 28px; height: 28px; fill: #4A4A55; }
.ph-thumb { overflow: hidden; }
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ex-thumb { width: 64px; height: 46px; min-width: 64px; border-radius: 8px; object-fit: cover; }
.ph-nextname { font-size: 17px; font-weight: 800; }
.ph-nextmeta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.btn.red { background: var(--red); color: #fff; }
.ph-rest-actions { display: flex; gap: 10px; }
.ph-rest-actions .btn.ghost { flex: 0 0 76px; padding: 15px 0; }
.ph-rest-actions .btn.red { flex: 1; }

.player-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.player-actions { display: flex; gap: 10px; margin-top: 10px; }
.player-actions .btn { flex: 1; }

/* Contenedor con scroll para pantallas largas (ej. resumen con ajustes) */
.player-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.player-scroll .player-body { min-height: 100%; justify-content: center; padding: 10px 0; }

/* Confirmar reps de la serie */
.rep-q { font-size: 18px; font-weight: 700; color: var(--muted); margin-bottom: 14px; }
.rep-stepper { display: flex; align-items: center; gap: 22px; }
.rep-btn {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  font-size: 30px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rep-btn:active { transform: scale(0.92); }
.rep-num { font-size: 76px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 130px; text-align: center; line-height: 1; }

/* Ajustes del motor en pantalla final */
.adj-list { margin-top: 18px; width: 100%; }
.adj-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; text-align: left; }
.adj-main { font-size: 14.5px; }
.adj-why { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.adj-badge {
  background: var(--accent-dim); color: var(--accent);
  font-size: 10.5px; font-weight: 800; padding: 1px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .5px;
}
.perf { color: var(--muted); }

/* Detalle workout: bloques ROUND */
.round-head { font-size: 15px; font-weight: 800; letter-spacing: 1px; margin: 18px 0 8px; }
.round-head span { color: var(--muted); font-weight: 600; letter-spacing: 0; font-size: 13px; }
.rest-band {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  text-align: center; color: var(--muted); font-size: 12px; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase; padding: 10px; margin: 14px 0;
}

/* Done screen */
.done-emoji { font-size: 64px; margin-bottom: 16px; }
.done-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.done-stats { display: flex; gap: 24px; margin: 20px 0; }
.done-stats .stat { border: none; background: var(--card); padding: 14px 20px; }

/* ---------- History ---------- */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-header button { background: var(--card2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; width: 36px; height: 36px; font-size: 16px; cursor: pointer; }
.cal-title { font-weight: 800; font-size: 16px; text-transform: capitalize; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; padding: 6px 0; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--text); position: relative;
}
.cal-day.other { color: #4A4A55; }
.cal-day.today { border: 1.5px solid var(--accent); }
.cal-day.trained { background: var(--accent); color: #0B0B0D; font-weight: 800; }

.session-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.session-row:last-child { border-bottom: none; }
.session-row .dot { width: 10px; height: 10px; min-width: 10px; border-radius: 50%; background: var(--accent); }
.session-row .title { font-weight: 700; font-size: 15px; }
.session-row .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.session-row .dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

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

/* Toast */
.toast {
  position: fixed; bottom: calc(100px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 99px; font-size: 14px; font-weight: 600;
  z-index: 200; white-space: nowrap; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
