/* Single hue: toda la interfaz sale de una escala de teal (Ice White → Deep Teal).
   Soft Peach es el único acento: músculo principal, fase activa, progreso y temporizador. */
:root {
  --t50: #F4F8FA; --t100: #E4EEF1; --t200: #CBDDE3; --t300: #9EC0CA; --t400: #6B98A5;
  --t500: #3F7280; --t600: #2A5965; --t700: #1B4955; --t800: #0F3D47; --t900: #0A2C34; --t950: #061E24;
  --peach: #F59E7B; --peach-50: #FEF3EE; --peach-100: #FCE1D5; --peach-700: #9A4426;

  --bg: var(--t950); --bg2: var(--t900); --card: #0B323B; --card2: #12434E; --line: rgba(158, 192, 202, .14); --line-strong: rgba(158, 192, 202, .3);
  --text: var(--t50); --muted: var(--t300); --dim: var(--t400);
  --accent: var(--peach); --accent-ink: var(--t950); --accent-hover: #F8B497;
  --prim: var(--peach); --sec: var(--t300); --ok: var(--t300); --danger: #F28B6E;
  --stage: radial-gradient(60% 55% at 50% 42%, rgba(245, 158, 123, .30), rgba(245, 158, 123, .06) 55%, transparent 75%), radial-gradient(120% 90% at 50% 100%, #0F3D47, #061E24 70%);
  --glass: rgba(4, 22, 27, .62);
  --glow: 0 0 0 1px rgba(245, 158, 123, .35), 0 10px 30px -10px rgba(245, 158, 123, .55);
  --r: 14px; --r-sm: 10px;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 18px 40px -26px rgba(0, 0, 0, .8);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--peach); outline-offset: 2px; }
::selection { background: var(--line-strong); }
h1, h2, h3 { margin: 0; font-family: var(--font); }
h1 { font-size: 32px; font-weight: 700; line-height: 1.08; letter-spacing: -.025em; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--dim); letter-spacing: .16em; }
.muted { color: var(--muted); }
.svg-ico, nav svg, .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Fotos de la base de datos teñidas al tono único */
.card .ph img, .photos img, .thumbs img, .item img, .pick img, .next img {
  filter: grayscale(1) sepia(.5) hue-rotate(150deg) saturate(1.3) contrast(1.08) brightness(.82);
}

/* ---------- Top ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(6, 30, 36, .78); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: .05em; color: var(--t50); }
.brand b { color: var(--peach); margin-left: 4px; font-weight: 800; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tabs a:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.tabs a.on { color: var(--accent-ink); background: var(--accent); }
.sync { width: 9px; height: 9px; border-radius: 50%; background: var(--t300); }
.sync.ok { background: var(--t300); } .sync.err { background: var(--danger); } .sync.busy { background: var(--peach); }

main { max-width: 1320px; margin: 0 auto; padding: 22px 20px 100px; outline: none; }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; white-space: nowrap; transition: background .15s, transform .1s, border-color .15s; }
.btn:hover { background: var(--card2); border-color: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 10px 28px -12px rgba(245, 158, 123, .7); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.outline { background: transparent; border-color: var(--peach); color: var(--peach); }
.btn.outline:hover { background: rgba(245, 158, 123, .1); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 42px; padding: 0; }
.btn.sm.icon { width: 34px; }
.btn.big { min-height: 56px; font-size: 17px; padding: 0 26px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
.input::placeholder { color: var(--t400); }
.input:focus { border-color: var(--peach); outline: none; box-shadow: 0 0 0 3px rgba(245, 158, 123, .18); }
.search { position: relative; flex: 1 1 260px; }
.search svg { position: absolute; left: 12px; top: 11px; width: 20px; height: 20px; stroke: var(--dim); fill: none; stroke-width: 2; }
.search .input { padding-left: 40px; border-radius: 999px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 13px; }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.on { background: var(--t50); color: var(--t950); border-color: transparent; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--t50); color: var(--t950); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--card2); color: var(--t200); }
.tag.p { background: rgba(245, 158, 123, .16); color: var(--peach); }
.tag.s { background: rgba(158, 192, 202, .12); color: var(--t100); }
.tag.home { background: var(--card2); color: var(--t200); }
.tag.warn { background: transparent; color: var(--t300); box-shadow: inset 0 0 0 1px var(--line-strong); }
.card .lvl { background: rgba(4, 22, 27, .7); color: var(--t50); backdrop-filter: blur(6px); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Biblioteca ---------- */
.hero { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.hero p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.filters .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; border-radius: var(--r); overflow: hidden; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: rgba(245, 158, 123, .45); }
.card .ph { position: relative; aspect-ratio: 4/3; background: var(--card2); overflow: hidden; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .25s; }
.card .ph img + img { position: absolute; inset: 0; opacity: 0; }
.card:hover .ph img + img { opacity: 1; }
.card .lvl { position: absolute; left: 8px; top: 8px; }
.card .body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card .name { font-weight: 700; line-height: 1.25; }
.card .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.count { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r); }

/* ---------- Detalle ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.back:hover { color: var(--text); }
.stage { position: sticky; top: 76px; }
.viewer { position: relative; height: min(68vh, 640px); min-height: 360px; border-radius: var(--r); overflow: hidden; background: var(--stage); touch-action: none; box-shadow: var(--shadow); color: var(--t50); }
.viewer-canvas { width: 100%; height: 100%; display: block; }
.v-top { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.v-top > * { pointer-events: auto; }
.phase { padding: 6px 11px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(6px); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--t50); }
.phase i { width: 8px; height: 8px; border-radius: 50%; background: var(--peach); }
.legend { display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; border-radius: 10px; background: var(--glass); font-size: 12px; color: var(--line-strong); }
.legend span { display: flex; align-items: center; gap: 6px; }
.v-bot { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.v-bot .seg { background: var(--glass); border-color: rgba(203, 221, 227, .18); backdrop-filter: blur(6px); }
.v-bot .seg button { color: var(--line-strong); }
.v-bot .seg button.on { background: var(--t50); color: var(--t800); }
.hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: 58px; font-size: 12px; color: var(--t300); pointer-events: none; }
.info { display: flex; flex-direction: column; gap: 18px; }
.info .head { display: flex; flex-direction: column; gap: 10px; }
.info .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.panel h3 { margin-bottom: 10px; }
ol.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
ol.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; line-height: 1.45; }
ol.steps li::before { content: counter(s, decimal-leading-zero); width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--t200); font-weight: 700; display: grid; place-items: center; font-size: 11px; font-family: var(--font); transition: .2s; }
ul.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
ul.tips li::marker { color: var(--t400); }
.err { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: rgba(245, 158, 123, .08); box-shadow: inset 2px 0 0 var(--peach); color: #F9C3AC; line-height: 1.4; }
.err b { color: var(--peach); }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photos figure { margin: 0; border-radius: var(--r-sm); overflow: hidden; background: var(--card2); position: relative; }
.photos img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.photos figcaption { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--glass); color: var(--t50); }
details.en summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.en ol { color: var(--muted); font-size: 13px; line-height: 1.5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Rutinas ---------- */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.rcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.rcard .thumbs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.rcard .thumbs img { width: 100%; aspect-ratio: 4/3; height: auto; object-fit: cover; border-radius: 6px; background: var(--card2); }
.rcard .stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.rcard .stats b { color: var(--text); }
.rcard .row { display: flex; gap: 8px; margin-top: auto; }
.editor-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.editor-head .input.title { font-family: var(--font); font-size: 26px; font-weight: 700; letter-spacing: -.02em; flex: 1 1 280px; background: transparent; border-color: transparent; padding-left: 0; box-shadow: none; }
.editor-head .input.title:hover, .editor-head .input.title:focus { border-color: var(--line); padding-left: 10px; background: var(--bg2); }
.items { display: flex; flex-direction: column; gap: 10px; }
.item { display: grid; grid-template-columns: 30px 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; box-shadow: var(--shadow); }
.item .num { font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--t300); text-align: center; }
.item img { width: 72px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--card2); }
.item .nm { font-weight: 700; margin-bottom: 8px; display: block; }
.item .nm:hover { color: var(--peach); }
.fields { display: flex; gap: 8px; flex-wrap: wrap; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.fields .input { min-height: 36px; padding: 6px 9px; width: 76px; }
.fields .input.wide { width: 160px; }
.item .ops { display: flex; flex-direction: column; gap: 4px; }
.add-row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 10, 12, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.sheet { width: min(760px, 100%); max-height: min(86dvh, 860px); background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px -20px rgba(6, 30, 36, .5); }
.sheet header { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.sheet header .t { display: flex; justify-content: space-between; align-items: center; }
.sheet .list { overflow: auto; padding: 8px; }
.pick { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 10px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); }
.pick:hover { background: var(--card2); }
.pick.added { background: rgba(245, 158, 123, .14); }
.pick img { width: 56px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--card2); }
.pick .s { font-size: 12px; color: var(--muted); }
.sheet .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.sheet .pad { padding: 18px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Entrenar ---------- */
.train { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; }
.progress { height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; margin: 12px 0 18px; }
.progress i { display: block; height: 100%; background: var(--peach); transition: width .3s; }
.train .viewer { height: min(60vh, 560px); }
.setbox { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.setnum { font-family: var(--display); font-size: 58px; font-weight: 800; line-height: 1; letter-spacing: .01em; }
.setnum small { font-size: 22px; color: var(--muted); }
.target { font-size: 20px; font-weight: 700; }
.dots { display: flex; gap: 6px; }
.dots i { width: 28px; height: 6px; border-radius: 9px; background: var(--card2); }
.dots i.done { background: var(--t300); } .dots i.cur { background: var(--peach); box-shadow: 0 0 12px rgba(245, 158, 123, .7); }
.big-in { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-in label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg2); }
.stepper button { border: 0; background: var(--card2); color: var(--t50); font-size: 20px; font-weight: 600; }
.stepper button:hover { background: var(--line-strong); }
.stepper input { border: 0; background: transparent; text-align: center; font-size: 22px; font-weight: 800; min-width: 0; padding: 8px 0; color: var(--text); }
.next { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.next img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; }
.rest { position: fixed; inset: 0; z-index: 40; background: radial-gradient(50% 40% at 50% 45%, rgba(245, 158, 123, .18), transparent 70%), rgba(4, 22, 27, .97); color: var(--t50); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px; text-align: center; }
.rest[hidden] { display: none; }
.rest .muted { color: var(--t300); }
.rest .muted b { color: var(--t50) !important; }
.rest .btn { background: rgba(244, 248, 250, .1); color: var(--t50); border-color: rgba(244, 248, 250, .25); }
.rest .btn.primary { background: var(--peach); color: var(--t900); border-color: transparent; }
.ring { position: relative; width: 240px; height: 240px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .bgc { stroke: rgba(244, 248, 250, .14); } .ring .fg { stroke: var(--peach); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring .t { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 72px; font-weight: 800; }
.summary { max-width: 560px; margin: 30px auto; text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-family: var(--display); font-size: 30px; }
.kpi span { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 600; }

/* ---------- Historial ---------- */
.hist { display: flex; flex-direction: column; gap: 10px; }
.hrow { display: grid; grid-template-columns: 64px 1fr auto auto; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.hdate { text-align: center; font-family: var(--display); line-height: 1; }
.hdate b { font-size: 28px; display: block; } .hdate span { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 18px; max-width: 420px; }
.week div { text-align: center; font-size: 11px; color: var(--muted); }
.week i { display: block; height: 34px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); margin-top: 4px; }
.week i.on { background: var(--peach); border-color: transparent; box-shadow: 0 0 14px rgba(245, 158, 123, .5); }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 60; background: var(--t50); color: var(--t950); padding: 10px 16px; border-radius: 999px; font-weight: 600; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail, .train { grid-template-columns: minmax(0, 1fr); }
  .stage { position: relative; top: 0; }
  .viewer { height: 56vh; min-height: 320px; }
  .train .viewer { height: 44vh; min-height: 280px; }
}
@media (max-width: 760px) {
  .top { padding: 10px 16px; backdrop-filter: none; background: var(--bg); }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; justify-content: space-around; background: rgba(244, 248, 250, .97); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 6px max(6px, env(safe-area-inset-bottom)); z-index: 30; }
  .tabs a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 14px; border-radius: 12px; }
  .sync { margin-left: auto; }
  .hint { display: none; }
  .v-bot { gap: 6px; }
  .v-bot .seg button { padding: 6px 10px; }
}
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  main { padding: 16px 16px 96px; }
  h1 { font-size: 25px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card .body { padding: 9px 10px 11px; }
  .card .name { font-size: 13px; }
  .item { grid-template-columns: 56px minmax(0, 1fr); }
  .item .num { display: none; }
  .item img { width: 56px; height: 44px; }
  .item .ops { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .fields .input { width: 64px; } .fields .input.wide { width: 120px; }
  .hrow { grid-template-columns: 52px 1fr auto; }
  .hrow .vol { display: none; }
  .setnum { font-size: 44px; }
  .ring { width: 200px; height: 200px; }
  .legend { display: none; }
}
/* =========================================================
   Pulido premium + móvil
   ========================================================= */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-feature-settings: "cv11", "ss01", "ss03"; }
h1 { letter-spacing: .005em; }
.btn, .chip, .seg button, .tabs a, .pick, .card { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.chip:active, .seg button:active, .tabs a:active { transform: scale(.96); }
.card:active { transform: scale(.985); }
.eyebrow { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--t300); margin-bottom: 8px; }
.eyebrow::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--peach); margin-right: 8px; vertical-align: 1px; }

/* Visor: barra de vistas bajo el 3D */
.v-tools { margin-top: 10px; display: flex; }
.seg-fill { display: flex; width: 100%; }
.seg-fill button { flex: 1; min-height: 36px; }
.v-bot { justify-content: space-between; }

/* CTA y barra de entrenamiento */
.cta-bar { display: flex; }
.cta-bar .btn { flex: 1; }
.trainbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.tb-title { display: flex; flex-direction: column; min-width: 0; text-align: center; line-height: 1.2; }
.tb-title b { font-family: var(--font); font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title span { font-size: 12px; color: var(--muted); }
.go-bar { display: flex; }
.go-bar .btn { flex: 1; }

@media (max-width: 760px) {
  /* Barra de pestañas flotante tipo cristal */
  .tabs {
    left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 6px;
    border: 1px solid rgba(158, 192, 202, .16); border-radius: 24px;
    background: rgba(10, 44, 52, .78); backdrop-filter: saturate(1.4) blur(18px); -webkit-backdrop-filter: saturate(1.4) blur(18px);
    box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .05);
  }
  .tabs a { flex: 1; justify-content: center; min-height: 52px; border-radius: 18px; font-size: 11px; font-weight: 600; }
  .tabs a svg { width: 22px; height: 22px; }
  main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  .top { min-height: calc(54px + env(safe-area-inset-top)); }
  .brand { font-size: 19px; }

  /* Modo entrenamiento inmersivo: sin cabecera ni pestañas */
  body.immersive .top, body.immersive .tabs { display: none; }
  body.immersive main { padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  body.immersive .progress { margin: 10px 0 14px; }
}

@media (max-width: 640px) {
  /* Tipografía y objetivos táctiles */
  h1 { font-size: 27px; }
  .btn { min-height: 46px; }
  .btn.sm { min-height: 38px; }
  .btn.sm.icon { width: 38px; }
  .input, .stepper input, .fields .input { font-size: 16px; } /* evita el zoom automático de iOS */
  .hide-m { display: none !important; }
  .hero { margin-bottom: 12px; }
  .hero-sub { display: none; }

  /* Filtros: barra fija y filas deslizables */
  .filters { margin-bottom: 14px; gap: 10px; }
  .filters .row, .filters .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; scroll-padding-inline: 16px; }
  .filters .row::-webkit-scrollbar, .filters .chips::-webkit-scrollbar { display: none; }
  .filters .row > *, .filters .chips > * { flex: none; }
  .filters .search { flex: 1 0 100%; }
  .search .input { min-height: 46px; background: var(--bg2); box-shadow: var(--shadow); border-color: transparent; }
  .chip { padding: 8px 14px; }
  .count { margin-bottom: 8px; }

  /* Tarjetas */
  .card { border-radius: 16px; }
  .card .name { font-size: 14px; }
  .card .meta .tag { font-size: 11px; padding: 2px 8px; }

  /* Detalle: visor a sangre, CTA fija sobre las pestañas */
  .detail .back { margin-bottom: 10px; }
  .detail .stage { margin: 0 -16px; }
  .detail .viewer { border-radius: 0; height: 52vh; height: 52svh; min-height: 330px; box-shadow: none; }
  .detail .v-tools { padding: 10px 16px 0; }
  .info { gap: 14px; }
  .panel { padding: 14px 16px; border-radius: 16px; }
  .cta-bar {
    position: sticky; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 12;
    margin: 4px -16px 0; padding: 10px 16px; background: linear-gradient(rgba(6, 30, 36, 0), var(--bg) 35%);
  }


  /* Visor: controles compactos */
  .v-top { left: 10px; right: 10px; top: 10px; }
  .phase { font-size: 12px; padding: 5px 10px; }
  .v-bot { left: 10px; right: 10px; bottom: 10px; }
  .v-bot .seg button { min-height: 34px; min-width: 38px; padding: 0 10px; display: grid; place-items: center; }

  /* Entrenar: visor compacto y botón de serie fijo abajo */
  .train { gap: 14px; }
  .train .stage { margin: 0 -16px; }
  .train .viewer { border-radius: 0; height: 36vh; height: 36svh; min-height: 250px; box-shadow: none; }
  .train .v-tools { padding: 8px 16px 0; }
  .setbox { padding: 16px; gap: 14px; border-radius: 18px; }
  .setbox h1 { font-size: 22px !important; }
  .setnum { font-size: 46px; }
  .go-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(6, 30, 36, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .go-bar .btn { min-height: 58px; font-size: 18px; border-radius: 18px; }
  .trainbar .btn.icon { width: 42px; min-height: 42px; }

  /* Editor de rutina: cabecera de ítem + campos en rejilla */
  .item { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px 12px; padding: 12px; align-items: start; border-radius: 16px; }
  .item > div:not(.ops) { display: contents; }
  .item img { grid-column: 1; grid-row: 1; width: 56px; height: 44px; }
  .item .nm { grid-column: 2; grid-row: 1; margin: 0; align-self: center; font-size: 14px; line-height: 1.3; }
  .item .ops { grid-column: 3; grid-row: 1; flex-direction: row; gap: 4px; }
  .item .fields { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .fields .input, .fields .input.wide { width: 100%; }
  .fields label:last-child { grid-column: span 2; }
  .editor-head .input.title { font-size: 24px; }

  /* Rutinas e historial */
  .rcard { border-radius: 18px; }
  .rcard .row .btn.primary { flex: 1; }
  .kpis { gap: 8px; }
  .kpi b { font-size: 26px; }
  .sheet { border-radius: 22px 22px 0 0; max-height: 92dvh; align-self: flex-end; width: 100%; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet::before { content: ""; width: 40px; height: 5px; border-radius: 9px; background: var(--line-strong); margin: 8px auto 0; flex: none; }
  .modal:not([hidden]) { animation: fade-in .2s ease-out; }
  .modal { padding: 0; align-items: flex-end; }
  .sheet .foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------- Etiquetas 3D con línea guía ---------- */
.v-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.v-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.v-line { fill: none; stroke: rgba(244, 248, 250, .55); stroke-width: 1; transition: opacity .25s; }
.v-line-force, .v-line-burn, .v-line-muscle-p { stroke: var(--peach); }
.v-dot { fill: var(--t50); transition: opacity .25s; }
.v-dot-force, .v-dot-burn, .v-dot-muscle-p { fill: var(--peach); filter: drop-shadow(0 0 6px rgba(245, 158, 123, .9)); }
.v-tag { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .25s; will-change: transform;
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--t50); white-space: nowrap; }
.v-tag-muscle-p { color: var(--peach); }
.v-tag-force, .v-tag-burn { max-width: 190px; white-space: normal; letter-spacing: 0; text-transform: none; font-size: 13px; font-weight: 600; line-height: 1.3;
  padding: 8px 11px; border-radius: 12px; background: rgba(4, 22, 27, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 123, .45); }
.v-tag-force b, .v-tag-burn b { display: block; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--peach); margin-bottom: 2px; }
.v-tag-burn { box-shadow: inset 0 0 0 1px var(--peach), 0 0 24px -4px rgba(245, 158, 123, .6); }

/* ---------- Pasos interactivos ---------- */
ol.steps li { cursor: pointer; padding: 8px; margin: -8px; border-radius: 12px; transition: background .2s; }
ol.steps li:hover { background: rgba(255, 255, 255, .03); }
ol.steps li.on { background: rgba(245, 158, 123, .08); }
ol.steps li.on::before { background: var(--peach); color: var(--t950); box-shadow: 0 0 16px rgba(245, 158, 123, .6); }
.steps-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.steps-head h3 { margin: 0; }

/* ---------- Guía inmersiva ---------- */
.imm { position: fixed; inset: 0; z-index: 70; background: var(--stage), var(--t950); display: flex; flex-direction: column; animation: fade-in .25s ease-out; }
.imm-stage { position: absolute; inset: 0; touch-action: none; }
.imm-top { position: relative; z-index: 3; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 0; }
.imm-top .t { min-width: 0; }
.imm-top .t b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imm-top .eyebrow { margin: 0; }
.imm-count { font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--t300); }
.imm-count b { color: var(--peach); }
.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); background: rgba(4, 22, 27, .5); color: var(--t50); backdrop-filter: blur(8px); }
.round:active { transform: scale(.94); }
.imm-card { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  padding: 16px 16px 14px; border-radius: 24px; background: rgba(6, 30, 36, .78); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid rgba(158, 192, 202, .14); box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .8); }
.imm-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.imm-bars i { height: 3px; border-radius: 3px; background: rgba(158, 192, 202, .2); overflow: hidden; }
.imm-bars i.done { background: var(--t300); }
.imm-bars i.cur { background: var(--peach); box-shadow: 0 0 10px rgba(245, 158, 123, .8); }
.imm-step { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; min-height: 64px; }
.imm-num { font-family: var(--display); font-size: 46px; font-weight: 800; line-height: .9; color: var(--peach); text-shadow: 0 0 24px rgba(245, 158, 123, .45); }
.imm-step p { margin: 2px 0 0; font-size: 16px; line-height: 1.45; font-weight: 500; }
.imm-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 14px; }
.imm-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(245, 158, 123, .12); color: #FAD0BE; }
.imm-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--peach); box-shadow: 0 0 8px var(--peach); }
.imm-chip.alt { background: rgba(158, 192, 202, .12); color: var(--t100); }
.imm-chip.alt i { background: var(--t300); box-shadow: none; }
.imm-nav { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.imm-nav .btn { min-height: 52px; }
.imm-nav .btn.icon { width: 52px; }
.imm-phase { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); top: calc(max(14px, env(safe-area-inset-top)) + 58px); }
.imm .v-tag-force, .imm .v-tag-burn { font-size: 14px; max-width: 210px; }
@media (min-width: 900px) {
  .imm-card { left: auto; right: 28px; bottom: 28px; width: 420px; }
  .imm-top { padding: 22px 28px 0; }
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Selector de peso en rueda ---------- */
.big-in:has(.kgw) { grid-template-columns: 1fr; }
.big-in > * { min-width: 0; }
.kgw { min-width: 0; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 0 8px; position: relative; }
.kgw-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 12px; }
.kgw-head > span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.kgw-val { display: flex; align-items: baseline; gap: 4px; justify-content: center; }
.kgw-val b { font-family: var(--font-d, 'Barlow Condensed'), sans-serif; font-size: 40px; font-weight: 800; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: center; }
.kgw-val small { color: var(--muted); font-size: 13px; font-weight: 600; }
.kgw-btns { display: flex; gap: 6px; justify-content: flex-end; }
.kgw-btns button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--card2); color: var(--text); font-size: 18px; font-weight: 600; }
.kgw-track { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 0 calc(50% - 6px); margin-top: 6px; outline: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); }
.kgw-track::-webkit-scrollbar { display: none; }
.kgw-ticks { display: flex; height: 46px; width: max-content; }
.kgw-ticks i { flex: 0 0 12px; scroll-snap-align: center; position: relative; }
.kgw-ticks i::before { content: ''; position: absolute; left: 50%; top: 0; width: 1.5px; height: 10px; background: var(--dim); transform: translateX(-50%); border-radius: 1px; }
.kgw-ticks i.m::before { height: 16px; background: var(--muted); }
.kgw-ticks i.M::before { height: 22px; width: 2px; background: var(--t50); }
.kgw-ticks span { position: absolute; top: 27px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-weight: 600; }
.kgw::after { content: ''; position: absolute; left: 50%; bottom: 20px; width: 3px; height: 30px; margin-left: -1.5px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px rgba(245,158,123,.6); pointer-events: none; }
.kgw-track:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Barras de volumen (código de barras) ---------- */
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 34px; }
.vb-g { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.vb-g i { width: 3px; border-radius: 2px; background: var(--accent); }
.vb-g.alt i { background: var(--t300); }

/* =========================================================
   Premium: tarjetas con miniatura 3D + movimiento fluido
   ========================================================= */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.34, 1.4, .64, 1); }

/* ---------- Biblioteca ---------- */
.hero h1 { font-size: clamp(28px, 4.2vw, 46px); letter-spacing: -.035em; line-height: 1.02; max-width: 16ch; }
.hero h1 em { font-style: normal; color: var(--peach); }
.count { display: flex; align-items: baseline; gap: 6px; font-size: 13px; margin: 2px 0 14px; color: var(--muted); }
.count b { color: var(--text); font-size: 15px; }
.count span { color: var(--dim); }
.linkbtn { margin-left: auto; border: 0; background: none; color: var(--peach); font-weight: 700; font-size: 13px; padding: 4px 0; }

.grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card {
  border-radius: 22px; border: 1px solid rgba(158, 192, 202, .12);
  background:
    radial-gradient(80% 55% at 50% 40%, rgba(245, 158, 123, .20), rgba(245, 158, 123, 0) 70%),
    linear-gradient(180deg, #0F3D47 0%, #0A2C34 62%, #082730 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 24px 40px -28px rgba(0, 0, 0, .9);
  transition: transform .45s var(--ease-out), border-color .3s, box-shadow .45s var(--ease-out);
  animation: card-in .6s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 40ms);
  isolation: isolate;
}
.card::after { /* brillo que sigue al hover */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: linear-gradient(120deg, transparent 30%, rgba(244, 248, 250, .07) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform .9s var(--ease-out);
}
.card:hover { transform: translateY(-4px); border-color: rgba(245, 158, 123, .4); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 30px 50px -28px rgba(245, 158, 123, .35); }
.card:hover::after { transform: translateX(100%); }
.card:active { transform: scale(.97); transition-duration: .12s; }
.card .ph { aspect-ratio: 4 / 5; background: none; }
.card .ph img.th { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; filter: none; transform: scale(1.08) translateY(6%); transition: transform .7s var(--ease-out); }
.card .ph img.th.photo { filter: grayscale(1) sepia(.5) hue-rotate(150deg) saturate(1.3) contrast(1.08) brightness(.82); }
.card:hover .ph img.th { transform: scale(1.14) translateY(5%); }
.card .ph::after { content: ''; position: absolute; inset: auto 0 0; height: 40%; background: linear-gradient(180deg, transparent, #0A2C34 92%); pointer-events: none; }
.card .lvl { position: absolute; left: 10px; top: 10px; z-index: 1; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--t100); background: rgba(6, 30, 36, .55); border: 1px solid rgba(158, 192, 202, .18); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.card .go { position: absolute; right: 10px; top: 10px; z-index: 1; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(244, 248, 250, .1); border: 1px solid rgba(244, 248, 250, .16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .3s, transform .45s var(--ease-spring); }
.card .go svg { width: 15px; height: 15px; fill: none; stroke: var(--t50); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: stroke .3s; }
.card:hover .go { background: var(--peach); transform: rotate(45deg); }
.card:hover .go svg { stroke: var(--t950); }
.card .body { position: relative; z-index: 1; margin-top: -34px; padding: 0 14px 15px; gap: 4px; }
.card .mus { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--peach); }
.card .name { font-size: 15px; font-weight: 700; line-height: 1.22; letter-spacing: -.01em; }
.card .eq { font-size: 12px; color: var(--dim); margin-top: 2px; }

@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }

/* Chips y segmentos: cambio suave */
.chip, .seg button { transition: background .3s var(--ease-out), color .3s, transform .2s var(--ease-spring), border-color .3s; }
.tabs a { transition: background .35s var(--ease-out), color .3s, transform .2s var(--ease-spring); }
.btn { transition: background .25s, transform .25s var(--ease-spring), border-color .25s, box-shadow .3s; }
.btn:active { transform: scale(.96); }
.btn.primary { box-shadow: 0 10px 26px -12px rgba(245, 158, 123, .7); }

/* ---------- Detalle: entrada escalonada ---------- */
.detail .info > *, .train .info > * { animation: rise .55s var(--ease-out) backwards; }
.detail .info > :nth-child(2), .train .info > :nth-child(2) { animation-delay: .06s; }
.detail .info > :nth-child(3) { animation-delay: .12s; }
.detail .info > :nth-child(4) { animation-delay: .18s; }
.detail .info > :nth-child(5) { animation-delay: .24s; }
.detail .info > :nth-child(6) { animation-delay: .3s; }
.rcard, .item, .log-item { animation: rise .55s var(--ease-out) backwards; }
.rgrid > :nth-child(2) { animation-delay: .06s; } .rgrid > :nth-child(3) { animation-delay: .12s; } .rgrid > :nth-child(4) { animation-delay: .18s; } .rgrid > :nth-child(n+5) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Barras de volumen crecen al aparecer */
.vb-g i { transform-origin: bottom; animation: bar-up .7s var(--ease-out) backwards; }
.vb-g:nth-child(2n) i { animation-delay: .05s; } .vb-g:nth-child(3n) i { animation-delay: .1s; }
@keyframes bar-up { from { transform: scaleY(0); } to { transform: none; } }

/* ---------- Transiciones entre páginas (View Transitions) ---------- */
.top { view-transition-name: topbar; }
@media (max-width: 760px) { .tabs { view-transition-name: tabbar; } }
.detail .stage, .train .stage { view-transition-name: hero-media; }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .42s; animation-timing-function: var(--ease-out); }
html[data-nav="fwd"]::view-transition-old(root) { animation-name: vt-out-left; }
html[data-nav="fwd"]::view-transition-new(root) { animation-name: vt-in-right; }
html[data-nav="back"]::view-transition-old(root) { animation-name: vt-out-right; }
html[data-nav="back"]::view-transition-new(root) { animation-name: vt-in-left; }
::view-transition-old(hero-media), ::view-transition-new(hero-media) { animation-duration: .5s; animation-timing-function: var(--ease-out); height: 100%; object-fit: cover; }
::view-transition-old(topbar), ::view-transition-new(topbar), ::view-transition-old(tabbar), ::view-transition-new(tabbar) { animation: none; }
@keyframes vt-out-left { to { opacity: 0; transform: translateX(-6%) scale(.98); } }
@keyframes vt-in-right { from { opacity: 0; transform: translateX(8%); } }
@keyframes vt-out-right { to { opacity: 0; transform: translateX(6%) scale(.98); } }
@keyframes vt-in-left { from { opacity: 0; transform: translateX(-8%); } }

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { border-radius: 20px; }
  .card .body { padding: 0 11px 12px; margin-top: -30px; }
  .card .name { font-size: 13.5px; }
  .card .mus { font-size: 9.5px; }
  .card .go { width: 26px; height: 26px; right: 8px; top: 8px; }
  .card .lvl { left: 8px; top: 8px; font-size: 10px; padding: 3px 8px; }
}
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* Miniaturas 3D en listas (rutinas, editor, selector, "siguiente") */
img.t3 { filter: none !important; object-fit: cover; object-position: 50% 45%; background: radial-gradient(70% 60% at 50% 45%, rgba(245, 158, 123, .22), transparent 70%), linear-gradient(180deg, #0F3D47, #0A2C34); }
.rcard .thumbs img.t3 { aspect-ratio: 4 / 5; border-radius: 10px; }

/* ---------- Carga del visor: póster 3D → modelo definitivo con fundido ---------- */
.viewer .viewer-canvas { opacity: 0; transition: opacity .5s var(--ease-out); }
.viewer.ready .viewer-canvas { opacity: 1; }
.v-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 55%; pointer-events: none; transition: opacity .45s var(--ease-out), transform .6s var(--ease-out); }
.viewer.ready .v-poster { opacity: 0; transform: scale(1.03); }
.v-loader { position: absolute; left: 50%; bottom: 76px; width: 120px; height: 3px; margin-left: -60px; border-radius: 3px; background: rgba(244, 248, 250, .12); overflow: hidden; transition: opacity .3s; }
.v-loader i { position: absolute; inset: 0; width: 40%; border-radius: inherit; background: var(--peach); animation: v-load 1.1s ease-in-out infinite; }
.viewer.ready .v-loader { opacity: 0; }
@keyframes v-load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* =========================================================
   Móvil primero: páginas internas como app nativa
   ========================================================= */
@media (max-width: 760px) {
  body.deep .top, body.deep .tabs { display: none; }
  body.deep main { padding-top: 0; padding-bottom: calc(108px + env(safe-area-inset-bottom)); }

  /* Botón volver flotante (cristal) */
  body.deep .back {
    position: fixed; z-index: 30; left: 12px; top: calc(10px + env(safe-area-inset-top));
    width: 42px; height: 42px; margin: 0; justify-content: center; border-radius: 50%; font-size: 0; color: var(--t50);
    background: rgba(6, 30, 36, .55); border: 1px solid rgba(244, 248, 250, .14);
    backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
    box-shadow: 0 8px 22px -10px rgba(0, 0, 0, .7);
  }
  body.deep .back svg { width: 22px; height: 22px; }
  body.deep .back:active { transform: scale(.92); }

  /* Barra de acción fija abajo, cristal */
  body.deep .cta-bar, body[data-page="rutina"] .add-row {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(6, 30, 36, .82); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
    border-top: 1px solid var(--line);
  }
  body.deep .cta-bar .btn, body[data-page="rutina"] .add-row .btn { width: 100%; min-height: 54px; border-radius: 18px; font-size: 16px; }
}

@media (max-width: 640px) {
  /* Detalle: visor a sangre desde arriba, título pegado bajo el 3D */
  body.deep .detail .stage { margin: 0 -16px; }
  body.deep .detail .viewer { height: 60svh; min-height: 360px; padding-top: env(safe-area-inset-top); }
  body.deep .detail .v-top { top: calc(16px + env(safe-area-inset-top)); left: 64px; }
  body.deep .detail .viewer::after { content: ''; position: absolute; inset: auto 0 0; height: 70px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
  .detail .v-tools { padding: 0 16px; margin-top: -26px; position: relative; z-index: 2; }
  .detail .v-tools .seg { background: rgba(10, 44, 52, .72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .detail .info { margin-top: 18px; }
  .detail .head h1 { font-size: 30px; letter-spacing: -.03em; }
  .hint { display: none; }

  /* Editor: cabecera compacta bajo el botón volver */
  body[data-page="rutina"] .editor-head { padding-top: calc(62px + env(safe-area-inset-top)); }
  body[data-page="rutina"] .editor-head .input.title { flex: 1 1 100%; order: -1; }

  /* Pestañas raíz: título grande estilo iOS */
  body:not(.deep) .hero h1 { font-size: 30px; }
  main { padding-left: 16px; padding-right: 16px; }
}

/* Pantallas muy estrechas (iPhone SE / Android compactos) */
@media (max-width: 360px) {
  .grid { gap: 8px; }
  .card .body { padding: 0 9px 10px; }
  .card .name { font-size: 12.5px; }
  .tabs a span { font-size: 10px; }
  .big-in { gap: 8px; }
  .setnum { font-size: 40px; }
  body.deep .detail .viewer { height: 54svh; min-height: 320px; }
}
/* Teléfono en horizontal: visor y panel lado a lado */
@media (max-height: 500px) and (orientation: landscape) {
  .detail, .train { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .detail .viewer, .train .viewer { height: calc(100svh - 40px) !important; min-height: 0 !important; }
  .detail .stage, .train .stage { position: sticky; top: 10px; margin: 0 !important; }
}
@media (max-width: 640px) {
  .viewer .v-top, .viewer .v-bot, .viewer .v-labels { z-index: 3; }
  body.deep .detail .v-bot { bottom: 42px; }
  body.deep .detail .v-loader { bottom: 96px; }
}
