/* ══════════════════════════════════════════════════════════════
   Fit Tracker — Dark Fitness Theme
   ══════════════════════════════════════════════════════════════ */
:root {
  /* Fondos */
  --bg:         #080D1A;
  --bg2:        #0D1322;
  --card:       #111827;
  --card2:      #1A2338;

  /* Texto */
  --text:       #FFFFFF;
  --text2:      rgba(255,255,255,.52);
  --text3:      rgba(255,255,255,.22);

  /* Acento cyan — reemplaza iOS blue */
  --blue:       #00C8D7;
  --accent:     #00C8D7;
  --accent-dim: rgba(0,200,215,.14);
  --accent-glow:rgba(0,200,215,.32);

  /* Colores de tipo */
  --green:      #30D158;
  --green-dim:  rgba(48,209,88,.18);
  --orange:     #FF9F0A;
  --orange-dim: rgba(255,159,10,.18);
  --red:        #FF453A;
  --red-dim:    rgba(255,69,58,.20);
  --purple:     #BF5AF2;
  --teal-light: #5AC8FA;

  /* Separadores y rellenos */
  --sep:        rgba(255,255,255,.07);
  --sep-s:      rgba(255,255,255,.10);
  --fill1:      rgba(255,255,255,.10);
  --fill2:      rgba(255,255,255,.06);
  --fill3:      rgba(255,255,255,.04);

  /* Nav blurred */
  --nav:        rgba(8,13,26,.92);
}

:root { color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ── Nav bar ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--sep);
  padding-top: env(safe-area-inset-top);
}
.nav-inner { height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; gap: 8px; }
.nav-l  { justify-self: start; }
.nav-t  { justify-self: center; font-weight: 700; font-size: 17px; white-space: nowrap; letter-spacing: -.2px; }
.nav-r  { justify-self: end; }
.nav-btn { color: var(--accent); font-size: 17px; background: none; border: none; padding: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.nav-btn:active { opacity: .4; }
.nav-back svg { transform: scaleX(-1); }

/* ── Bottom tab bar ── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--nav);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--sep);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 0 6px; text-decoration: none; color: var(--text3); font-size: 10px; gap: 3px; cursor: pointer; border: none; background: transparent; -webkit-appearance: none; transition: color .18s; }
.tab-item svg { stroke: var(--text3); transition: stroke .18s, transform .18s; }
.tab-item span { font-weight: 500; transition: font-weight .18s, color .18s; }
.tab-item.active { color: var(--accent); }
.tab-item.active svg { stroke: var(--accent); }
.tab-item.active span { font-weight: 700; }
.tab-item:active svg { transform: scale(.88); }

/* ── Scroll wrapper ── */
.scroll { padding: 0 0 calc(84px + env(safe-area-inset-bottom)); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); animation: page-enter .36s cubic-bezier(.32,.72,0,1); }
@keyframes page-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.large-title { font-size: 34px; font-weight: 800; letter-spacing: -.6px; padding: 12px 20px 4px; }
.large-sub   { font-size: 15px; color: var(--text2); padding: 0 20px 16px; }

/* ── iOS list ── */
.list-hdr { text-transform: uppercase; font-size: 12px; color: var(--text3); margin: 24px 16px 8px 20px; font-weight: 600; letter-spacing: .08em; }
.list-ftr  { font-size: 13px; color: var(--text2); margin: 8px 20px 0; }
.ios-list  { background: var(--card); border-radius: 14px; margin: 0 16px; overflow: hidden; border: 1px solid var(--sep); }
.ios-item  { display: flex; align-items: center; padding: 14px 16px; min-height: 50px; position: relative; background: var(--card); }
.ios-item + .ios-item::before { content: ''; position: absolute; top: 0; left: 56px; right: 0; height: 1px; background: var(--sep); }
.ios-item.ni + .ios-item::before, .ios-item.ni::before { left: 16px; }
.ios-item.tap:active { background: var(--fill2); }
.ios-inp { flex: 1; border: none; background: transparent; color: var(--text); font-size: 16px; padding: 4px 0; outline: none; -webkit-appearance: none; font-family: inherit; }
.ios-inp::placeholder { color: var(--text2); }

/* ── Botones ── */
.btn-fill { display: block; background: var(--accent); color: #000; border: none; border-radius: 14px; font-size: 17px; font-weight: 700; padding: 16px; width: calc(100% - 32px); margin: 16px; cursor: pointer; text-align: center; font-family: inherit; letter-spacing: -.1px; box-shadow: 0 4px 20px var(--accent-glow); }
.btn-fill:active { filter: brightness(.88); }
.btn-flat { display: block; background: var(--card2); color: var(--text); border: none; border-radius: 12px; font-size: 17px; padding: 13px; width: calc(100% - 32px); margin: 8px 16px; cursor: pointer; text-align: center; font-family: inherit; border: 1px solid var(--sep); }
.btn-flat.red { color: var(--red); }
.btn-flat:active { background: var(--fill2); }

/* ── Checkbox ── */
.cb { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--sep-s); appearance: none; -webkit-appearance: none; outline: none; margin-right: 14px; position: relative; cursor: pointer; transition: transform .15s, background-color .2s, border-color .2s; flex-shrink: 0; }
.cb:checked { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.cb:checked::after { content: ''; position: absolute; top: 4px; left: 4.5px; width: 14px; height: 14px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E"); background-size: contain; background-repeat: no-repeat; }
.cb:active { transform: scale(.90); }

/* ── Calendar ── */
.wk-hdr { font-size: 12px; color: var(--text3); text-transform: uppercase; margin: 20px 16px 6px 20px; font-weight: 600; letter-spacing: .08em; }
.day-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; padding: 0 16px; }
.day-card {
  background: var(--card); border-radius: 18px; padding: 16px; color: inherit;
  display: flex; flex-direction: column; position: relative; min-height: 110px;
  transition: transform .15s; cursor: pointer;
  border: 1px solid var(--sep); overflow: hidden;
}
.day-card::after { content: ''; position: absolute; inset: 0; border-radius: 18px; background: linear-gradient(135deg, rgba(255,255,255,.03) 0%, transparent 60%); pointer-events: none; }
.day-card:active { transform: scale(.96); }
.day-card.rest { background: var(--bg2); border-color: var(--sep); }
.day-dot { position: absolute; top: 13px; right: 13px; width: 9px; height: 9px; border-radius: 50%; }
.day-date  { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: .08em; text-transform: uppercase; }
.day-title { font-size: 15px; font-weight: 700; margin-top: 5px; line-height: 1.25; letter-spacing: -.1px; }
.day-sub   { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.3; }
.day-prog  { position: absolute; bottom: 11px; right: 11px; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.day-prog-bar  { width: 40px; height: 4px; background: var(--fill2); border-radius: 2px; overflow: hidden; }
.day-prog-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.day-check { position: absolute; bottom: 11px; right: 11px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #000; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; box-shadow: 0 2px 10px var(--accent-glow); }

/* ── Day hero ── */
.day-hero  { padding: 4px 20px 16px; display: flex; gap: 14px; align-items: stretch; }
.hero-bar  { width: 4px; border-radius: 2px; flex-shrink: 0; }
.hero-title { font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -.5px; }
.hero-sub  { font-size: 15px; color: var(--text2); margin-top: 4px; }
.prog-wrap { margin: 10px 20px 8px; }
.prog-track { background: var(--fill2); height: 6px; border-radius: 3px; overflow: hidden; }
.prog-fill  { height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s; }
.prog-labels { font-size: 13px; color: var(--text2); margin-top: 6px; display: flex; justify-content: space-between; }

/* ── Exercise row ── */
.ex-meta  { font-size: 14px; color: var(--text2); margin-top: 3px; }
.ex-w     { color: var(--text); font-weight: 600; }
.weight-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.weight-inp { border: 1px solid var(--sep); background: var(--fill2); color: var(--text); font-size: 15px; font-weight: 600; padding: 8px 12px; border-radius: 10px; min-width: 90px; flex: 1; outline: none; font-family: inherit; -webkit-appearance: none; transition: border-color .2s, background .2s; }
.weight-inp::placeholder { color: var(--text3); font-weight: 400; }
.weight-inp:focus { border-color: var(--accent); background: rgba(0,200,215,.06); }
.weight-saved { font-size: 12px; color: var(--accent); max-width: 0; overflow: hidden; opacity: 0; transition: max-width .35s ease, opacity .35s ease; white-space: nowrap; }
.weight-saved.show { max-width: 80px; opacity: 1; }

/* ── Calorie row ── */
.cal-row { display: flex; align-items: center; gap: 10px; padding: 13px 16px; background: var(--card2); border-radius: 14px; margin: 10px 16px 0; border: 1px solid var(--sep); }
.cal-inp { border: none; background: transparent; color: var(--text); font-size: 17px; font-weight: 700; width: 90px; outline: none; font-family: inherit; -webkit-appearance: none; }
.cal-inp::placeholder { color: var(--text2); font-weight: 400; }
.cal-lbl { font-size: 13px; color: var(--text2); }

/* ── Tip ── */
.tip { margin: 20px 16px 16px; padding: 14px 16px; background: var(--card2); border-radius: 16px; font-size: 14px; color: var(--text2); line-height: 1.5; display: flex; gap: 10px; border: 1px solid var(--sep); transition: border-color .2s; }
.tip:focus-within { border-color: var(--accent); }
.tip-icon { flex-shrink: 0; line-height: 0; color: var(--accent); display: flex; align-items: flex-start; padding-top: 2px; }
.tip-icon svg { stroke: var(--accent); }
.tip-textarea {
  flex: 1; border: none; background: transparent; color: var(--text2);
  font-size: 14px; line-height: 1.5; resize: none; outline: none;
  font-family: inherit; -webkit-appearance: none; overflow: hidden;
  min-height: 20px;
}
.tip-textarea::placeholder { color: var(--text3); font-style: italic; }

/* ── Empty ── */
.empty { margin: 24px 16px; padding: 40px 20px; background: var(--card); border-radius: 16px; text-align: center; color: var(--text2); font-size: 15px; line-height: 1.6; border: 1px solid var(--sep); }

/* ── Modal sheet ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 200; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 20px 20px 0 0; transform: translateY(100%); transition: transform .32s cubic-bezier(.32,.72,0,1); z-index: 201; padding-bottom: calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; border-top: 1px solid var(--sep); }
.overlay.show { opacity: 1; pointer-events: auto; }
.sheet.show   { transform: translateY(0); }
.handle { width: 40px; height: 4px; border-radius: 2px; background: var(--fill1); margin: 10px auto 6px; }
.modal-title { text-align: center; font-size: 12px; color: var(--text3); margin: 12px 16px 4px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.modal-msg { font-size: 14px; text-align: center; min-height: 20px; margin: 8px 16px 0; color: var(--text2); }
.modal-msg.ok  { color: var(--accent); }
.modal-msg.err { color: var(--red); }

/* ── Stats ── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.stat-card { background: var(--card); border-radius: 16px; padding: 16px 14px; border: 1px solid var(--sep); }
.stat-val  { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.8px; }
.stat-lbl  { font-size: 13px; color: var(--text2); margin-top: 5px; line-height: 1.3; }
.month-tabs { display: flex; gap: 8px; padding: 8px 16px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.month-tabs::-webkit-scrollbar { display: none; }
.month-tab { white-space: nowrap; padding: 7px 16px; border-radius: 20px; font-size: 14px; font-weight: 500; background: var(--card2); color: var(--text2); text-decoration: none; flex-shrink: 0; border: 1px solid var(--sep); }
.month-tab.active { background: var(--accent); color: #000; font-weight: 700; border-color: transparent; }

/* ── Adherence ring ── */
.ring-wrap  { position: relative; width: 90px; height: 90px; flex-shrink: 0; }
.ring-svg   { width: 90px; height: 90px; transform: rotate(-90deg); }
.ring-inner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1px; }
.ring-pct   { font-size: 20px; font-weight: 700; line-height: 1; }
.ring-sub   { font-size: 10px; color: var(--text2); font-weight: 500; }

/* ── Calorie bar chart ── */
.cal-chart   { display: flex; gap: 8px; align-items: flex-end; padding: 0 16px; height: 140px; }
.cal-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; justify-content: flex-end; }
.cal-bar-val { font-size: 10px; color: var(--text2); font-weight: 500; text-align: center; min-height: 14px; }
.cal-bar     { width: 100%; border-radius: 7px 7px 0 0; background: var(--accent); min-height: 4px; }
.cal-bar-lbl { font-size: 11px; color: var(--text2); font-weight: 400; }

/* ── Exercise progression ── */
.prog-ex-card { margin: 0 16px 12px; background: var(--card); border-radius: 16px; overflow: hidden; border: 1px solid var(--sep); }
.prog-ex-head { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--sep); }
.prog-ex-name { font-weight: 700; font-size: 15px; }
.prog-ex-badge { display: flex; align-items: center; gap: 6px; }
.prog-ex-body { padding: 12px 14px; }
.prog-sparkline { margin-bottom: 10px; }
.prog-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.prog-table th { text-align: left; font-size: 11px; color: var(--text2); padding: 4px 6px; text-transform: uppercase; letter-spacing: .06em; }
.prog-table td { padding: 7px 6px; border-top: 1px solid var(--sep); }
.var-up { color: var(--accent); font-weight: 700; }
.var-dn { color: var(--red); font-weight: 700; }
.var-eq { color: var(--text2); }
.type-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; color: #fff; }

/* ── Routines library ── */
.filter-tabs { display: flex; gap: 8px; padding: 12px 16px 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab { flex-shrink: 0; padding: 7px 18px; border-radius: 20px; font-size: 14px; font-weight: 500; text-decoration: none; background: var(--card2); color: var(--text2); border: 1px solid var(--sep); }
.filter-tab.active { background: var(--accent); color: #000; font-weight: 700; border-color: transparent; }

.rt-card { margin: 0 16px 10px; background: var(--card); border-radius: 16px; overflow: hidden; border: 1px solid var(--sep); display: flex; align-items: stretch; text-decoration: none; color: var(--text); }
.rt-card:active { opacity: .7; }
.rt-card-bar  { width: 5px; flex-shrink: 0; }
.rt-card-body { flex: 1; padding: 14px 12px; min-width: 0; }
.rt-card-name { font-size: 16px; font-weight: 700; }
.rt-card-meta { font-size: 13px; color: var(--text2); margin-top: 3px; }
.rt-card-chev { display: flex; align-items: center; padding: 0 14px; color: var(--text3); font-size: 22px; }

.rt-hero       { padding: 18px 16px 12px; }
.rt-hero-name  { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.25; }
.rt-hero-stats { font-size: 15px; color: var(--text2); margin-top: 5px; }

.rt-item { display: flex; align-items: stretch; background: var(--card); border-radius: 14px; margin: 0 16px 8px; overflow: hidden; border: 1px solid var(--sep); }
.rt-item-bar  { width: 5px; flex-shrink: 0; }
.rt-item-body { flex: 1; padding: 13px 12px; min-width: 0; }
.rt-item-name { font-size: 15px; font-weight: 600; }
.rt-item-sub  { font-size: 13px; color: var(--text2); margin-top: 4px; line-height: 1.55; }
.rt-item-chev { display: flex; align-items: center; padding: 0 14px; color: var(--text3); font-size: 18px; }
.rt-sect-lbl  { font-size: 12px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; padding: 10px 16px 4px; margin-top: 4px; }

.apply-bar { position: fixed; bottom: calc(49px + env(safe-area-inset-bottom)); left: 0; right: 0; padding: 10px 20px 14px; background: linear-gradient(to top, var(--bg) 75%, transparent); pointer-events: none; display: flex; justify-content: center; z-index: 90; }
.apply-bar button { pointer-events: auto; background: var(--red); color: #fff; border: none; border-radius: 30px; font-size: 17px; font-weight: 700; padding: 14px 48px; cursor: pointer; box-shadow: 0 4px 20px var(--red-dim); }
.apply-bar button:active { filter: brightness(.88); }

/* ── Exercise delete button — edit mode only ── */
.ex-del-btn { flex-shrink: 0; margin-left: 12px; width: 32px; height: 32px; border: none; background: var(--red-dim); border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; -webkit-appearance: none; transition: transform .12s; align-self: flex-start; margin-top: 2px; }
.ex-del-btn:active { transform: scale(.88); }
.day-edit-mode .ex-del-btn { display: flex; }

/* ── Stats redesign ── */
.st-hero { display: flex; align-items: center; gap: 16px; padding: 8px 16px 24px; }
.st-ring-wrap  { position: relative; width: 114px; height: 114px; flex-shrink: 0; }
.st-ring-svg   { width: 114px; height: 114px; transform: rotate(-90deg); }
.st-ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.st-ring-pct   { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.st-ring-lbl   { font-size: 10px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.st-kpis { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.st-kpi  { background: var(--card); border-radius: 16px; padding: 12px 13px; border: 1px solid var(--sep); }
.st-kpi-val { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.st-kpi-lbl { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.3; font-weight: 500; }
.st-types { background: var(--card); border-radius: 16px; margin: 0 16px; padding: 16px; display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--sep); }
.st-type-row  { display: grid; grid-template-columns: 52px 1fr 24px; align-items: center; gap: 10px; }
.st-type-lbl  { font-size: 13px; font-weight: 600; color: var(--text2); }
.st-type-track { background: var(--fill2); border-radius: 6px; height: 8px; overflow: hidden; }
.st-type-fill { height: 100%; border-radius: 6px; }
.st-type-n    { font-size: 14px; font-weight: 700; text-align: right; }
.st-chart     { display: flex; gap: 10px; align-items: flex-end; padding: 4px 16px 0; height: 170px; }
.st-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; }
.st-chart-val { font-size: 10px; color: var(--text2); font-weight: 600; text-align: center; min-height: 14px; line-height: 1.2; }
.st-chart-bar { width: 100%; border-radius: 9px 9px 0 0; background: linear-gradient(to top, var(--accent), rgba(0,200,215,.4)); min-height: 6px; }
.st-chart-lbl { font-size: 11px; color: var(--text2); font-weight: 400; }
/* Progression accordion list */
.pg-list { background: var(--card); border-radius: 16px; margin: 0 16px; overflow: hidden; border: 1px solid var(--sep); }
.pg-item { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pg-item.pg-hidden { display: none; }
.pg-row  { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.pg-name { flex: 1; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pg-spark { flex-shrink: 0; opacity: .7; }
.pg-badge { font-size: 12px; font-weight: 700; flex-shrink: 0; white-space: nowrap; }
.pg-chev  { color: var(--text3); font-size: 18px; line-height: 1; transition: transform .2s; flex-shrink: 0; }
.pg-item.pg-open .pg-chev { transform: rotate(90deg); }
.pg-detail { display: none; padding: 2px 16px 10px; background: var(--fill); border-top: .5px solid var(--sep); }
.pg-item.pg-open .pg-detail { display: block; }
.pg-sess-row  { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: .5px solid var(--sep); }
.pg-sess-row:last-child { border-bottom: none; }
.pg-sess-date { font-size: 13px; color: var(--text2); width: 38px; flex-shrink: 0; }
.pg-sess-w    { font-size: 14px; font-weight: 600; flex: 1; }
.pg-sep { height: .5px; background: var(--sep); }
.pg-more-btn  { display: block; width: calc(100% - 32px); margin: 8px 16px 4px; padding: 12px; background: var(--fill); border: none; border-radius: 12px; color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; }

@media (min-width: 700px) {
  .nav-inner, .tab-bar > * { max-width: 700px; margin-left: auto; margin-right: auto; }
  .tab-bar { justify-content: center; }
  .tab-item { max-width: 120px; }
}

/* ── Exercise edit tap zone ── */
.ex-edit-tap { cursor: pointer; padding-bottom: 2px; }
.ex-edit-tap:active { opacity: .6; }

/* ── Exercise param edit sheet ── */
.ex-sheet-title { text-align: center; font-size: 17px; font-weight: 700; padding: 2px 16px 12px; margin: 0; letter-spacing: -.2px; }
.ex-sets-row    { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--card2); border-radius: 14px; margin: 0 16px 8px; border: 1px solid var(--sep); }
.ex-sets-label  { font-size: 16px; font-weight: 500; }
.ex-stepper     { display: flex; align-items: center; background: var(--fill2); border-radius: 12px; overflow: hidden; }
.ex-stepper-btn { width: 38px; height: 38px; border: none; background: transparent; color: var(--accent); font-size: 24px; cursor: pointer; -webkit-appearance: none; font-family: inherit; display: flex; align-items: center; justify-content: center; }
.ex-stepper-btn:active { background: var(--fill3); }
.ex-stepper-val { min-width: 38px; text-align: center; font-size: 17px; font-weight: 700; }
.ex-param-group { background: var(--card2); border-radius: 14px; margin: 0 16px 8px; overflow: hidden; border: 1px solid var(--sep); }
.ex-param-row   { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; min-height: 48px; }
.ex-param-row + .ex-param-row { border-top: 1px solid var(--sep); }
.ex-param-label  { font-size: 16px; font-weight: 500; }
.ex-param-select { border: none; background: transparent; color: var(--text2); font-size: 16px; text-align: right; outline: none; -webkit-appearance: none; cursor: pointer; font-family: inherit; max-width: 180px; }
.ex-param-inp    { border: none; background: transparent; color: var(--text2); font-size: 16px; text-align: right; width: 90px; outline: none; font-family: inherit; -webkit-appearance: none; }
.ex-param-inp::placeholder { color: var(--text3); }

/* ── Routine item tappable ── */
.rt-item-tap { cursor: pointer; }
.rt-item-tap:active { opacity: .6; }

/* ── Exercise detail overlay (slides from right) ── */
.ex-detail-sheet-title { text-align: center; font-size: 18px; font-weight: 700; letter-spacing: -.3px; padding: 2px 20px 14px; margin: 0; }
#ex-detail-gallery   { position: relative; margin: 0 16px; border-radius: 14px; overflow: hidden; background: #fff; }
.ex-detail-main-img  { width: 100%; background: #fff; overflow: hidden; cursor: pointer; }
.ex-detail-main-img img { width: 100%; display: block; max-height: 220px; object-fit: contain; }
.ex-detail-thumbs    { display: flex; gap: 6px; padding: 8px 12px; }
.ex-detail-thumb     { width: 60px; height: 45px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.ex-detail-thumb.active { border-color: var(--accent); }
.ex-detail-info      { padding: 16px 16px 8px; }
.ex-detail-name      { font-size: 22px; font-weight: 800; line-height: 1.2; margin-bottom: 4px; letter-spacing: -.3px; }
.ex-detail-mg        { font-size: 14px; color: var(--text2); margin-bottom: 14px; }
.ex-detail-section   { font-size: 12px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 4px; }
.ex-detail-text      { font-size: 15px; line-height: 1.6; }
.ex-detail-params    { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--sep); border-radius: 16px; overflow: hidden; margin-bottom: 28px; }
.ex-detail-param     { background: var(--fill); padding: 16px 18px; display: flex; flex-direction: column; gap: 5px; }
.ex-detail-param-lbl { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; }
.ex-detail-param-val { font-size: 28px; font-weight: 700; letter-spacing: -.6px; line-height: 1; }
.ex-detail-param-unit{ font-size: 15px; font-weight: 500; color: var(--text2); letter-spacing: 0; }
.ex-detail-badges    { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.ex-detail-badge     { background: var(--fill2); color: var(--text2); font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 20px; }
.ex-detail-muted     { color: var(--text2); }

/* ── Edit sheet exercise image ── */
.ex-edit-img-wrap     { margin: 0 16px 12px; border-radius: 14px; overflow: hidden; background: #fff; }
.ex-edit-img-wrap img { width: 100%; display: block; max-height: 180px; object-fit: contain; }

/* ── Drag handle ── */
.drag-handle { display: none; align-items: center; justify-content: center; width: 28px; min-height: 44px; color: var(--text3); cursor: grab; flex-shrink: 0; touch-action: none; margin-left: -4px; }
.day-edit-mode .drag-handle { display: flex; }
.edit-draggable.dragging  { opacity: .45; position: relative; z-index: 50; }
.edit-draggable.drag-over { box-shadow: 0 -2px 0 var(--accent); }

/* ── Add-exercise floating bar ── */
.add-ex-bar { display: none; position: fixed; bottom: calc(83px + env(safe-area-inset-bottom)); left: 0; right: 0; padding: 6px 16px 8px; z-index: 20; pointer-events: none; }
.add-ex-bar.show { display: flex; pointer-events: auto; }
.add-ex-bar-btn  { flex: 1; background: var(--accent); color: #000; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 20px var(--accent-glow); }
.add-ex-bar-btn:active { opacity: .8; }

/* ── Botón "agregar ejercicio manual" (reutilizado en el selector con pestañas) ── */
.add-ex-free-btn   { background: var(--accent); color: #000; border: none; border-radius: 12px; padding: 10px 16px; font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap; font-family: inherit; }
.add-ex-free-btn:active { opacity: .8; }

/* ── Edit mode secondary action buttons ── */
.add-ex-bar-actions { display: flex; gap: 8px; margin-top: 6px; }
.add-ex-action-btn  { flex: 1; background: var(--card2); color: var(--text); border: 1px solid var(--sep); border-radius: 12px; padding: 11px 8px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; text-align: center; }
.add-ex-action-btn:active { opacity: .7; }

/* ── Toast ── */
.app-toast { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(12px); background: rgba(17,24,39,.96); color: #fff; padding: 12px 22px; border-radius: 14px; font-size: 14px; font-weight: 600; white-space: nowrap; max-width: calc(100vw - 48px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; opacity: 0; transition: opacity .22s, transform .22s; z-index: 9999; box-shadow: 0 4px 24px rgba(0,0,0,.5); border: 1px solid var(--sep); }
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast-ok   { background: rgba(0,200,215,.12); border-color: var(--accent); color: var(--accent); }
.app-toast-warn { background: rgba(255,159,10,.12); border-color: var(--orange); color: var(--orange); }

/* ── Porcentaje en tarjeta de calendario ── */
.day-prog-pct { font-size: 11px; font-weight: 700; color: var(--text2); text-align: right; line-height: 1; }

/* ── Historial de pesos ── */
.wh-row   { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--sep); }
.wh-date  { font-size: 13px; color: var(--text2); width: 52px; flex-shrink: 0; }
.wh-val   { font-size: 15px; font-weight: 600; flex: 1; }
.wh-var   { font-size: 12px; font-weight: 700; width: 18px; text-align: right; }
.wh-empty { padding: 28px 16px; text-align: center; color: var(--text2); font-size: 14px; }

/* ── Fotos de progreso ── */
.photos-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; padding: 0 0 8px; }
.photo-thumb { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--fill2); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del-btn   { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 13px; line-height: 22px; text-align: center; cursor: pointer; padding: 0; }
.photo-date      { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; font-size: 10px; padding: 10px 4px 3px; text-align: center; }
.photo-upload-btn { background: var(--fill2); border: 1.5px dashed var(--sep-s); border-radius: 10px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); font-size: 12px; gap: 4px; -webkit-appearance: none; appearance: none; }
.photo-upload-btn .pu-icon { line-height: 0; color: var(--text2); }
.photo-upload-btn:active { opacity: .6; }
.photo-empty { padding: 28px 16px; text-align: center; color: var(--text2); font-size: 14px; }

/* ══════════════════════════════════════════════════════════════
   LOGIN screen
   ══════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 40px) 24px calc(env(safe-area-inset-bottom) + 40px);
  background:
    radial-gradient(ellipse 90% 50% at 50% -5%, rgba(0,200,215,.18) 0%, transparent 65%),
    var(--bg);
}
.login-logo-wrap { display: flex; flex-direction: column; align-items: center; margin-bottom: 18px; gap: 10px; }
.login-logo-svg  { width: 62px; height: 56px; color: #fff; filter: drop-shadow(0 6px 18px rgba(0,200,215,.38)); }
.login-brand {
  font-size: 26px; font-weight: 900; letter-spacing: 3px;
  background: linear-gradient(135deg, var(--accent), var(--teal-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin: 0;
}
.login-tagline { font-size: 15px; color: var(--text2); margin-bottom: 44px; text-align: center; line-height: 1.5; }
.login-form    { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 0; }
.login-fields  { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.login-field   { background: var(--card); border: 1.5px solid var(--sep); border-radius: 14px; display: flex; align-items: center; padding: 0 16px; height: 58px; transition: border-color .2s, background .2s; }
.login-field:focus-within { border-color: var(--accent); background: rgba(0,200,215,.05); }
.login-field-icon { margin-right: 12px; color: var(--text3); flex-shrink: 0; }
.login-field-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.login-inp { flex: 1; border: none; background: transparent; color: var(--text); font-size: 16px; outline: none; -webkit-appearance: none; font-family: inherit; }
.login-inp::placeholder { color: var(--text2); }
.login-btn {
  width: 100%; background: var(--accent); color: #000; border: none; border-radius: 14px;
  font-size: 17px; font-weight: 700; padding: 17px; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 28px var(--accent-glow); letter-spacing: -.1px;
  transition: filter .15s, transform .1s;
}
.login-btn:active { filter: brightness(.88); transform: scale(.99); }
.login-error { font-size: 14px; color: var(--red); text-align: center; margin: 14px 0 0; min-height: 20px; }

/* ── Hero title editable input ── */
.hero-title-input {
  font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -.5px;
  background: rgba(255,255,255,.07); border: 1.5px solid var(--accent);
  border-radius: 12px; color: var(--text); padding: 6px 10px;
  outline: none; font-family: inherit; width: 100%;
  -webkit-appearance: none;
}

/* ── Rest day toggle row ── */
.rest-toggle-row {
  display: none; align-items: center; justify-content: space-between;
  margin: 2px 20px 12px; padding: 13px 16px;
  background: var(--card); border-radius: 14px; border: 1px solid var(--sep);
}
.rest-toggle-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 500; color: var(--text);
}
.rest-toggle-label svg { stroke: var(--accent); flex-shrink: 0; }
.ios-toggle-wrap { flex-shrink: 0; }
.ios-toggle {
  appearance: none; -webkit-appearance: none;
  width: 51px; height: 31px; border-radius: 16px;
  background: var(--fill1); cursor: pointer; position: relative;
  transition: background .22s;
}
.ios-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.ios-toggle:checked { background: var(--accent); }
.ios-toggle:checked::after { transform: translateX(20px); }

/* ── Rest day empty state ── */
.rest-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rest-empty-icon svg { stroke: var(--text3); }

/* ── cal-icon (replaces emoji) ── */
.cal-icon { display: flex; align-items: center; color: var(--orange); flex-shrink: 0; }
.cal-icon svg { stroke: var(--orange); }

/* ── wh-btn SVG (replaces 📈 emoji) ── */
.wh-btn { border: none; background: var(--fill2); border-radius: 10px; cursor: pointer;
  padding: 6px 8px; flex-shrink: 0; -webkit-appearance: none; line-height: 0;
  display: flex; align-items: center; justify-content: center; color: var(--accent); }
.wh-btn svg { stroke: var(--accent); }
.wh-btn:active { opacity: .5; }
.weight-saved { font-size: 12px; color: var(--accent); max-width: 0; overflow: hidden; opacity: 0; transition: max-width .35s ease, opacity .35s ease; white-space: nowrap; }
.weight-saved.show { max-width: 80px; opacity: 1; }

/* ── Edit mode action bar (redesigned) ── */
.edit-action-bar {
  display: none; position: fixed;
  bottom: calc(83px + env(safe-area-inset-bottom));
  left: 0; right: 0; padding: 8px 16px 10px; z-index: 20;
  pointer-events: none;
}
.edit-action-bar.show { display: block; pointer-events: auto; }
.edit-action-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.edit-action-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px; border: none; border-radius: 16px;
  background: var(--card2); border: 1px solid var(--sep);
  color: var(--text); cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 16px rgba(0,0,0,.32);
  transition: transform .12s, opacity .12s;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.edit-action-item:active { transform: scale(.93); opacity: .75; }
.edit-action-primary {
  background: var(--accent); color: #000; border-color: transparent;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.edit-action-primary .edit-action-icon svg { stroke: #000; }
.edit-action-icon { line-height: 0; }
.edit-action-icon svg { stroke: var(--text); }
.edit-action-label { font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; }
.edit-action-primary .edit-action-label { color: #000; }

/* ══════════════════════════════════════════════════════════════
   ONBOARDING screen
   ══════════════════════════════════════════════════════════════ */
.ob-screen {
  min-height: 100dvh; overflow: hidden; position: relative;
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(0,200,215,.14) 0%, transparent 62%),
    var(--bg);
}
.ob-step {
  display: none; flex-direction: column;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 32px) 24px calc(env(safe-area-inset-bottom) + 24px);
}
.ob-step.active { display: flex; }

/* Step 0 — welcome */
.ob-welcome-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 32px; }
.ob-logo-svg { width: 72px; height: 64px; filter: drop-shadow(0 6px 20px rgba(0,200,215,.4)); }
.ob-logo-svg path { fill: url(#ob-grad); }
.ob-logo-brand {
  font-size: 24px; font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(135deg, var(--accent), var(--teal-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.ob-welcome-title { font-size: 36px; font-weight: 800; letter-spacing: -.6px; line-height: 1.2; margin: 0 0 14px; }
.ob-welcome-sub   { font-size: 16px; color: var(--text2); line-height: 1.6; margin: 0 0 auto; }

/* Step header */
.ob-step-top  { margin-bottom: 28px; }
.ob-step-num  { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.ob-step-title { font-size: 28px; font-weight: 800; letter-spacing: -.4px; margin: 0; line-height: 1.2; }

/* Sex grid */
.ob-sex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: auto; }
.ob-sex-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px 20px; border-radius: 22px;
  background: var(--card); border: 2px solid var(--sep);
  color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color .2s, background .2s;
}
.ob-sex-btn svg { width: 44px; height: 44px; stroke: var(--text2); transition: stroke .2s; }
.ob-sex-btn.active { border-color: var(--accent); background: var(--accent-dim); }
.ob-sex-btn.active svg { stroke: var(--accent); }
.ob-sex-btn:active { opacity: .75; }

/* Drum picker */
.ob-picker-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.ob-picker-label { font-size: 42px; font-weight: 800; letter-spacing: -1px; color: var(--accent); margin-bottom: 4px; }
.ob-drum-wrap {
  position: relative; width: 200px; height: 240px; overflow: hidden;
  border-radius: 18px; background: var(--card); border: 1px solid var(--sep);
}
.ob-drum-mask {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom, var(--card) 0%, transparent 30%, transparent 70%, var(--card) 100%);
}
.ob-drum-mask::after {
  content: ''; position: absolute; left: 0; right: 0;
  top: calc(50% - 24px); height: 48px;
  border-top: 1.5px solid var(--accent); border-bottom: 1.5px solid var(--accent);
}
.ob-drum {
  overflow-y: scroll; height: 100%; scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.ob-drum::-webkit-scrollbar { display: none; }
.ob-drum-item {
  height: 48px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: var(--text2);
  scroll-snap-align: center;
}

/* Options list */
.ob-options-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: auto; }
.ob-option-btn {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  background: var(--card); border: 2px solid var(--sep); border-radius: 16px;
  color: var(--text); font-size: 15px; font-weight: 500; cursor: pointer;
  font-family: inherit; text-align: left; line-height: 1.3;
  transition: border-color .2s, background .2s;
}
.ob-option-btn svg { width: 22px; height: 22px; stroke: var(--text3); flex-shrink: 0; transition: stroke .2s; }
.ob-option-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.ob-option-btn.active svg { stroke: var(--accent); }
.ob-option-btn:active { opacity: .75; }

/* Avatar */
.ob-photo-hint { font-size: 14px; font-weight: 600; color: var(--text2); margin: 20px 0 10px; text-transform: uppercase; letter-spacing: .06em; }
.ob-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: auto; }
.ob-avatar-preview {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--card2); border: 2px solid var(--sep);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.ob-avatar-preview svg { stroke: var(--text3); }
.ob-avatar-choose {
  display: inline-flex; align-items: center; padding: 12px 20px;
  background: var(--card2); border: 1px solid var(--sep); border-radius: 12px;
  font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer;
}
.ob-avatar-choose:active { opacity: .6; }

/* Navigation buttons */
.ob-step-actions { display: flex; gap: 10px; margin-top: 24px; }
.ob-btn-primary {
  flex: 1; background: var(--accent); color: #000; border: none; border-radius: 14px;
  font-size: 17px; font-weight: 700; padding: 17px; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 24px var(--accent-glow);
  transition: filter .15s, transform .1s;
}
.ob-btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
.ob-btn-primary:not(:disabled):active { filter: brightness(.88); transform: scale(.99); }
.ob-btn-back {
  flex: 0 0 auto; padding: 17px 20px; background: var(--card2); color: var(--text);
  border: 1px solid var(--sep); border-radius: 14px; font-size: 17px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.ob-btn-back:active { opacity: .7; }

/* ── Save animation overlay ── */
.save-anim-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease;
}
.save-anim-overlay.show { opacity: 1; pointer-events: auto; }
.save-anim-box {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.save-anim-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--fill1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.save-anim-msg {
  font-size: 15px; font-weight: 600; color: var(--text2); letter-spacing: -.1px;
}

/* ── Calendario FAB (biblioteca) ── */
.cal-fab {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  right: 20px;
  z-index: 90;
  display: flex; align-items: center; gap: 8px;
  background: var(--accent);
  color: #000;
  border: none; border-radius: 30px;
  padding: 13px 20px 13px 18px;
  font-size: 13px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: transform .15s, filter .15s;
}
.cal-fab svg { stroke: #000; }
.cal-fab:active { transform: scale(.92); filter: brightness(.88); }

/* ── Create-day step 1: type picker list ── */
.crd-type-list {
  display: flex; flex-direction: column;
  margin: 0 16px 8px;
  background: var(--card2);
  border-radius: 16px; overflow: hidden;
}
.crd-type-list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 14px;
  background: none; border: none;
  border-bottom: 1px solid var(--sep);
  cursor: pointer; font-family: inherit; text-align: left;
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.crd-type-list-row:last-child { border-bottom: none; }
.crd-type-list-row:active { background: var(--sep); }
.crd-type-list-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.crd-type-list-name {
  flex: 1; font-size: 16px; font-weight: 500; color: var(--text);
}

/* ── Nav save-mode button — same look as Listo (plain accent text) ── */
/* No extra styles needed; .nav-btn already applies the accent color */

/* ── Individual exercise card (day view) ── */
.day-ex-group { padding: 0 16px; display: flex; flex-direction: column; }
.day-ex-card {
  display: flex; align-items: stretch;
  background: var(--card2); border-radius: 14px;
  margin-bottom: 8px; overflow: hidden;
  border: 1px solid var(--sep); position: relative;
}
.day-ex-bar { width: 5px; flex-shrink: 0; }
.day-ex-main {
  flex: 1; display: flex; align-items: flex-start;
  padding: 13px 14px 13px 12px; min-width: 0;
}
.day-ex-body { flex: 1; min-width: 0; }

/* ── Tappable date in edit mode ── */
.hero-date-tap { display: inline; cursor: default; }
.day-edit-mode .hero-date-tap {
  color: var(--accent); cursor: pointer;
  border-bottom: 1px dashed rgba(0,200,215,.5);
}

/* ── Insert row (+ button between exercises) ── */
.insert-row {
  display: none; align-items: center; justify-content: center;
  height: 32px; min-height: 0; padding: 0; background: transparent;
  cursor: pointer; position: relative;
}
/* En modo edición, mostrar todos los + (permite agregar e insertar entre ejercicios) */
.day-edit-mode .insert-row { display: flex; margin-bottom: 8px; }
.insert-row-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #000; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 400; line-height: 1; pointer-events: none;
  box-shadow: 0 2px 10px var(--accent-glow);
}
/* Restore separator after insert-rows (same as ios-item + ios-item) */
.insert-row + .ios-item::before {
  content: ''; position: absolute; top: 0; left: 56px; right: 0;
  height: 1px; background: var(--sep);
}

/* ── Calendar view toggle ── */
.cal-view-toggle {
  display: flex; gap: 0; margin: 0 16px 12px;
  background: var(--card2); border-radius: 11px; padding: 3px;
  border: 1px solid var(--sep);
}
.cal-view-btn {
  flex: 1; border: none; background: transparent; color: var(--text2);
  font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; font-family: inherit; display: flex; align-items: center;
  justify-content: center; gap: 5px; transition: background .18s, color .18s;
}
.cal-view-btn svg { stroke: currentColor; }
.cal-view-btn.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.cal-view-btn:active { opacity: .7; }

/* ── Monthly calendar grid ── */
.cal-grid-view { padding: 0 14px 8px; }
.cal-grid-head {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; margin-bottom: 5px;
}
.cal-grid-head span {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; padding: 4px 0;
}
.cal-grid-cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell { min-height: 70px; }
.cal-cell-inner {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 3px 5px; height: 100%; min-height: 70px;
  border-radius: 11px; background: var(--card);
  border: 1px solid var(--sep); text-decoration: none; color: inherit;
  position: relative; overflow: hidden;
}
.cal-cell-today .cal-cell-inner { border-color: var(--accent); }
.cal-cell-noday .cal-cell-inner,
.cal-cell-empty .cal-cell-inner {
  background: transparent; border-color: transparent;
}
.cal-cell-inner:active { opacity: .7; }
.cal-cell-day-num {
  font-size: 12px; font-weight: 700; color: var(--text3); margin-bottom: 3px;
}
.cal-cell-today .cal-cell-day-num { color: var(--accent); }
.cal-cell-noday .cal-cell-day-num { color: var(--text3); opacity: .45; }
.cal-cell-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; margin-bottom: 2px; }
.cal-cell-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cal-cell-dot.done { box-shadow: 0 0 5px rgba(255,255,255,.25); }
.cal-cell-title {
  font-size: 8px; font-weight: 600; color: var(--text2); text-align: center;
  line-height: 1.25; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding: 0 1px;
  width: 100%;
}
.cal-cell-check {
  position: absolute; bottom: 4px; right: 5px; font-size: 10px;
  color: var(--accent); font-weight: 900;
}
.cal-cell-prog {
  width: calc(100% - 6px); background: var(--fill2); height: 3px;
  border-radius: 2px; margin-top: auto; overflow: hidden;
}
.cal-cell-prog-fill { height: 100%; border-radius: 2px; background: var(--accent); }

/* ── Flat calendar list view ── */
.cal-list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 16px; text-decoration: none; color: var(--text);
}
.cal-list-row:active { opacity: .7; }
.cal-list-date {
  flex-shrink: 0; width: 40px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0;
}
.cal-list-dow { font-size: 10px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; }
.cal-list-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.cal-today-num { color: var(--accent); }
.cal-list-slot-tag { font-size: 11px; font-weight: 700; color: var(--text3); background: var(--fill2); border-radius: 8px; padding: 3px 8px; }
.cal-list-card {
  flex: 1; display: flex; align-items: stretch;
  background: var(--card); border-radius: 14px; overflow: hidden;
  border: 1px solid var(--sep); min-width: 0; margin: 4px 0;
}
.cal-list-bar { width: 5px; flex-shrink: 0; }
.cal-list-body { flex: 1; padding: 12px 12px; min-width: 0; }
.cal-list-title { font-size: 15px; font-weight: 700; }
.cal-list-stats { font-size: 12px; color: var(--text2); margin-top: 3px; }
.cal-list-prog { background: var(--fill2); height: 3px; border-radius: 2px; overflow: hidden; margin-top: 5px; }
.cal-list-prog-fill { height: 100%; border-radius: 2px; }
.cal-list-check { padding: 0 14px; color: var(--accent); font-weight: 900; font-size: 16px; display: flex; align-items: center; flex-shrink: 0; }

/* ── Back button (nav-back-btn) — icon only, no text wrapping ── */
.nav-back-btn { font-size: 0; }
.nav-back-btn svg { width: 26px; height: 26px; }

/* ── Day empty state: big add button ── */
/* Visible siempre que no hay ejercicios (PHP lo renderiza solo cuando total_ex===0) */
.day-empty-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: calc(100% - 32px); margin: 24px 16px;
  padding: 22px 16px;
  background: var(--card2);
  border: 2px dashed var(--sep);
  border-radius: 16px;
  color: var(--accent);
  font-size: 17px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-empty-add-btn:active { opacity: .7; }

/* ── Day delete button (edit mode only) ── */
.day-del-btn {
  display: none; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 32px); margin: 24px 16px 8px;
  padding: 14px 16px;
  background: rgba(255,59,48,.1);
  border: 1.5px solid rgba(255,59,48,.3);
  border-radius: 14px;
  color: #FF3B30;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-del-btn:active { opacity: .7; }

/* ── Calendar list: type icon + title row ── */
.cal-list-title-row {
  display: flex; align-items: center; gap: 7px;
}
.cal-list-type-icon {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Tira semanal (L-D) bajo el nav del calendario ── */
.cal-day-strip {
  position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 95;
  display: flex; align-items: center; gap: 2px;
  padding: 10px 12px; background: var(--nav);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--sep);
}
.cal-strip-day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 2px 0; text-decoration: none; color: inherit;
}
.cal-strip-dow { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }
.cal-strip-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--text2);
  transition: transform .15s, background .15s, color .15s;
}
.cal-strip-day:active .cal-strip-num { transform: scale(.88); }
.cal-strip-today .cal-strip-num {
  background: var(--accent); color: #000; font-weight: 800;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.cal-strip-today-btn {
  flex-shrink: 0; margin-left: 4px;
  background: var(--fill2); color: var(--text2); border: 1px solid var(--sep);
  border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; -webkit-appearance: none;
}
.cal-strip-today-btn:active { opacity: .6; }

/* ── Lista del calendario: un renglón por cada día del mes ── */
.cal-day-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 4px 16px; scroll-margin-top: calc(48px + env(safe-area-inset-top) + 64px);
}
.cal-day-cards { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
@keyframes cal-flash-pulse {
  0%   { background-color: var(--accent-dim); }
  100% { background-color: transparent; }
}
.cal-day-row.cal-flash { animation: cal-flash-pulse .9s ease-out; border-radius: 16px; }

.cal-empty-day-btn {
  height: 56px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--sep); border-radius: 14px;
  cursor: pointer; width: 100%; -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
  transition: transform .12s, border-color .15s;
}
.cal-empty-day-btn:active { transform: scale(.97); }
.cal-empty-day-plus {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: var(--accent);
  transition: transform .15s;
}
.cal-empty-day-btn:active .cal-empty-day-plus { transform: scale(1.12); }

.cal-add-more-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; background: transparent; border: 1.5px dashed var(--sep-s); border-radius: 12px;
  color: var(--text2); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
}
.cal-add-more-btn svg { stroke: var(--accent); width: 15px; height: 15px; }
.cal-add-more-btn:active { opacity: .6; }

/* ── Grid mensual: botón "+" en celdas vacías ── */
.cal-cell-inner-btn { border: none; background: var(--card); font-family: inherit; width: 100%; cursor: pointer; -webkit-appearance: none; -webkit-tap-highlight-color: transparent; }
.cal-cell-plus { color: var(--text3); opacity: .6; transition: opacity .15s, transform .15s; margin-top: 2px; }
.cal-cell-inner-btn:active .cal-cell-plus { opacity: 1; color: var(--accent); transform: scale(1.15); }
.cal-cell-inner-btn:active { transform: scale(.94); }

/* ── Sheet: ¿Qué deseas programar? ── */
.sched-option-row {
  display: flex; align-items: center; gap: 14px; width: calc(100% - 32px);
  margin: 0 16px 10px; padding: 14px; text-align: left;
  background: var(--card2); border: 1px solid var(--sep); border-radius: 16px;
  cursor: pointer; font-family: inherit; -webkit-appearance: none; -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .12s;
}
.sched-option-row:active { transform: scale(.98); background: var(--fill2); }
.sched-option-icon {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sched-option-icon-create { background: var(--red-dim); color: var(--red); }
.sched-option-icon-lib    { background: var(--accent-dim); color: var(--accent); }
.sched-option-icon svg { stroke: currentColor; }
.sched-option-body { flex: 1; min-width: 0; }
.sched-option-name { font-size: 15px; font-weight: 700; color: var(--text); }
.sched-option-sub  { font-size: 12.5px; color: var(--text2); margin-top: 3px; line-height: 1.4; }

/* ── Selector de ejercicios con pestañas (fullscreen) ── */
.exsel-sheet {
  position: fixed; inset: 0; z-index: 205;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.32,.72,0,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.exsel-sheet.show { transform: translateY(0); }
/* El detalle de ejercicio se abre DESDE el selector, así que debe quedar
   siempre por encima de él (el selector queda de fondo, no se cierra). */
#ex-detail-overlay { z-index: 206; }
#ex-detail-sheet { z-index: 207; }
/* El sheet de "elegir fecha" se abre desde el detalle, debe ir aún más arriba. */
#exadd-overlay { z-index: 208; }
#exadd-sheet { z-index: 209; }
.exsel-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 12px;
  border-bottom: 1px solid var(--sep); flex-shrink: 0;
}
.exsel-back-btn, .exsel-search-btn {
  width: 34px; height: 34px; flex-shrink: 0; border: none; background: transparent;
  color: var(--text2); display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer; -webkit-appearance: none;
}
.exsel-back-btn:active, .exsel-search-btn:active { background: var(--fill2); }
.exsel-title { flex: 1; text-align: center; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.exsel-search-inp {
  flex: 1; background: var(--fill2); border: 1px solid var(--sep); border-radius: 10px;
  padding: 8px 12px; color: var(--text); font-size: 15px; font-family: inherit; outline: none;
}
.exsel-tabs {
  display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--sep); flex-shrink: 0;
}
.exsel-tabs::-webkit-scrollbar { display: none; }
.exsel-tab {
  flex-shrink: 0; padding: 13px 16px; font-size: 13.5px; font-weight: 600; color: var(--text2);
  background: none; border: none; position: relative; cursor: pointer; font-family: inherit;
  white-space: nowrap; -webkit-appearance: none;
}
.exsel-tab.active { color: var(--accent); }
.exsel-tab.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.exsel-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.exsel-sidebar {
  width: 34%; max-width: 148px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--sep); background: var(--bg2);
}
.exsel-side-item {
  display: block; width: 100%; text-align: left; padding: 13px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--text2); background: none; border: none;
  border-bottom: 1px solid var(--sep); cursor: pointer; font-family: inherit; -webkit-appearance: none;
  line-height: 1.3;
}
.exsel-side-item.active { color: var(--accent); background: var(--fill2); box-shadow: inset 2px 0 0 var(--accent); }
.exsel-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.exsel-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--sep); border-radius: 14px;
  padding: 10px 12px; cursor: pointer; font-family: inherit; -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent; transition: transform .12s, border-color .15s;
}
.exsel-row:active { transform: scale(.98); border-color: var(--sep-s); }
.exsel-row-thumb {
  width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0; overflow: hidden;
  background: var(--card2); display: flex; align-items: center; justify-content: center;
}
.exsel-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.exsel-thumb-icon { display: flex; }
.exsel-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.exsel-row-name { font-size: 14.5px; font-weight: 600; color: var(--text); }
.exsel-row-sub  { font-size: 12.5px; color: var(--text2); }
.exsel-empty { padding: 40px 16px; text-align: center; color: var(--text2); font-size: 14px; }
@keyframes exsel-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.exsel-list-anim { animation: exsel-fade-in .3s cubic-bezier(.32,.72,0,1); }
.exsel-free-row {
  flex-shrink: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sep); background: var(--bg2);
}
.exsel-free-lbl { font-size: 12.5px; color: var(--text2); }
.exsel-free-inputs { display: flex; gap: 8px; margin-top: 8px; }
.exsel-free-inputs .ios-inp { flex: 1; background: var(--card2); border: 1px solid var(--sep); border-radius: 12px; padding: 10px 12px; }

/* ── Detalle de ejercicio: cabecera modo "picker" (Cancelar / Añadir) ── */
.ex-detail-picker-hdr {
  align-items: center; justify-content: space-between;
  padding: 4px 16px 10px; border-bottom: 1px solid var(--sep); margin-bottom: 4px;
}
.ex-detail-picker-cancel {
  background: none; border: none; color: var(--text2); font-size: 15px;
  cursor: pointer; font-family: inherit; padding: 6px 2px; -webkit-appearance: none;
}
.ex-detail-picker-title { font-size: 15px; font-weight: 700; }
.ex-detail-picker-add {
  background: var(--accent-dim); color: var(--accent); border: none; border-radius: 10px;
  padding: 7px 14px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  -webkit-appearance: none;
}
.ex-detail-picker-add:active { opacity: .7; }
#ex-detail-sheet.picker-mode .handle { display: none; }

/* ── Ajustes de parámetros: subtítulos descriptivos ── */
.ex-sheet-hint { text-align: center; font-size: 12px; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin: -6px 0 10px; }
.ex-param-hint { font-size: 12px; color: var(--text2); margin-top: 2px; font-weight: 400; }
