/* TatamiFit · interfaz monocromo
   Tipografía: Geist + Geist Mono (OFL). Iconos: Phosphor (MIT).
   Paleta: solo neutros (negro, blancos y grises). El rojo aparece solo en acciones destructivas.
   Radios: controles 10px · superficies 16px · chips y puntos completos. */

@font-face { font-family: "Geist"; src: url("../fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("../fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root, [data-theme="dark"] {
  --bg: #0b0b0b;
  --surface: #131313;
  --surface-2: #1b1b1b;
  --surface-3: #272727;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f3f3f3;
  --muted: #a1a1a1;
  --faint: #6a6a6a;
  --inv: #f3f3f3;        /* superficie invertida (botón principal, series hechas) */
  --inv-ink: #0b0b0b;
  --soft: rgba(255, 255, 255, .07);
  --danger: #ef5350;
  --danger-soft: rgba(239, 83, 80, .12);
  --media: #ececec;
  --overlay: rgba(0, 0, 0, .7);
  --shadow: 0 24px 60px -16px rgba(0, 0, 0, .7), 0 0 0 1px var(--line-strong);
  --m-base: #2e2e2e;     /* mapa muscular */
  --m-sec: #8a8a8a;
  --m-pri: #f3f3f3;
  --r-ctl: 10px;
  --r-surf: 16px;
  --top-h: 60px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f6f6;
  --surface: #ffffff;
  --surface-2: #efefef;
  --surface-3: #e2e2e2;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .15);
  --text: #111111;
  --muted: #5e5e5e;
  --faint: #9a9a9a;
  --inv: #111111;
  --inv-ink: #ffffff;
  --soft: rgba(0, 0, 0, .05);
  --danger: #d32f2f;
  --danger-soft: rgba(211, 47, 47, .08);
  --media: #f1f1f1;
  --overlay: rgba(20, 20, 20, .4);
  --shadow: 0 24px 60px -18px rgba(0, 0, 0, .25), 0 0 0 1px var(--line-strong);
  --m-base: #dcdcdc;
  --m-sec: #8f8f8f;
  --m-pri: #111111;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Geist", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden; user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { user-select: text; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.025em; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 17px; letter-spacing: -.015em; }
h3 { font-size: 14.5px; letter-spacing: -.01em; }
.mono, .num { font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
::selection { background: var(--inv); color: var(--inv-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
svg.ic { width: 18px; height: 18px; flex: none; display: inline-block; }
.ic-sm svg.ic { width: 15px; height: 15px; vertical-align: -3px; }

/* ---------- Estructura: barra superior ---------- */
#app { display: grid; grid-template-rows: var(--top-h) 1fr; height: 100vh; }
#topbar {
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 10;
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; flex: none; }
.brand img { border-radius: 8px; display: block; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.02em; }
#nav { display: flex; gap: 2px; flex: 1; justify-content: center; min-width: 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px;
  color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13.5px; position: relative; white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}
.nav-item svg.ic { width: 17px; height: 17px; }
.nav-item:hover { color: var(--text); background: var(--soft); }
.nav-item.active { background: var(--inv); color: var(--inv-ink); }
.nav-item .lbl-s { display: none; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; animation: live 1.6s ease-in-out infinite; }
.nav-item .live-dot { position: absolute; top: 6px; right: 6px; }
@keyframes live { 50% { opacity: .25; } }
#side-active { flex: none; }
.side-wo {
  display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line-strong); max-width: 260px;
  transition: background-color 140ms ease, transform 120ms var(--ease-out);
}
.side-wo:hover { background: var(--surface-3); }
.side-wo:active { transform: scale(.97); }
.side-wo .time { font-family: "Geist Mono", monospace; font-variant-numeric: tabular-nums; font-weight: 500; }
.side-wo .t { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#main { overflow-y: auto; overflow-x: hidden; }
#view { padding: 40px 40px 120px; max-width: 1180px; margin: 0 auto; }
#view.is-focus { max-width: 1480px; padding: 16px 24px 20px; height: calc(100vh - var(--top-h)); display: flex; flex-direction: column; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 30px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 260px; }
.page-head p { margin: 8px 0 0; color: var(--muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease, transform 120ms var(--ease-out);
}
.btn:hover { background: var(--soft); }
.btn:active { transform: scale(.97); }
.btn svg.ic { width: 16px; height: 16px; }
.btn.primary, .btn.green { background: var(--inv); border-color: transparent; color: var(--inv-ink); }
.btn.primary:hover, .btn.green:hover { opacity: .88; background: var(--inv); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--soft); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 0; background: transparent; color: var(--faint); cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 120ms var(--ease-out);
}
.icon-btn:hover { background: var(--soft); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[disabled] { opacity: .25; pointer-events: none; }

/* ---------- Superficies y utilidades ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surf); }
.card { padding: 20px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h3 { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.mt { margin-top: 18px; }
.mt-s { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }

/* Métricas: franja con separadores, números grandes */
.grid:has(> .stat) { gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid.g4.mb:has(> .stat) { margin-bottom: 32px; }
.stat { padding: 18px 20px 20px 0; }
.grid:has(> .stat) > .stat + .stat { padding-left: 20px; border-left: 1px solid var(--line); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 550; margin-top: 6px; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; letter-spacing: 0; }
.stat .hint { color: var(--faint); font-size: 12px; margin-top: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
}
.pill.blue, .pill.green, .pill.orange, .pill.purple { background: var(--inv); color: var(--inv-ink); border-color: transparent; }
.pill.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill svg.ic { width: 13px; height: 13px; }

/* ---------- Formularios ---------- */
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-ctl);
  background: var(--surface-2); border: 1px solid transparent; outline: none;
  transition: border-color 140ms ease, background-color 140ms ease;
}
textarea.input { height: auto; padding: 9px 12px; resize: vertical; min-height: 38px; line-height: 1.45; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--text); background: var(--surface); }
select.input { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%23999'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
label.field { display: flex; flex-direction: column; gap: 7px; font-weight: 500; font-size: 13px; color: var(--muted); }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg.ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search input { padding-left: 36px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13px;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 120ms var(--ease-out);
}
.chip:hover { color: var(--text); }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--inv); border-color: var(--inv); color: var(--inv-ink); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 550; font-size: 13px; white-space: nowrap; flex: none; transition: background-color 160ms ease, color 160ms ease; }
.seg button svg.ic { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--inv); color: var(--inv-ink); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; cursor: pointer; transition: background-color 160ms ease; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: transform 200ms var(--ease-out), background-color 160ms ease; }
.switch input:checked + span { background: var(--inv); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--inv-ink); }
.toggle-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] { accent-color: var(--text); }

/* ---------- Media ---------- */
.media { background: var(--media); border-radius: var(--r-ctl); overflow: hidden; flex: none; display: grid; place-items: center; position: relative; }
.media img { width: 100%; height: 100%; object-fit: contain; display: block; mix-blend-mode: multiply; filter: grayscale(.15); opacity: 0; transition: opacity 200ms ease; }
.media img[src] { opacity: 1; }
.media .ph { color: var(--faint); font-weight: 600; font-size: 13px; }
.media.s40 { width: 40px; height: 40px; border-radius: 8px; }
.media.s52 { width: 48px; height: 48px; }
.media.custom { background: var(--surface-2); }
.media.broken::after { content: "Sin conexión"; font-size: 11px; color: var(--faint); position: absolute; }
.media canvas.gif, .media img.gif, .media video.gif { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 180ms ease; mix-blend-mode: multiply; pointer-events: none; }
.media canvas.gif.ready, .media img.gif.ready, .media video.gif.ready { opacity: 1; }
.media video.gif { object-fit: contain; background: transparent; }
.media:has(> .gif.ready) > img[data-media] { visibility: hidden; }

.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 24px 16px; }
.ex-grid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ex-card { cursor: pointer; display: flex; flex-direction: column; gap: 10px; position: relative; }
.ex-card .media { width: 100%; aspect-ratio: 1; border-radius: var(--r-surf); transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .ex-card:hover .media { transform: translateY(-2px); } }
.ex-card .body { padding: 0 2px; }
.ex-card .name { font-weight: 550; font-size: 13.5px; line-height: 1.35; }
.ex-card .sub { color: var(--faint); font-size: 12px; margin-top: 2px; }
.ex-card.sel .media { box-shadow: 0 0 0 2px var(--text); }
.ex-card .check {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--inv); color: var(--inv-ink); display: grid; place-items: center;
  opacity: 0; transform: scale(.9); transition: opacity 150ms ease, transform 150ms var(--ease-out);
}
.ex-card.sel .check { opacity: 1; transform: scale(1); }
.ex-card .check svg.ic { width: 14px; height: 14px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.click { cursor: pointer; border-radius: var(--r-ctl); padding: 10px; border-bottom: 0; transition: background-color 140ms ease; }
.list-item.click:hover { background: var(--soft); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { color: var(--faint); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.routine-card { display: flex; flex-direction: column; gap: 12px; transition: border-color 160ms ease; }
.routine-card:hover { border-color: var(--line-strong); }
.routine-card .title { display: flex; align-items: center; gap: 8px; }
.routine-card .title h3 { flex: 1; }
.routine-card .exlist { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumbs { display: flex; gap: 6px; }

/* ---------- Bloques de ejercicio (lista y editor) ---------- */
.ex-block { border-top: 1px solid var(--line); padding: 22px 0 18px; }
.ex-block:first-child { border-top: 0; padding-top: 4px; }
.ex-block-head { display: flex; align-items: center; gap: 12px; }
.ex-block-head .name { font-weight: 600; font-size: 15.5px; cursor: pointer; }
.ex-block-head .name:hover { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.ex-block .note { margin-top: 12px; background: transparent; border-color: var(--line); }
.ex-block .note:focus { background: var(--surface); }
.ex-block .opts { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.ex-block .opts svg.ic { width: 15px; height: 15px; }
.ex-block .opts select { width: auto; height: 30px; font-size: 13px; }
table.sets { width: 100%; border-collapse: separate; border-spacing: 0 3px; margin-top: 12px; }
table.sets th { text-align: center; font-size: 11.5px; color: var(--faint); font-weight: 550; padding: 4px; }
table.sets th svg.ic { width: 14px; height: 14px; }
table.sets td { text-align: center; padding: 3px 4px; transition: background-color 180ms ease; }
table.sets tr.row-set td:first-child { border-radius: 9px 0 0 9px; }
table.sets tr.row-set td:last-child { border-radius: 0 9px 9px 0; }
table.sets tr.done td { background: var(--soft); }
table.sets input { width: 76px; height: 32px; text-align: center; border-radius: 8px; border: 1px solid transparent; background: var(--surface-2); outline: none; font-family: "Geist Mono", monospace; font-variant-numeric: tabular-nums; font-weight: 500; }
table.sets input::placeholder { color: var(--faint); }
table.sets input:focus { border-color: var(--text); }
table.sets tr.done input { background: transparent; }
table.sets .prev { color: var(--faint); font-size: 12.5px; cursor: pointer; min-width: 90px; font-family: "Geist Mono", monospace; }
table.sets .prev:hover { color: var(--text); }
.set-type { width: 30px; height: 28px; border-radius: 8px; border: 0; cursor: pointer; font-weight: 600; background: transparent; color: var(--muted); font-family: "Geist Mono", monospace; }
.set-type:hover { background: var(--soft); }
.set-type.warmup, .set-type.drop, .set-type.failure { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.check-btn { width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line-strong); cursor: pointer; background: transparent; color: var(--faint); display: inline-grid; place-items: center; transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out); }
.check-btn:active { transform: scale(.92); }
.check-btn svg.ic { width: 16px; height: 16px; }
.check-btn.on { background: var(--inv); border-color: transparent; color: var(--inv-ink); }
.add-set { margin-top: 6px; width: 100%; border-style: dashed; color: var(--muted); }
.modal.modify .ex-block-head [data-act="up"], .modal.modify .ex-block-head [data-act="down"], .modal.modify .ex-block-head [data-act="delex"] { display: none; }
.modal.modify .ex-block { border-top: 0; padding-top: 0; }

/* ---------- Entrenamiento: cabecera ---------- */
.wo-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 18px 0 16px; margin: -18px 0 16px; border-bottom: 1px solid var(--line); }
#view.is-focus .wo-head { position: static; margin: 0 0 14px; padding: 0 0 12px; flex: none; }
#view.is-focus .wo-stats { margin-top: 6px; }
.wo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-input { flex: 1; min-width: 200px; background: transparent; border: 0; outline: none; font-size: 24px; font-weight: 600; letter-spacing: -.025em; padding: 0; }
.wo-stats { display: flex; gap: 34px; margin-top: 12px; align-items: flex-end; flex-wrap: wrap; row-gap: 8px; }
.wo-stats .k { color: var(--faint); font-size: 12px; font-weight: 500; }
.wo-stats .v { font-family: "Geist Mono", monospace; font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 500; letter-spacing: -.03em; }
.wo-progress { flex: 1; min-width: 160px; max-width: 360px; }
.wo-pbar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.wo-pbar > div { height: 100%; background: var(--text); border-radius: 4px; transition: width 300ms var(--ease-out); }

/* ---------- Modo enfoque ---------- */
.focus {
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .85fr) minmax(0, 1.05fr);
  grid-template-rows: minmax(0, .78fr) minmax(0, 1.22fr) auto;
  grid-template-areas:
    "timer next gif"
    "timer steps muscles"
    "ctrl  steps muscles";
  flex: 1; min-height: 0;
}
#view.is-focus > [data-focus] { flex: 1; min-height: 540px; display: flex; flex-direction: column; }
.panel { padding: 16px; min-height: 0; display: flex; flex-direction: column; }
.p-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex: none; }
.p-head h3 { flex: 1; font-size: 13px; color: var(--muted); font-weight: 550; letter-spacing: 0; }

.f-timer { grid-area: timer; container-type: inline-size; padding: 22px 24px; position: relative; overflow: hidden; }
.f-timer[data-state="rest"] { background: var(--inv); color: var(--inv-ink); border-color: transparent; }
.f-timer[data-state="rest"] .f-phase, .f-timer[data-state="rest"] .f-prev, .f-timer[data-state="rest"] .st-l { color: var(--inv-ink); opacity: .6; }
.f-timer[data-state="rest"] .f-exname { color: var(--inv-ink); }
.f-timer[data-state="rest"] .f-bar { background: color-mix(in srgb, var(--inv-ink) 15%, transparent); }
.f-timer[data-state="rest"] .f-bar > div { background: var(--inv-ink); }
.f-timer[data-state="rest"] .f-dot { border-color: color-mix(in srgb, var(--inv-ink) 30%, transparent); color: var(--inv-ink); }
.f-timer[data-state="rest"] .f-dot.done { background: var(--inv-ink); color: var(--inv); }
.f-timer[data-state="rest"] .stepper .st-row { background: color-mix(in srgb, var(--inv-ink) 8%, transparent); }
.f-timer[data-state="rest"] .f-adjust .btn { color: var(--inv-ink); border-color: color-mix(in srgb, var(--inv-ink) 30%, transparent); }
.f-timer { transition: background-color 300ms ease, color 300ms ease; }
.f-head { display: flex; flex-direction: column; gap: 4px; }
.f-phase { font-size: 13px; font-weight: 550; color: var(--muted); }
.f-exname { all: unset; cursor: pointer; font-size: clamp(18px, 4.2cqi, 26px); font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }
.f-exname:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.f-clock-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: stretch; min-height: 0; }
.f-clock { font-size: clamp(64px, 27cqi, 220px); font-weight: 300; letter-spacing: -.06em; line-height: .95; font-variant-numeric: tabular-nums; text-align: center; }
.f-bar { height: 3px; border-radius: 3px; background: var(--surface-3); margin: 18px auto 0; width: 70%; overflow: hidden; }
.f-bar > div { height: 100%; background: var(--text); transition: width 120ms linear; }
.f-adjust { display: flex; gap: 8px; justify-content: center; margin-top: 14px; visibility: hidden; }
.f-adjust.on { visibility: visible; }
.f-sets { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 4px 0 16px; }
.f-dot { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 500 12.5px "Geist Mono", monospace; cursor: default; display: grid; place-items: center; transition: background-color 200ms ease, color 200ms ease, transform 200ms var(--ease-out); }
.f-dot.cur { border-color: var(--text); color: var(--text); transform: scale(1.08); }
.f-dot.done { background: var(--text); color: var(--bg); border-color: transparent; cursor: pointer; }
.f-values { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.f-values-done { text-align: center; color: var(--muted); padding: 12px 0; }
.stepper { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.st-l { font-size: 11.5px; color: var(--faint); font-weight: 550; letter-spacing: .02em; }
.st-row { display: flex; align-items: center; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.st-b { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; transition: background-color 140ms ease, transform 120ms var(--ease-out); }
.st-b:hover { background: var(--soft); }
.st-b:active { transform: scale(.9); }
.st-b svg.ic { width: 16px; height: 16px; }
.st-v { width: 72px; height: 36px; border: 0; background: transparent; text-align: center; font: 500 22px "Geist", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.03em; outline: none; -moz-appearance: textfield; }
.st-v::-webkit-inner-spin-button, .st-v::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.f-prev { text-align: center; font-size: 12.5px; color: var(--faint); margin-top: 12px; }

.f-ctrl { grid-area: ctrl; display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 10px; }
.f-btn {
  height: 64px; border-radius: var(--r-surf); border: 1px solid var(--line-strong); background: var(--surface);
  display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14.5px;
  transition: background-color 140ms ease, transform 120ms var(--ease-out), opacity 140ms ease;
}
.f-btn:hover { background: var(--surface-2); }
.f-btn:active { transform: scale(.97); }
.f-btn svg.ic { width: 22px; height: 22px; }
.f-btn[disabled] { opacity: .35; pointer-events: none; }
.f-play { background: var(--inv); color: var(--inv-ink); border-color: transparent; }
.f-play:hover { background: var(--inv); opacity: .9; }
.f-done { border-color: var(--text); }

.f-next { grid-area: next; padding: 14px 10px 10px 14px; }
.f-next .p-head { padding-right: 6px; }
.f-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; min-height: 0; }
.f-item { all: unset; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer; transition: background-color 140ms ease; }
.f-item:hover { background: var(--soft); }
.f-item.cur { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.f-item.done .f-item-n { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.f-item-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.f-item-n { font-weight: 550; font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-item-s { font-size: 12px; color: var(--faint); }
.f-item-ok { width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; flex: none; }
.f-item-ok svg.ic { width: 13px; height: 13px; }
.f-add { margin-top: 6px; align-self: flex-start; }

.f-gif { grid-area: gif; padding: 8px; }
.f-gif .p-head { margin-bottom: 6px; padding: 0 2px; }
.f-gif-t { text-align: center; }
.f-gif .media.f-media { flex: 1; width: 100%; min-height: 0; border-radius: 12px; }
.f-gif .media.f-media img, .f-gif .media.f-media canvas { object-fit: contain; }
.f-gif .media.f-media canvas.gif, .f-gif .media.f-media video.gif { width: auto; height: 100%; max-width: 100%; aspect-ratio: 1; left: 50%; transform: translateX(-50%); }

.f-steps { grid-area: steps; overflow-y: auto; }
.f-steps .steps { font-size: 13.5px; }
.f-note { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--surface-2); font-size: 13px; }

.f-muscles { grid-area: muscles; }
.body-map { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-height: 0; }
.body-fig { margin: 0; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.body-fig svg { flex: 1; width: 100%; min-height: 0; }
.body-fig polygon { fill: var(--m-base); transition: fill 200ms ease; }
.body-fig polygon.m-h { fill: var(--surface-3); }
.body-fig polygon.m-s { fill: var(--m-sec); }
.body-fig polygon.m-p { fill: var(--m-pri); }
.body-fig figcaption { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.f-mus-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12.5px; }
.f-mus-list > div { display: flex; gap: 8px; }
.f-mus-list .k { color: var(--faint); min-width: 82px; }
.f-mus-list > div:first-child span:last-child { font-weight: 600; }
.focus-empty { align-items: center; text-align: center; padding: 60px 20px; gap: 8px; }
.focus-empty svg.ic { width: 34px; height: 34px; color: var(--faint); }
.focus-empty p { margin: 0 0 8px; }

/* Barra de descanso flotante (fuera del modo enfoque) */
#restbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 40;
  background: var(--inv); color: var(--inv-ink); border-radius: 18px; box-shadow: var(--shadow);
  padding: 10px 10px 10px 20px; display: flex; align-items: center; gap: 10px; min-width: 420px; overflow: hidden;
  animation: barIn 220ms var(--ease-out);
}
#restbar[hidden] { display: none; }
#restbar .btn { color: var(--inv-ink); border-color: color-mix(in srgb, var(--inv-ink) 25%, transparent); }
#restbar .btn.primary { background: var(--inv-ink); color: var(--inv); }
#restbar .rb-prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--inv-ink); opacity: .5; transition: width 200ms linear; }
#restbar .rb-time { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 500; letter-spacing: -.04em; min-width: 80px; }
#restbar .rb-label { opacity: .6; font-size: 12px; font-weight: 500; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes barIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Modales ---------- */
.modal-back { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: grid; place-items: center; padding: 28px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 160ms ease-out; }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); width: min(540px, 100%); max-height: calc(100vh - 56px); display: flex; flex-direction: column; animation: pop 200ms var(--ease-out); }
.modal.wide { width: min(1000px, 100%); }
.modal.mid { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 20px 22px 6px; }
.modal-head h2 { flex: 1; font-size: 19px; }
.modal-body { padding: 14px 22px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

.detail { display: grid; grid-template-columns: 340px 1fr; gap: 28px; }
.detail .big { width: 340px; height: 340px; border-radius: var(--r-surf); }
.detail .body-map { height: 220px; margin-top: 16px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 9px; color: var(--muted); }
.steps li { line-height: 1.55; padding-left: 4px; }
.steps li::marker { color: var(--faint); font-family: "Geist Mono", monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv .k { color: var(--faint); }
.attr { font-size: 11px; color: var(--faint); margin-top: 8px; }

#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--surface); box-shadow: var(--shadow); padding: 12px 16px; border-radius: 12px; max-width: 360px; font-size: 13.5px; animation: toastIn 240ms var(--ease-out); transition: opacity 200ms ease, transform 200ms ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Gráficos ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 40px; background: var(--surface-3); border-radius: 6px; min-height: 3px; }
.bars .bar-col:last-child .bar:not(.zero) { background: var(--text); }
.bars .bar.zero { background: var(--surface-2); }
.bars .bar-val { font-size: 11.5px; color: var(--muted); font-family: "Geist Mono", monospace; }
.bars .bar-lbl { font-size: 11px; color: var(--faint); font-family: "Geist Mono", monospace; }
.hbar { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.hbar .track { height: 6px; border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--text); border-radius: 6px; }
.hbar b { font-family: "Geist Mono", monospace; font-weight: 500; text-align: right; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--faint); font-weight: 500; padding-bottom: 4px; }
.cal .day { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; color: var(--muted); font-family: "Geist Mono", monospace; }
.cal .day.out { visibility: hidden; }
.cal .day.today { box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text); }
.cal .day.has { background: var(--inv); color: var(--inv-ink); font-weight: 600; cursor: pointer; }
.cal .day.bjj { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Temporizadores ---------- */
.timer-display { font-variant-numeric: tabular-nums; font-size: clamp(72px, 12vw, 160px); font-weight: 250; text-align: center; letter-spacing: -.055em; line-height: 1; }
.timer-phase { text-align: center; font-size: 14px; font-weight: 550; margin-bottom: 14px; color: var(--muted); }
.timer-phase.work, .timer-phase.prep { color: var(--text); }
.timer-wrap { padding: 40px 20px 30px; text-align: center; }
.timer-ring { height: 3px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin: 28px auto 0; max-width: 520px; }
.timer-ring > div { height: 100%; background: var(--text) !important; transition: width 200ms linear; }
.laps { max-width: 420px; margin: 18px auto 0; text-align: left; }
.num-input { width: 90px; text-align: center; font-family: "Geist Mono", monospace; }

/* ---------- BJJ ---------- */
.tech-card { cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color 160ms ease; }
.tech-card:hover { border-color: var(--line-strong); }
.tech-card .en { color: var(--faint); font-size: 12.5px; }
.pill.lvl1 { color: var(--muted); }
.pill.lvl2 { color: var(--text); border-color: var(--text); }
.pill.lvl3 { background: var(--inv); color: var(--inv-ink); border-color: transparent; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .wd { border-radius: 14px; padding: 12px 8px; text-align: center; background: var(--surface-2); min-height: 82px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.week .wd .d { font-weight: 550; font-size: 12px; color: var(--faint); }
.week .wd.today { box-shadow: inset 0 0 0 1px var(--text); }
.week .wd .what { font-size: 12.5px; font-weight: 550; line-height: 1.3; }
.week .wd .dot { display: none; }
.week .wd.k-bjj { background: var(--inv); color: var(--inv-ink); }
.week .wd.k-bjj .d { color: var(--inv-ink); opacity: .6; }
.week .wd.k-kb { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.week .wd.k-kb.today { box-shadow: inset 0 0 0 2px var(--text); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty svg.ic { width: 34px; height: 34px; color: var(--faint); margin-bottom: 12px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px 14px 20px; border-radius: var(--r-surf); background: var(--surface-2); margin-bottom: 24px; }
.pr { color: var(--text); font-weight: 650; }
.click-card { transition: border-color 160ms ease; }
.click-card:hover { border-color: var(--line-strong); }

/* ---------- Layouts ---------- */
.split { align-items: start; }
.split-dash { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.split-side { grid-template-columns: minmax(0, 1fr) 320px; }
.side-sticky { position: sticky; top: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .nav-item .lbl { display: none; }
  .nav-item { width: 40px; padding: 0; justify-content: center; }
  .side-wo .t { display: none; }
}
@media (max-width: 1100px) {
  #view.is-focus { height: auto; display: block; }
  #view.is-focus > [data-focus] { display: block; min-height: 0; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g4:has(> .stat) > .stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .grid.g4:has(> .stat) > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  #view { padding: 30px 28px 110px; }
  .split-dash, .split-side { grid-template-columns: minmax(0, 1fr); }
  .side-sticky { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .detail { grid-template-columns: 260px 1fr; gap: 22px; }
  .detail .big { width: 260px; height: 260px; }
  .cal .day { aspect-ratio: auto; height: 36px; border-radius: 10px; }
  /* modo enfoque en dos columnas */
  .focus {
    flex: none; min-height: 0;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "timer gif" "ctrl gif" "next muscles" "steps muscles";
  }
  .f-timer { min-height: 440px; }
  .f-gif { min-height: 300px; }
  .f-next { max-height: 340px; }
  .f-muscles { min-height: 320px; }
}
@media (max-width: 720px) {
  #app { grid-template-rows: 54px 1fr; }
  #topbar { padding: 0 14px; }
  #nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg); border-top: 1px solid var(--line);
    padding: 6px 8px; justify-content: space-around; gap: 0;
  }
  .nav-item { flex-direction: column; flex: 1; width: auto; height: 52px; gap: 3px; border-radius: 12px; }
  .nav-item.active { background: var(--surface-2); color: var(--text); }
  .nav-item > .lbl-s { display: block; font-size: 10.5px; }
  #topbar { justify-content: space-between; }
  #view, #view.is-focus { padding: 20px 16px 100px; }
  h1 { font-size: 24px; }
  .page-head { margin-bottom: 20px; align-items: flex-start; }
  .page-head .grow { min-width: 100%; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .grid.g4:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g3:has(> .stat) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.g3:has(> .stat) > .stat + .stat { padding-left: 12px; }
  .stat .value { font-size: 22px; }
  .side-sticky { grid-template-columns: minmax(0, 1fr); }
  .ex-grid, .ex-grid.compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 12px; }
  .search { min-width: 100%; }
  [data-f] { width: auto !important; flex: 1 1 140px; }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail .big { width: 100%; height: auto; aspect-ratio: 1; max-width: 360px; margin: 0 auto; }
  .modal-back { padding: 10px; place-items: end center; }
  .modal { width: 100% !important; max-height: calc(100vh - 20px); }
  table.sets input { width: 56px; height: 30px; font-size: 13px; }
  table.sets .prev { min-width: 0; font-size: 11.5px; }
  .ex-block-head .icon-btn[data-act="up"], .ex-block-head .icon-btn[data-act="down"] { display: none; }
  .title-input { font-size: 20px; min-width: 100%; }
  .wo-stats { gap: 18px; }
  .wo-progress { min-width: 100%; }
  .focus { grid-template-columns: minmax(0, 1fr); grid-template-areas: "timer" "ctrl" "gif" "next" "steps" "muscles"; }
  .f-timer { min-height: 400px; padding: 18px; }
  .f-gif { min-height: 0; }
  .f-gif .media.f-media { aspect-ratio: 1; flex: none; }
  .f-btn { height: 58px; }
  .f-btn span { display: none; }
  .f-btn.f-play span, .f-btn.f-done span { display: inline; }
  #restbar { bottom: 76px; min-width: 0; width: calc(100% - 24px); padding-left: 14px; }
  #toast-root { bottom: 84px; right: 12px; max-width: calc(100% - 24px); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .timer-wrap { padding: 28px 8px 20px; }
  .timer-wrap .row { flex-wrap: wrap; }
  .page-head > .seg { width: 100%; }
}
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .wo-row .seg { flex: 1; }
}
@media (max-width: 420px) {
  .nav-item > .lbl-s { display: none; }
  .nav-item { height: 44px; }
  table.sets .prev, table.sets .th-prev { display: none; }
  .brand-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- iPhone / web ---------- */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { height: 100dvh; }
#topbar { padding-top: env(safe-area-inset-top); padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
@supports (padding: env(safe-area-inset-top)) {
  #app { grid-template-rows: calc(var(--top-h) + env(safe-area-inset-top)) 1fr; }
}
@media (max-width: 720px) {
  #app { grid-template-rows: calc(54px + env(safe-area-inset-top)) 1fr; }
  #nav { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  #view, #view.is-focus { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  #restbar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  #toast-root { bottom: calc(84px + env(safe-area-inset-bottom)); }
  /* iOS hace zoom en campos con letra menor a 16px */
  .input, select.input, textarea.input, table.sets input, .title-input, .st-v { font-size: 16px; }
  .title-input { font-size: 20px; }
  .st-v { font-size: 22px; }
}
@media (hover: none) {
  .nav-item:not(.active):hover { background: transparent; color: var(--muted); }
}
