/* ========================================================
   Gym Tracker - Apple Design System (iOS / Apple Fitness / Hevy)
   ======================================================== */

:root {
  /* Apple iOS Palette */
  --apple-bg: #000000;
  --apple-bg-secondary: #0a0a0c;
  --apple-card: rgba(28, 28, 30, 0.85);
  --apple-card-solid: #1c1c1e;
  --apple-card-elevated: rgba(44, 44, 46, 0.88);
  --apple-input: rgba(44, 44, 46, 0.75);
  --apple-border: rgba(255, 255, 255, 0.08);
  --apple-border-focus: rgba(10, 132, 255, 0.6);

  /* Apple Fitness / Activity Ring Accents */
  --apple-green: #30D158;
  --apple-green-glow: rgba(48, 209, 88, 0.25);
  --apple-blue: #0A84FF;
  --apple-blue-glow: rgba(10, 132, 255, 0.25);
  --apple-coral: #FF453A;
  --apple-coral-glow: rgba(255, 69, 58, 0.25);
  --apple-amber: #FF9F0A;
  --apple-amber-glow: rgba(255, 159, 10, 0.25);
  --apple-purple: #BF5AF2;
  --apple-teal: #5DE2E7;

  /* Typography */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.38);

  /* Set Types */
  --type-normal: var(--apple-blue);
  --type-warmup: var(--apple-amber);
  --type-failure: var(--apple-coral);
  --type-dropset: var(--apple-purple);

  /* Dimensions & Radius - Hevy Compact */
  --radius-card: 18px;
  --radius-button: 12px;
  --radius-input: 10px;
  --radius-pill: 9999px;

  /* Transitions */
  --spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.18s var(--spring);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "SF Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--apple-bg);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: calc(82px + env(safe-area-inset-bottom, 20px));
  position: relative;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(48, 209, 88, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 100% 15%, rgba(10, 132, 255, 0.05) 0%, transparent 35%);
  background-attachment: fixed;
}

/* ========================================================
   Apple Sticky Navigation Bar
   ======================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--apple-border);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1c1c1e, #2c2c2e);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-icon svg {
  width: 16px;
  height: 16px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title span {
  color: var(--apple-green);
  font-weight: 800;
}

.brand-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}

/* User Capsule / Profile Badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: var(--radius-pill);
  padding: 3px 10px 3px 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-badge:hover {
  background: var(--apple-card-elevated);
}

.user-badge:active {
  transform: scale(0.96);
}

.user-badge img.avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--apple-green);
}

.user-badge .avatar-initials {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--apple-green), #28cd41);
  color: #000;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-badge .user-name {
  font-size: 0.8rem;
  font-weight: 500;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge.guest-badge {
  background: rgba(10, 132, 255, 0.12);
  border-color: rgba(10, 132, 255, 0.3);
  color: var(--apple-blue);
  font-weight: 600;
  padding: 5px 12px;
}

/* ========================================================
   Apple Dynamic Island - Floating Rest Timer
   ======================================================== */
.dynamic-island-timer {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 105;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8), 0 0 16px var(--apple-amber-glow);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: islandDrop 0.3s var(--spring);
  backdrop-filter: blur(20px);
}

@keyframes islandDrop {
  0% { transform: translateX(-50%) translateY(-25px) scale(0.9); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

.timer-ring-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--apple-amber);
  box-shadow: 0 0 8px var(--apple-amber);
  animation: timerPulse 1.5s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.timer-content {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.timer-content strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 700;
}

.island-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.island-btn:hover { background: rgba(255, 255, 255, 0.22); }
.island-btn:active { transform: scale(0.94); }

/* ========================================================
   Main Content Layout (Hevy Compact 500px)
   ======================================================== */
.app-content {
  padding: 16px 14px;
  max-width: 500px;
  margin: 0 auto;
}

.view-section {
  animation: fadeIn 0.25s var(--spring);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========================================================
   Apple Cards & Components (Compact)
   ======================================================== */
.card {
  background: var(--apple-card);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--apple-border);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.card-hero {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, rgba(32, 32, 35, 0.9) 0%, rgba(18, 18, 20, 0.9) 100%);
}

.card-hero .hero-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.card-hero h3 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.card-hero p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 18px;
  line-height: 1.4;
}

/* ========================================================
   Active Workout Header & Controls (Pausar, Descartar)
   ======================================================== */
.workout-header-card {
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.98), rgba(40, 40, 44, 0.98));
  border: 1px solid rgba(48, 209, 88, 0.35);
  box-shadow: 0 0 16px rgba(48, 209, 88, 0.08);
  padding: 14px;
}

.workout-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.input-title {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  width: 100%;
  outline: none;
  letter-spacing: -0.01em;
}

.timer-badge {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
  border: 1px solid rgba(48, 209, 88, 0.4);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.timer-badge.paused {
  background: rgba(255, 159, 10, 0.15);
  color: var(--apple-amber);
  border-color: rgba(255, 159, 10, 0.4);
}

.timer-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: timerPulse 1.2s infinite;
}

/* Control buttons: Pausar, Descartar */
.workout-controls-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ctrl {
  padding: 9px 12px;
  border-radius: var(--radius-button);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--apple-border);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.btn-ctrl:active { transform: scale(0.96); }

.btn-ctrl-pause {
  background: rgba(255, 159, 10, 0.15);
  color: var(--apple-amber);
  border-color: rgba(255, 159, 10, 0.35);
}

.btn-ctrl-pause.active-paused {
  background: var(--apple-amber);
  color: #000;
  font-weight: 700;
}

.btn-ctrl-discard {
  background: rgba(255, 69, 58, 0.15);
  color: var(--apple-coral);
  border-color: rgba(255, 69, 58, 0.35);
}

.btn-ctrl-discard:hover {
  background: rgba(255, 69, 58, 0.25);
}

/* Banner de pausa */
.pause-banner {
  background: linear-gradient(90deg, rgba(255, 159, 10, 0.2), rgba(255, 159, 10, 0.1));
  border: 1px solid rgba(255, 159, 10, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pause-banner span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--apple-amber);
}

/* ========================================================
   Cola / Barra de Ejercicios de la Rutina Activa (Hevy Style)
   ======================================================== */
.routine-queue-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.routine-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.btn-mini-add {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
  border: 1px solid rgba(48, 209, 88, 0.3);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.routine-queue-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.routine-queue-chips::-webkit-scrollbar { display: none; }

.queue-chip {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--apple-border);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

.queue-chip.active {
  background: rgba(10, 132, 255, 0.2);
  color: #fff;
  border-color: var(--apple-blue);
  box-shadow: 0 0 10px rgba(10, 132, 255, 0.2);
}

.queue-chip.completed {
  border-color: rgba(48, 209, 88, 0.5);
  color: var(--apple-green);
}

/* ========================================================
   Compact Exercise Header & Small GIF Preview
   ======================================================== */
.exercise-compact-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.gif-thumb-small {
  width: 78px;
  height: 78px;
  min-width: 78px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.gif-thumb-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exercise-compact-meta {
  flex: 1;
}

.exercise-compact-meta h3 {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 3px;
}

.exercise-compact-meta .meta-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

/* Target Sets Banner & Extra Set */
.target-sets-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--apple-border);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 10px;
  font-size: 0.78rem;
}

.btn-extra-set {
  background: rgba(10, 132, 255, 0.15);
  color: var(--apple-blue);
  border: 1px solid rgba(10, 132, 255, 0.3);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-extra-set:hover { background: rgba(10, 132, 255, 0.25); }

/* ========================================================
   Configuración de Temporizador de Descanso
   ======================================================== */
.rest-time-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--apple-border);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.rest-picker-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.rest-chips {
  display: flex;
  gap: 4px;
}

.rest-chip-btn {
  background: var(--apple-input);
  border: 1px solid var(--apple-border);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.rest-chip-btn.active {
  background: var(--apple-amber);
  color: #000000;
  border-color: var(--apple-amber);
  font-weight: 700;
}

/* ========================================================
   Buttons & Inputs (Hevy Touch)
   ======================================================== */
.btn {
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-button);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--apple-green);
  color: #000000;
  font-weight: 700;
}
.btn-primary:hover { background: #34e060; }

.btn-secondary {
  background: var(--apple-card-elevated);
  color: #FFFFFF;
  border: 1px solid var(--apple-border);
}

.btn-accent {
  background: var(--apple-blue);
  color: #FFFFFF;
}

.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--apple-coral);
  border: 1px solid rgba(255, 69, 58, 0.3);
}

.input-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-text, .input-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--apple-input);
  border: 1px solid var(--apple-border);
  color: #FFFFFF;
  border-radius: var(--radius-input);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.input-text:focus, .input-select:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
}

.input-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.input-select option {
  background-color: #1c1c1e;
  color: #fff;
}

/* Selector de tipo de serie */
.set-type-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.set-pill-btn {
  background: var(--apple-input);
  border: 1px solid var(--apple-border);
  padding: 6px 2px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.set-pill-btn.active-normal {
  background: rgba(10, 132, 255, 0.2);
  border-color: var(--apple-blue);
  color: var(--apple-blue);
}
.set-pill-btn.active-warmup {
  background: rgba(255, 159, 10, 0.2);
  border-color: var(--apple-amber);
  color: var(--apple-amber);
}
.set-pill-btn.active-failure {
  background: rgba(255, 69, 58, 0.2);
  border-color: var(--apple-coral);
  color: var(--apple-coral);
}
.set-pill-btn.active-dropset {
  background: rgba(191, 90, 242, 0.2);
  border-color: var(--apple-purple);
  color: var(--apple-purple);
}

/* ========================================================
   Apple Intelligence - Progressive Overload Card (Compact)
   ======================================================== */
.overload-box {
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.1), rgba(10, 132, 255, 0.06));
  border: 1px solid rgba(48, 209, 88, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.overload-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--apple-green);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.overload-content {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.35;
}

.overload-content strong { color: #fff; }
.overload-content small { display: block; color: var(--text-secondary); font-size: 0.78rem; margin-top: 2px; }

/* Formulario de Registro de Serie */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; }
.field label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.input-number-wrap .input-text {
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 8px 4px;
}

/* Tabla de Series (Hevy Compact) */
.sets-table-card {
  overflow-x: auto;
  border-radius: 14px;
  background: var(--apple-card-solid);
  margin-top: 12px;
  border: 1px solid var(--apple-border);
}

.sets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sets-table th {
  padding: 9px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--apple-border);
  text-align: center;
}

.sets-table td {
  padding: 9px 8px;
  text-align: center;
  border-bottom: 1px solid var(--apple-border);
  font-variant-numeric: tabular-nums;
}

.sets-table tr:last-child td { border-bottom: none; }

.set-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
}

.badge-normal { background: rgba(10, 132, 255, 0.15); color: var(--apple-blue); }
.badge-warmup { background: rgba(255, 159, 10, 0.15); color: var(--apple-amber); }
.badge-failure { background: rgba(255, 69, 58, 0.15); color: var(--apple-coral); }
.badge-dropset { background: rgba(191, 90, 242, 0.15); color: var(--apple-purple); }

.btn-icon-delete {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
}
.btn-icon-delete:hover { color: var(--apple-coral); }

/* ========================================================
   Historial de Entrenamientos Anteriores (En "Entrenar")
   ======================================================== */
.history-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 22px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  transition: all var(--transition-fast);
}

.history-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-metrics {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.history-metrics strong { color: #fff; }

.history-ex-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.history-ex-tag {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
}

.btn-repeat-workout {
  background: rgba(48, 209, 88, 0.12);
  color: var(--apple-green);
  border: 1px solid rgba(48, 209, 88, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-repeat-workout:hover {
  background: rgba(48, 209, 88, 0.22);
}

/* ========================================================
   Rutinas Personalizadas & Rutinas Cards
   ======================================================== */
.routines-top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.routine-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
  transition: all var(--transition-fast);
}

.routine-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.routine-card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.routine-tag {
  background: rgba(191, 90, 242, 0.15);
  color: var(--apple-purple);
  border: 1px solid rgba(191, 90, 242, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
}

.routine-tag.custom {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
  border-color: rgba(48, 209, 88, 0.3);
}

.routine-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.routine-exercises-list {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.routine-ex-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.routine-ex-item:last-child { border-bottom: none; }

.btn-inline-plus-set {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
  border: 1px solid rgba(48, 209, 88, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
}
.btn-inline-plus-set:hover { background: rgba(48, 209, 88, 0.25); }

.routine-footer-btns {
  display: flex;
  gap: 8px;
}

.btn-edit-routine {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--apple-border);
  padding: 8px 12px;
  border-radius: var(--radius-button);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-edit-routine:hover { background: rgba(255, 255, 255, 0.15); }

.btn-del-routine {
  background: rgba(255, 69, 58, 0.1);
  color: var(--apple-coral);
  border: 1px solid rgba(255, 69, 58, 0.25);
  padding: 8px 12px;
  border-radius: var(--radius-button);
  cursor: pointer;
}

/* ========================================================
   Hevy-Style Routine Builder Modal & Exercise Picker
   ======================================================== */
.routine-builder-exercises {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.builder-ex-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--apple-border);
  border-radius: 12px;
  padding: 8px 10px;
  gap: 8px;
}

.builder-ex-info {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
}

.builder-ex-info small {
  display: block;
  font-size: 0.72rem;
  color: var(--apple-blue);
  font-weight: 500;
}

.builder-ex-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.builder-stepper {
  display: flex;
  align-items: center;
  background: #000;
  border: 1px solid var(--apple-border);
  border-radius: 8px;
  overflow: hidden;
}

.stepper-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
}
.stepper-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.builder-input-mini {
  width: 32px;
  padding: 4px 2px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

/* Picker List */
.picker-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--apple-border);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.picker-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.picker-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
}

/* ========================================================
   Exercises Catalog (Compact Cards)
   ======================================================== */
.chip-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.chip-container::-webkit-scrollbar { display: none; }

.filter-chip {
  white-space: nowrap;
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background: #FFFFFF;
  color: #000000;
  border-color: #FFFFFF;
}

.search-bar-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-bar-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.search-bar-wrap .input-text {
  padding-left: 36px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
}

.exercises-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.exercise-item-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.exercise-item-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.exercise-item-thumb {
  width: 100%;
  height: 105px;
  background: #000000;
  position: relative;
}

.exercise-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exercise-item-body {
  padding: 10px 12px;
}

.exercise-item-body h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.exercise-item-body .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ========================================================
   Stats (Progreso)
   ======================================================== */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-kpi-card {
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  border-radius: 16px;
  padding: 14px;
}

.stat-kpi-card .kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-kpi-card .kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 6px;
}

.stat-kpi-card .kpi-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.kpi-green .kpi-value { color: var(--apple-green); }
.kpi-blue .kpi-value { color: var(--apple-blue); }
.kpi-amber .kpi-value { color: var(--apple-amber); }
.kpi-coral .kpi-value { color: var(--apple-coral); }

.stat-bar-item { margin-bottom: 12px; }
.stat-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.stat-bar-track {
  background: rgba(255, 255, 255, 0.08);
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.8s var(--spring);
}

/* ========================================================
   Bottom Navigation Bar
   ======================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(58px + env(safe-area-inset-bottom, 16px));
  padding-bottom: env(safe-area-inset-bottom, 16px);
  background: rgba(18, 18, 20, 0.85);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid var(--apple-border);
  z-index: 99;
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 0;
  transition: all var(--transition-fast);
}

.nav-item svg { width: 20px; height: 20px; }
.nav-item small { font-size: 0.68rem; font-weight: 500; }
.nav-item.active { color: var(--apple-green); }
.nav-item:active { transform: scale(0.92); }

/* ========================================================
   Modals & Bottom Sheets
   ======================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: overlayFade 0.2s var(--spring);
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  padding: 20px;
  position: relative;
  animation: sheetPop 0.25s var(--spring);
}

@keyframes sheetPop {
  0% { transform: scale(0.93); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.sheet-drag-handle {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 14px;
}

.sheet-header {
  text-align: center;
  margin-bottom: 16px;
}

.sheet-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.sheet-header p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-close-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.or-divider {
  display: flex;
  align-items: center;
  margin: 14px 0;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  text-transform: uppercase;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--apple-border);
}
.or-divider span { padding: 0 10px; }

.google-apple-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-button);
  background: #FFFFFF;
  color: #1F1F1F;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.segmented-control {
  display: flex;
  background: rgba(118, 118, 128, 0.24);
  padding: 2px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.segmented-option {
  flex: 1;
  text-align: center;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
}

.segmented-option.active {
  background: #636366;
  color: #FFFFFF;
}

.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.text-center { text-align: center; }
