/* ===== Variables ===== */
:root {
  --bg:           #0D0D0D;
  --bg-card:      #1C1C1E;
  --bg-input:     #2C2C2E;
  --bg-input-focus: #3A3A3C;
  --accent:       #FF6B35;
  --accent-dim:   rgba(255, 107, 53, 0.15);
  --accent-dark:  #CC5429;
  --text:         #F2F2F7;
  --text-dim:     #8E8E93;
  --text-muted:   #636366;
  --success:      #30D158;
  --success-dim:  rgba(48, 209, 88, 0.15);
  --warning:      #FFD60A;
  --warning-dim:  rgba(255, 214, 10, 0.15);
  --danger:       #FF453A;
  --danger-dim:   rgba(255, 69, 58, 0.15);
  --border:       #38383A;
  --radius-sm:    10px;
  --radius:       16px;
  --radius-lg:    22px;
  --shadow:       0 4px 20px rgba(0,0,0,0.5);
  --nav-height:   70px;
  --header-height: 56px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ===== App Shell ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* ===== Header ===== */
.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.header-date {
  font-size: 13px;
  color: var(--text-dim);
}

.header-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  transition: color 0.2s;
}
.header-logout:hover { color: var(--danger); }

/* ===== Main Content ===== */
.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-content {
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  display: flex;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  padding: 8px 4px;
  transition: color 0.2s;
}

.nav-item.active { color: var(--accent); }

.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ===== Page Title ===== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-title-row .page-title { margin-bottom: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  border: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.btn-outline {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-input-focus); }

.btn-lg {
  height: 60px;
  font-size: 18px;
  border-radius: var(--radius-lg);
}

.btn-sm {
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-block { width: 100%; }
.mt-2 { margin-top: 12px; }

/* ===== Alerts ===== */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 500;
}
.alert-success { background: var(--success-dim); color: var(--success); border: 1px solid var(--success); }
.alert-danger   { background: var(--danger-dim);  color: var(--danger);  border: 1px solid var(--danger);  }
.alert-info     { background: var(--accent-dim);  color: var(--accent);  border: 1px solid var(--accent);  }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-muted   { background: var(--bg-input);    color: var(--text-muted); }

/* ===== Switch (botón deslizable) ===== */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.switch-label { font-size: 14px; color: var(--text); font-weight: 600; }
.switch-hint  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ===== Section ===== */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 13px;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 16px;
  line-height: 1.6;
}

.chevron { font-size: 22px; color: var(--text-muted); margin-left: 8px; }
.text-accent { color: var(--accent); }

/* ===========================
   PIN PAGE
   =========================== */
.pin-page {
  /* Halo naranja sutil arriba + reflejo tenue abajo sobre el fondo base */
  background:
    radial-gradient(ellipse 90% 55% at 50% -12%, rgba(255, 107, 53, 0.14), transparent 62%),
    radial-gradient(ellipse 70% 45% at 50% 112%, rgba(255, 107, 53, 0.06), transparent 60%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.pin-container {
  width: 100%;
  max-width: 360px;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pin-enter 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pin-enter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pin-header { text-align: center; margin-bottom: 28px; }

/* Logo como "ícono de app": placa redondeada con borde y glow del acento */
.pin-logo {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  border-radius: 26px;
  background: linear-gradient(145deg, #2A2A2E 0%, #1C1C1E 100%);
  border: 1px solid rgba(255, 107, 53, 0.35);
  box-shadow:
    0 0 0 6px rgba(255, 107, 53, 0.07),
    0 18px 40px -12px rgba(255, 107, 53, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.pin-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent); /* fallback si background-clip no está soportado */
  background: linear-gradient(120deg, #FF8A5C 0%, var(--accent) 55%, #E85D25 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Variante para la página de bloqueo: título rojo plano, sin gradiente */
.pin-title-danger {
  background: none;
  color: var(--danger);
  -webkit-text-fill-color: var(--danger);
}

.pin-subtitle {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 0.2px;
}

.pin-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  text-align: center;
  font-size: 15px;
  width: 100%;
}

/* PIN dots */
.pin-dots {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-bottom: 36px;
}

.pin-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.18s, border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.55);
}

/* Keypad */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  grid-template-rows: repeat(4, 78px);
  gap: 16px;
  justify-content: center;
}

.key-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  /* Relieve sutil: brillo arriba que se apaga hacia abajo, sobre el fondo card */
  background: linear-gradient(145deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015)), var(--bg-card);
  color: var(--text);
  font-size: 30px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: background 0.12s, transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:active {
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent);
  transform: scale(0.92);
  box-shadow: 0 0 22px rgba(255, 107, 53, 0.45);
  color: #fff;
}

.key-back { font-size: 26px; color: var(--text-dim); }
.key-empty { width: 78px; height: 78px; background: transparent; border: none; box-shadow: none; }

/* Botón de ingreso biométrico */
.bio-btn {
  display: none; /* el JS lo pasa a flex si el dispositivo soporta biometría */
  margin-top: 26px;
  width: 100%;
  height: 54px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  gap: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.bio-btn:active { border-color: var(--accent); background: var(--bg-input); }
.bio-btn svg { color: var(--accent); flex-shrink: 0; }

.pin-help {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* Shake animation for wrong PIN */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.shake { animation: shake 0.4s ease; }

/* ===========================
   DASHBOARD
   =========================== */
.hero-card {
  background: linear-gradient(135deg, #1C1C2E 0%, #2D1B1B 100%);
  border: 1px solid rgba(255,107,53,0.3);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 24px;
  text-align: center;
}

.hero-date {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}

.hero-subtitle {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.hero-done {
  font-size: 16px;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 4px;
}

.hero-in-progress {
  font-size: 15px;
  color: var(--warning);
  font-weight: 600;
  margin-bottom: 4px;
}

/* Suggestion cards */
.suggestion-list { display: flex; flex-direction: column; gap: 10px; }

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,214,10,0.3);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.suggestion-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.suggestion-detail {
  font-size: 14px;
  color: var(--text-dim);
}

/* Recent sessions */
.session-list { display: flex; flex-direction: column; gap: 1px; }

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 16px;
  color: var(--text);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.session-item-left { display: flex; flex-direction: column; gap: 2px; }
.session-item-date { font-size: 16px; font-weight: 600; }
.session-item-info { font-size: 13px; color: var(--text-dim); }

.session-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===========================
   CALENDAR
   =========================== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.cal-nav-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.cal-nav-btn:hover  { background: var(--bg-input); color: var(--text); }
.cal-nav-btn:active { background: var(--accent-dim); color: var(--accent); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 8px;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  position: relative;
}

.cal-today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-has-session {
  background: var(--accent-dim);
}

.cal-cell-link {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 8px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.cal-cell-link:active { background: rgba(255,107,53,0.35); }

.cal-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  line-height: 1;
}

.cal-today .cal-num          { color: var(--accent); font-weight: 800; }
.cal-has-session .cal-num    { color: var(--accent); font-weight: 700; }
.cal-future .cal-num         { color: var(--text-muted); }

.cal-dot {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-dot-done     { background: var(--success); }
.cal-dot-wip      { background: var(--warning); }
.cal-dot-fee-paid {
  background: transparent;
  border: 2px solid var(--success);
  width: 7px;
  height: 7px;
}

.cal-fee-paid { background: var(--success); }
.cal-fee-paid .cal-num { color: #000; font-weight: 800; }
.cal-fee-paid .cal-dot-fee-paid { border-color: #000; }

.cal-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 2px 2px;
  font-size: 12px;
  color: var(--text-dim);
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ===========================
   SESSION PAGE
   =========================== */
.session-header { margin-bottom: 20px; }
.session-hint { font-size: 14px; color: var(--text-dim); margin-top: -10px; margin-bottom: 4px; }

/* Exercise Cards */
.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.exercise-card.all-saved {
  border-color: var(--success);
}

.exercise-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ex-number-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exercise-card.all-saved .ex-number-badge {
  background: var(--success-dim);
  color: var(--success);
}

.ex-info { flex: 1; min-width: 0; }
.ex-name { font-size: 16px; font-weight: 600; }
.ex-muscle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.ex-prev-summary { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.ex-note-preview { font-size: 12px; color: var(--text-dim); margin-top: 3px; font-style: italic; }

.ex-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.check-badge { font-size: 18px; color: var(--success); }
.up-badge    { font-size: 16px; }
.chevron-icon {
  font-size: 15px;
  color: var(--text-muted);
  margin-left: 14px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Exercise Body */
.exercise-body { padding: 0 16px 16px; }
.exercise-body.collapsed { display: none; }

.ex-history-row {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-top: 4px;
}
.ex-history-label { margin-right: 6px; }
.ex-history-vals { color: var(--text); font-weight: 500; }

.suggestion-banner {
  border-left: 3px solid rgba(255,214,10,0.6);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  color: rgba(255,214,10,0.85);
  margin-bottom: 10px;
}
.sugg-days { font-size: 12px; opacity: 0.7; }

/* Sets */
.sets-container { display: flex; flex-direction: column; gap: 10px; }

.sets-header {
  display: grid;
  grid-template-columns: 44px 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 0 4px;
}

.set-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr;
  gap: 8px;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: 0 -4px;
  transition: background 0.15s;
}

/* Serie marcada como hecha: se resalta toda la fila en verde */
.set-row.done {
  background: var(--success-dim);
}

/* Tocar la etiqueta de la serie (S1, S2...) la marca como hecha: evita agregar
   una columna más al grid, que en pantallas chicas deja muy poco espacio a los
   controles de peso/reps */
.set-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.set-label.done {
  background: var(--success-dim);
  color: var(--success);
}

/* Weight control */
.weight-control, .reps-control {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 52px;
}

.wbtn, .rbtn {
  width: 44px;
  height: 52px;
  font-size: 22px;
  font-weight: 300;
  color: var(--text);
  background: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.wbtn:active, .rbtn:active { background: var(--accent-dim); }

.weight-input, .reps-input {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  width: 0;
  min-width: 0;
  outline: none;
  -moz-appearance: textfield;
}

.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button,
.reps-input::-webkit-outer-spin-button,
.reps-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* Serie extra: agregada circunstancialmente, por encima de la cantidad normal del ejercicio */
.set-row-extra {
  background: var(--warning-dim);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  margin: 0 -4px;
}
.set-row-extra.done { background: var(--success-dim); }
.set-row-extra .set-label { color: var(--warning); }
.set-row-extra .set-label.done { background: var(--success-dim); color: var(--success); }

.set-extra-remove {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-val-extra { color: var(--warning); font-weight: 700; }

/* Comentario por ejercicio */
.ex-note-field { margin-top: 14px; }
.ex-note-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.ex-note-textarea {
  width: 100%;
  min-height: 60px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.ex-note-textarea:focus { outline: 2px solid var(--accent); }

/* Session actions */
.session-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 8px;
}

.btn-done {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid var(--success);
}
.btn-done:hover { background: rgba(48, 209, 88, 0.25); }

/* ===========================
   EXERCISES MANAGEMENT
   =========================== */
.exercise-manage-list { display: flex; flex-direction: column; gap: 8px; }

/* Acordeón de ejercicios agrupados por categoría (exercises.php, routine_edit.php) */
.ex-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
    margin-bottom: 6px;
}
.ex-group-header:active { background: var(--bg-input); }

.ex-group-name {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    flex: 1;
    text-align: left;
}
.ex-group-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    border-radius: 20px;
    padding: 2px 9px;
}
.ex-group-chevron {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    display: inline-block;
}
.ex-group-header.collapsed .ex-group-chevron { transform: rotate(-90deg); }

.ex-group-body {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 4000px;
    opacity: 1;
    padding-left: 14px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
}
.ex-group-body.collapsed {
    max-height: 0 !important;
    opacity: 0;
}
.ex-group { margin-bottom: 8px; }

.ex-group-stats-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: none;
  border-radius: 20px;
  padding: 6px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.ex-group-stats-btn:active { background: var(--accent-dark); color: var(--text); }

/* ===========================
   MONTHLY STATS MODAL
   =========================== */
.stats-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.stats-modal-overlay.open { display: flex; }

.stats-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: statsModalIn 0.2s ease;
}
@keyframes statsModalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stats-modal-title { font-size: 18px; font-weight: 700; }
.stats-modal-close {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stats-modal-hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 18px; }

.stats-chart { display: flex; flex-direction: column; gap: 14px; }

.stats-bar-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 10px;
}

.stats-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-bar-track {
  background: var(--bg);
  border-radius: 20px;
  height: 18px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.15s ease;
}
.stats-bar-row:hover .stats-bar-fill { filter: brightness(1.15); }

.stats-bar-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  min-width: 40px;
}
.stats-bar-value strong { font-size: 14px; font-weight: 700; }
.stats-bar-value span { font-size: 11px; color: var(--text-muted); }

/* ===========================
   CONFIRM MODAL
   =========================== */
.confirm-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-modal-overlay.open { display: flex; }

.confirm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: statsModalIn 0.2s ease;
  text-align: center;
}

.confirm-modal-message {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 20px;
  white-space: pre-line;
}

.confirm-modal-actions { display: flex; gap: 10px; }
.confirm-modal-actions .btn { flex: 1; }
.confirm-modal-yes { background: var(--danger); }
.confirm-modal-yes.confirm-modal-yes-positive { background: var(--accent); }

/* ===========================
   SESSION SUMMARY MODAL
   =========================== */
.session-summary-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.session-summary-overlay.open { display: flex; }

.session-summary-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 22px 22px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: statsModalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}

.session-summary-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }

.session-summary-headline {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.session-summary-sub { font-size: 14px; color: var(--text-dim); margin-bottom: 22px; }

.session-summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.session-summary-stat {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 14px 4px;
}

.session-summary-stat-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}

.session-summary-stat-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

.session-summary-progress {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 22px;
  text-align: left;
}
.session-summary-progress.is-positive { background: var(--success-dim); border: 1px solid var(--success); }
.session-summary-progress.is-neutral  { background: var(--accent-dim);  border: 1px solid var(--accent); }

.session-summary-progress-title {
  font-size: 15px;
  font-weight: 800;
}
.session-summary-progress.is-positive .session-summary-progress-title { color: var(--success); }
.session-summary-progress.is-neutral  .session-summary-progress-title { color: var(--accent); }

.session-summary-progress-list {
  list-style: none;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-summary-progress-list li {
  font-size: 13px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.session-summary-progress-list li span { color: var(--text-dim); }
.session-summary-progress-list li strong { color: var(--success); font-weight: 700; white-space: nowrap; }

.exercise-manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: opacity 0.2s;
}

.exercise-manage-item.inactive { opacity: 0.5; }

.drag-handle {
  font-size: 22px;
  color: var(--text-dim);
  cursor: grab;
  padding: 4px 6px;
  flex-shrink: 0;
  user-select: none;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.exercise-manage-item.drag-ghost {
  opacity: 0.4;
  background: var(--bg-input);
}

.ex-manage-info { flex: 1; min-width: 0; }
.ex-manage-name { font-size: 16px; font-weight: 600; }
.ex-manage-muscle { font-size: 12px; color: var(--text-dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ex-manage-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-input);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.action-btn:hover { background: var(--bg-input-focus); }

/* ===========================
   EXERCISE EDIT FORM
   =========================== */
.edit-form { display: flex; flex-direction: column; gap: 16px; }

/* Selector polea / peso libre */
.type-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.type-toggle-option {
  cursor: pointer;
}

.type-toggle-option input[type="radio"] {
  display: none;
}

.type-toggle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.type-toggle-option.selected .type-toggle-card,
.type-toggle-option input:checked + .type-toggle-card {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.type-toggle-icon  { font-size: 32px; line-height: 1; }
.type-toggle-title { font-size: 15px; font-weight: 700; }
.type-toggle-sub   { font-size: 12px; color: var(--text-dim); }

/* Badge "Polea" en el detalle */
.pulley-badge {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 6px;
  font-weight: 400;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 14px 16px;
  font-size: 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E8E93' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
  padding-top: 12px;
}

.form-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.form-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.form-section-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.defaults-table { display: flex; flex-direction: column; gap: 12px; }

.series-count-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.series-count-display {
  font-size: 24px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: var(--text);
}

.defaults-header {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

.defaults-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.defaults-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}
.form-actions .btn { flex: 1; }

/* ===========================
   HISTORY
   =========================== */
.history-list { display: flex; flex-direction: column; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  color: var(--text);
  transition: background 0.15s;
}
.history-item:hover { background: var(--bg-input); }

.history-item-left { display: flex; align-items: center; gap: 14px; }

.history-date-box { text-align: center; min-width: 44px; }
.history-day { font-size: 24px; font-weight: 800; line-height: 1; }
.history-dow { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.history-routine   { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.history-exercises { font-size: 16px; font-weight: 600; }
.history-volume    { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.history-duration  { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.history-item-right { display: flex; align-items: center; gap: 8px; }

/* ===========================
   SESSION DETAIL
   =========================== */
.detail-header { margin-bottom: 20px; }

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 8px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.detail-volume {
  font-size: 14px;
  color: var(--text-dim);
}

.detail-times {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.detail-exercises { display: flex; flex-direction: column; gap: 12px; }

.detail-exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-ex-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-ex-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.detail-ex-name   { font-size: 15px; font-weight: 600; }
.detail-ex-muscle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.detail-sets { padding: 12px 16px; }

.detail-sets-header {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.detail-set-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.detail-set-row:last-child { border-bottom: none; }

.detail-set-row.set-row-extra {
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}
.detail-set-row.set-row-extra span:first-child { color: var(--warning); }

/* ===========================
   PROGRESS PAGE
   =========================== */

/* Rankings: dos columnas lado a lado */
.progress-rankings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.rank-col { display: flex; flex-direction: column; gap: 8px; }

.rank-col-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.rank-col-best  { color: var(--success); }
.rank-col-worst { color: var(--warning); }

.rank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
}
.rank-card-best  { border-left: 3px solid var(--success); }
.rank-card-worst { border-left: 3px solid var(--warning); }

.rank-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.rank-weights {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.rank-pct {
  font-size: 12px;
  font-weight: 700;
}
.rank-pct-best  { color: var(--success); }
.rank-pct-worst { color: var(--warning); }

/* Chips de selección de ejercicio */
.exercise-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.exercise-chips::-webkit-scrollbar { display: none; }

.exercise-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.exercise-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Contenedor del gráfico canvas */
.chart-wrapper {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

#progressChart {
  display: block;
}

/* Tooltip al tocar un punto */
.chart-tooltip {
  position: absolute;
  background: rgba(20,20,22,0.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Resumen bajo el gráfico */
.chart-info { text-align: center; padding: 4px 0 8px; }
.chart-info-text { font-size: 13px; color: var(--text-dim); }

/* Toast de guardado (session_detail edit mode) */
.save-toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(20,20,22,0.96);
  border: 1px solid var(--success);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}
.save-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .cal-header,
  .cal-grid,
  .cal-footer {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
  .cal-header { margin-bottom: 14px; }
  .cal-footer { margin-top: 10px; }
}

@media (min-width: 480px) {
  .session-actions {
    flex-direction: row;
  }
  .session-actions .btn {
    flex: 1;
  }
  .keypad {
    grid-template-columns: repeat(3, 90px);
    grid-template-rows: repeat(4, 90px);
  }
  .key-btn, .key-empty { width: 90px; height: 90px; }
}

/* Orden de rutinas: desktop vs mobile */
.drag-handle-mobile  { display: none; }
.order-hint-mobile   { display: none; }

@media (max-width: 599px) {
  .drag-handle-mobile  { display: flex; align-items: center; }
  .order-hint-mobile   { display: block; }
  .order-btns-desktop  { display: none; }
  .order-hint-desktop  { display: none; }
}

@media (prefers-color-scheme: light) {
  /* La app usa tema oscuro siempre para mayor legibilidad en el gym */
}
