/* Forja — design system */
@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-latin.woff2') format('woff2');
  font-weight: 400 800; font-stretch: 62% 125%; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
:root {
  --bg: #F7F8FA; --surface: #FFFFFF; --surface-2: #F0F2F6; --ink: #171A20; --muted: #69717D; --line: #E5E8ED;
  --brand: #3867F5; --brand-ink: #FFFFFF; --brand-soft: #EAF0FF; --brand-strong: #2550D6;
  --go: #64B887; --go-soft: #E8F5EE; --go-ink: #2F7A52;
  --warn: #C2672B; --danger: #C93B3B;
  --night: #171A20; --night-2: #22262E; --night-line: #323844; --night-ink: #F7F8FA; --night-muted: #9AA3B0;
  --lvl1: #64B887; --lvl2: #E0A43B; --lvl3: #E05A5A;
  --fig-ink: #171A20; --fig-far: #A9B1BD; --fig-prop: #CBD2DC; --fig-prop-fill: #EDF0F4; --fig-floor: #DDE2E9; --fig-acc: #3867F5; --fig-cable: #8A94A3;
  --r-lg: 20px; --r: 16px; --r-s: 12px; --r-xs: 8px;
  --shadow: 0 1px 2px rgb(23 26 32 / .04), 0 4px 16px rgb(23 26 32 / .05);
  --tabs-h: 64px; --gutter: 16px;
  --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--font); font-stretch: 100%; -webkit-font-smoothing: antialiased;
  overflow-x: hidden; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; font-stretch: 106%; letter-spacing: -.02em; line-height: 1.15; }
main { max-width: 1120px; margin: 0 auto; min-height: 70vh; outline: none; }
.pad { padding: 0 var(--gutter); }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); font-size: .9rem; }
.fine { color: var(--muted); font-size: .78rem; line-height: 1.5; padding: 8px 0 24px; }
.fine a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.eyebrow { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; font-stretch: 110%; }
.num { font-variant-numeric: tabular-nums; font-stretch: 112%; font-weight: 750; letter-spacing: -.03em; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-title h2 { font-size: 1.12rem; font-weight: 750; }
.section-title a, .link { color: var(--brand); font-weight: 650; font-size: .9rem; background: none; border: 0; padding: 6px 0; }
.link[hidden] { display: none; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 18px; height: 18px; }

/* view enter */
.enter > section > *, .enter > .hello { animation: rise .26s var(--ease) backwards; }
.enter > section > *:nth-child(2) { animation-delay: .03s; } .enter > section > *:nth-child(3) { animation-delay: .06s; } .enter > section > *:nth-child(n+4) { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* header */
.top { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(1.4) blur(12px); }
.top h1 { font-size: 1.5rem; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top.small h1 { font-size: 1.05rem; font-weight: 700; }
.top .spacer { flex: 1; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-stretch: 104%; letter-spacing: -.005em; transition: transform .12s var(--ease), background .15s, box-shadow .15s; touch-action: manipulation; }
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--brand-strong); }
.btn .ico { width: 20px; height: 20px; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand-strong); }
.btn-soft:hover { background: #dde7ff; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: #fdf1f1; }
.btn-go { background: var(--go); color: #0f2a1b; }
.btn-go:hover { background: #57a97a; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 16px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.row-btns > .btn { flex: 1 1 140px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); flex: none; transition: background .15s, color .15s, transform .12s; }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.on { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: #fff5f5; }
.icon-btn.on .ico { fill: currentColor; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: .9rem; font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .12s; }
.chip:active { transform: scale(.97); }
.chip .ico { width: 18px; height: 18px; }
.chip b { background: var(--brand); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: .72rem; padding: 0 6px; }
.chip.on { background: var(--brand-soft); color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.chip.on.heart .ico { fill: currentColor; }
.chip:disabled { opacity: 1; cursor: default; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); color: #3d434d; }
.tag.brand { background: var(--brand-soft); color: var(--brand-strong); }
.lvl { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.lvl i { display: inline-flex; gap: 2px; }
.lvl i::before, .lvl i::after, .lvl i b { content: ""; width: 4px; height: 10px; border-radius: 2px; background: var(--line); display: block; }
.lvl-principiante i::before { background: var(--lvl1); }
.lvl-intermedio i::before, .lvl-intermedio i b { background: var(--lvl2); }
.lvl-avanzado i::before, .lvl-avanzado i b, .lvl-avanzado i::after { background: var(--lvl3); }
.badge { font-size: .68rem; font-weight: 650; padding: 3px 8px; border-radius: 6px; background: rgb(23 26 32 / .72); color: #fff; letter-spacing: .01em; }

/* surfaces */
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }
.empty-state { text-align: center; padding: 28px 20px; display: grid; justify-items: center; gap: 10px; }
.empty-state .ill { width: 120px; height: 120px; border-radius: 28px; background: var(--brand-soft); padding: 14px; }
.empty-state h3 { font-size: 1.1rem; }
.empty-state p { margin: 0; color: var(--muted); max-width: 34ch; }

/* thumbnails (static SVG pose) */
.thumb { display: block; aspect-ratio: 1; border-radius: var(--r-s); background: var(--surface-2); padding: 6px; overflow: hidden; }
.thumb .figure .floor { stroke-width: 3; }
.thumb-pending { width: 100%; height: 100%; display: grid; place-items: center; color: #b6bdc8; }
.thumb-pending::before { content: ""; width: 34%; aspect-ratio: 1; border-radius: 50%; border: 2px dashed currentColor; }

/* ---------- home */
.hello { padding: 8px var(--gutter) 16px; }
.hello .date { color: var(--muted); font-weight: 600; font-size: .9rem; }
.hello .date::first-letter { text-transform: uppercase; }
.hello h1 { font-size: 1.85rem; font-weight: 800; margin-top: 2px; }
.resume { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r); background: var(--ink); color: #fff; }
.resume .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--go); box-shadow: 0 0 0 4px rgb(100 184 135 / .25); flex: none; }
.resume div { flex: 1; min-width: 0; }
.resume strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume span { font-size: .85rem; color: #c9ced6; }
.hero { position: relative; overflow: hidden; border-radius: 24px; background: var(--brand); color: #fff; padding: 20px; display: grid; gap: 14px; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 200px; height: 200px; border-radius: 50%; border: 28px solid rgb(255 255 255 / .07); pointer-events: none; }
.hero .eyebrow { color: rgb(255 255 255 / .75); }
.hero h2 { font-size: 1.55rem; font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; color: rgb(255 255 255 / .85); }
.hero .meta b { color: #fff; font-weight: 750; }
.hero-figs { display: flex; gap: 8px; }
.hero-figs .thumb { width: 64px; background: rgb(255 255 255 / .12); --fig-ink: #fff; --fig-far: rgb(255 255 255 / .45); --fig-floor: rgb(255 255 255 / .2); --fig-acc: #bcd0ff; --fig-prop: rgb(255 255 255 / .3); --fig-prop-fill: rgb(255 255 255 / .1); --fig-cable: rgb(255 255 255 / .5); }
.hero .btn { background: #fff; color: var(--brand-strong); }
.hero .btn:hover { background: #f1f5ff; }
.hero .btn-ghost-light { background: rgb(255 255 255 / .14); color: #fff; border: 0; }
.hero.empty-hero { background: var(--ink); }
.week { display: grid; gap: 14px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; }
.week-head strong { font-size: 1.05rem; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { display: grid; justify-items: center; gap: 6px; font-size: .74rem; font-weight: 650; color: var(--muted); }
.day i { width: 100%; max-width: 40px; aspect-ratio: 1; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; }
.day.done i { background: var(--go); }
.day.done i::after { content: ""; width: 12px; height: 7px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.day.today { color: var(--ink); }
.day.today i { box-shadow: inset 0 0 0 2px var(--brand); }
.cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cat { position: relative; display: grid; grid-template-columns: 1fr 56px; align-items: end; gap: 6px; min-height: 92px; padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); transition: transform .12s, border-color .15s; overflow: hidden; }
.cat:active { transform: scale(.98); }
.cat:hover { border-color: #cfd6e0; }
.cat strong { font-size: .98rem; font-weight: 720; line-height: 1.15; }
.cat span { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.cat .thumb { width: 56px; padding: 3px; background: var(--brand-soft); --fig-acc: var(--brand); }
.last { display: flex; align-items: center; gap: 12px; }
.last .ok { width: 44px; height: 44px; border-radius: 12px; background: var(--go-soft); color: var(--go-ink); display: grid; place-items: center; flex: none; }
.last div { min-width: 0; flex: 1; }
.last strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-link { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }

/* ---------- library */
.lib-tools { position: sticky; top: 60px; z-index: 5; padding: 0 var(--gutter) 12px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(12px); display: grid; gap: 10px; }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; min-height: 52px; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search .ico { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 0; font-size: 1rem; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.scroller { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter); }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.count { margin-left: auto; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.count b { color: var(--ink); }
.grid { list-style: none; margin: 0; padding: 0 var(--gutter); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ex-card { position: relative; content-visibility: auto; contain-intrinsic-size: 260px; }
.ex-link { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: transform .12s var(--ease), box-shadow .2s, border-color .2s; text-align: left; width: 100%; padding: 0; }
.ex-link:hover { box-shadow: var(--shadow); border-color: #d5dbe4; }
.ex-link:active { transform: scale(.985); }
.ex-link .thumb { border-radius: 0; background: var(--surface-2); padding: 10px; position: relative; }
.ex-link .badge { position: absolute; left: 8px; bottom: 8px; }
.ex-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 12px 12px; }
.ex-name { font-weight: 700; font-size: .95rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.ex-muscle { font-size: .8rem; color: var(--brand-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 6px; font-size: .76rem; color: var(--muted); }
.ex-meta .eq { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fav-btn { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; border-radius: 10px; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / .9); color: #8b93a0; box-shadow: 0 1px 3px rgb(0 0 0 / .08); transition: transform .12s, color .15s; }
.fav-btn .ico { width: 18px; height: 18px; }
.fav-btn[aria-pressed="true"] { color: var(--danger); }
.fav-btn[aria-pressed="true"] .ico { fill: currentColor; }
.fav-btn:active { transform: scale(.9); }
.pick-add { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; pointer-events: none; }
.more { padding: 16px var(--gutter) 8px; }

/* ---------- exercise detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.stage { position: relative; border-radius: var(--r-lg); background: linear-gradient(180deg, #fff 0%, #F1F4F8 100%); border: 1px solid var(--line); aspect-ratio: 4 / 3; overflow: hidden; }
.anim { position: absolute; inset: 14px 14px 64px; }
.player-ctl { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center; }
.player-ctl .icon-btn { background: rgb(255 255 255 / .92); }
.player-ctl .icon-btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.player-ctl .chip[hidden] { display: none; }
.stage .view-tag { position: absolute; top: 12px; left: 12px; }
.stage-pending { display: grid; place-items: center; }
.pending-box { display: grid; gap: 6px; text-align: center; padding: 20px; max-width: 32ch; color: var(--muted); font-size: .9rem; }
.pending-box strong { color: var(--ink); font-size: 1rem; }
.d-head { display: grid; gap: 10px; }
.d-head h1 { font-size: 1.65rem; font-weight: 800; overflow-wrap: anywhere; }
.d-sub { color: var(--muted); font-weight: 550; font-size: .92rem; }
.d-actions { display: flex; gap: 10px; }
.d-actions .btn { flex: 1; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.fact.wide { grid-column: 1 / -1; }
.fact .chips { gap: 6px; }
.fact .tag { font-size: .82rem; }
.block h2 { font-size: 1.12rem; font-weight: 750; margin-bottom: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); font-weight: 750; font-size: .85rem; font-variant-numeric: tabular-nums; }
.note { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 14px; border-radius: var(--r); }
.note ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.note.breath { background: var(--brand-soft); color: #22346f; }
.note.warn { background: #FFF5EC; color: #6d3a14; }
.note .ico { margin-top: 1px; }
.note.warn .ico { color: var(--warn); }
.note.breath .ico { color: var(--brand); }
.rail { list-style: none; display: flex; gap: 10px; overflow-x: auto; padding: 2px var(--gutter) 6px; margin: 0 calc(-1 * var(--gutter)); scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail li { flex: none; width: 148px; scroll-snap-align: start; }
.mini { display: grid; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font-size: .85rem; font-weight: 650; line-height: 1.2; transition: transform .12s; }
.mini:active { transform: scale(.97); }
.mini .thumb { padding: 6px; }
.mini span.n { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.tabs-inline { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs-inline button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; font-size: .88rem; color: var(--muted); }
.tabs-inline button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

/* ---------- routines */
.r-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.r-card .top-line { display: flex; align-items: center; gap: 12px; }
.r-card .top-line a { flex: 1; min-width: 0; }
.r-card strong { display: block; font-size: 1.02rem; font-weight: 720; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-figs { display: flex; gap: 6px; overflow: hidden; }
.r-figs .thumb { width: 48px; padding: 3px; }
.r-figs .more-n { width: 48px; aspect-ratio: 1; border-radius: var(--r-s); background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

/* builder */
.name-input { width: 100%; border: 0; border-bottom: 2px solid var(--line); background: transparent; font-size: 1.5rem; font-weight: 800; font-stretch: 106%; letter-spacing: -.02em; padding: 6px 0 8px; outline: none; transition: border-color .15s; }
.name-input:focus { border-color: var(--brand); }
.b-summary { display: flex; gap: 16px; color: var(--muted); font-size: .9rem; }
.b-summary b { color: var(--ink); }
.builder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.b-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); transition: border-color .15s, box-shadow .15s; }
.b-item.open { border-color: color-mix(in srgb, var(--brand) 40%, transparent); box-shadow: 0 0 0 3px var(--brand-soft); }
.b-row { display: grid; grid-template-columns: 22px 48px 1fr auto; gap: 10px; align-items: center; padding: 10px; }
.b-n { font-weight: 750; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; font-size: .9rem; }
.b-row .thumb { width: 48px; padding: 3px; }
.b-main { min-width: 0; display: grid; gap: 2px; text-align: left; background: none; border: 0; padding: 0; }
.b-main strong { font-size: .95rem; font-weight: 700; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.b-main span { font-size: .84rem; color: var(--brand-strong); font-weight: 650; font-variant-numeric: tabular-nums; }
.b-tools { display: flex; gap: 2px; }
.b-tools .icon-btn { width: 40px; height: 40px; border-radius: 10px; }
.b-edit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 10px 12px; }
.b-edit label { display: grid; gap: 4px; font-size: .74rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stepper { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; min-height: 44px; background: var(--bg); }
.stepper button { width: 36px; height: 42px; border: 0; background: transparent; font-size: 1.2rem; color: var(--brand); font-weight: 700; }
.stepper span { font-weight: 750; color: var(--ink); font-size: .95rem; font-variant-numeric: tabular-nums; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.sticky-foot { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 4; padding: 12px var(--gutter); margin: 0 calc(-1 * var(--gutter)); background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; gap: 10px; }
.sticky-foot .btn { flex: 1; }

/* generator */
.field { display: grid; gap: 10px; }
.label { font-weight: 700; font-size: .95rem; }
.seg-row { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg-row button { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; font-weight: 650; font-size: .9rem; color: var(--muted); padding: 0 6px; transition: background .15s, color .15s; }
.seg-row button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.gen-day { display: grid; gap: 10px; }
.gen-day ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.gen-day li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; font-size: .9rem; font-weight: 600; }
.gen-day li .thumb { width: 40px; padding: 2px; }
.gen-day li span { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }

/* progress */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px; display: grid; gap: 2px; }
.kpi .num { font-size: 1.7rem; line-height: 1.05; }
.kpi.main { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.main .eyebrow { color: rgb(255 255 255 / .75); }
.chart { display: grid; gap: 10px; }
.bars { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-items: end; gap: 4px; height: 140px; }
.bar { display: grid; gap: 6px; justify-items: center; align-content: end; height: 100%; }
.bar i { width: 100%; max-width: 32px; border-radius: 8px 8px 4px 4px; background: #c9d6fb; min-height: 4px; transition: height .4s var(--ease); }
.bar.cur i { background: var(--brand); }
.bar b { font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.bar span { font-size: .62rem; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.hist li { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; align-items: center; }
.hist .dt { width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; text-align: center; line-height: 1; }
.hist .dt b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.hist .dt span { font-size: .62rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .05em; }
.hist strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- workout player (dark) */
body.in-workout { background: var(--night); color: var(--night-ink); padding-bottom: 0; }
body.in-workout .tabs { display: none; }
.wk { min-height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto; gap: 14px; padding: max(10px, env(safe-area-inset-top)) var(--gutter) calc(16px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto;
  --fig-ink: #F7F8FA; --fig-far: #6E7785; --fig-prop: #3A414C; --fig-prop-fill: #262B33; --fig-floor: #2E343D; --fig-acc: #7D9BFF; --fig-cable: #8A94A3; }
.wk-top { display: flex; align-items: center; gap: 10px; }
.wk-top .icon-btn { background: var(--night-2); border-color: var(--night-line); color: var(--night-ink); }
.wk-top div { flex: 1; min-width: 0; }
.wk-top strong { display: block; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-top span { font-size: .8rem; color: var(--night-muted); font-variant-numeric: tabular-nums; }
.wk-progress { display: flex; gap: 4px; }
.wk-progress span { flex: 1; height: 4px; border-radius: 4px; background: var(--night-line); transition: background .3s; }
.wk-progress .done { background: var(--go); } .wk-progress .cur { background: var(--brand); }
.wk-body { display: grid; gap: 14px; align-content: start; }
.wk-stage { position: relative; border-radius: var(--r-lg); background: var(--night-2); aspect-ratio: 4 / 3; overflow: hidden; }
.wk-stage .anim { inset: 12px; }
.wk-stage .pending-box { position: absolute; inset: 0; margin: auto; height: fit-content; color: var(--night-muted); }
.wk-stage .pending-box strong { color: var(--night-ink); }
.wk-info { display: grid; gap: 4px; }
.wk-info .eyebrow { color: var(--night-muted); }
.wk-name { font-size: 1.45rem; font-weight: 800; font-stretch: 106%; letter-spacing: -.02em; line-height: 1.15; }
.wk-target { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.wk-target .num { font-size: 3.4rem; line-height: 1; }
.wk-target span { color: var(--night-muted); font-weight: 600; }
.set-dots { display: flex; gap: 6px; margin-top: 10px; }
.set-dots i { width: 22px; height: 6px; border-radius: 3px; background: var(--night-line); }
.set-dots i.done { background: var(--go); } .set-dots i.cur { background: var(--brand); }
.wk-rest { display: grid; justify-items: center; gap: 14px; padding-top: 6px; text-align: center; }
.ring { position: relative; width: min(64vw, 260px); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: var(--night-line); }
.ring .fg { stroke: var(--go); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; }
.ring .num { font-size: 4.2rem; line-height: 1; color: #fff; }
.ring .center span { color: var(--go); font-weight: 750; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.next-up { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px; border-radius: var(--r); background: var(--night-2); }
.next-up .thumb { width: 56px; padding: 3px; background: #2a3039; }
.next-up span { font-size: .78rem; color: var(--night-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.next-up strong { display: block; font-size: 1rem; }
.next-up em { font-style: normal; color: var(--night-muted); font-size: .85rem; }
.wk-paused { text-align: center; font-weight: 750; color: #FFC58A; letter-spacing: .02em; }
.wk-controls { display: grid; gap: 12px; }
.wk-controls .btn-lg { min-height: 60px; font-size: 1.1rem; }
.wk-sec { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wk-sec button { display: grid; justify-items: center; gap: 4px; min-height: 60px; padding: 8px 4px; border-radius: 14px; border: 1px solid var(--night-line); background: var(--night-2); color: var(--night-ink); font-size: .74rem; font-weight: 650; transition: background .15s, transform .12s; }
.wk-sec button:active { transform: scale(.96); }
.wk-sec button.danger { color: #ff9b9b; }
.wk.resting .wk-progress .cur { background: var(--go); }
.wk-done { display: grid; gap: 18px; justify-items: center; text-align: center; padding-top: 40px; }
.wk-done .check { width: 84px; height: 84px; border-radius: 26px; background: var(--go); display: grid; place-items: center; color: #0f2a1b; }
.wk-done .check .ico { width: 40px; height: 40px; stroke-width: 2.6; }
.wk-done h1 { font-size: 1.8rem; font-weight: 800; }
.wk-done .kpis { width: 100%; }
.wk-done .kpi { background: var(--night-2); border-color: var(--night-line); color: var(--night-ink); }
.wk-done .kpi .eyebrow { color: var(--night-muted); }

/* ---------- tabs (bottom bar; side rail on desktop) */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
.tabs a { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; font-size: .72rem; font-weight: 650; color: var(--muted); transition: color .15s; }
.tabs .ico { width: 24px; height: 24px; stroke-width: 1.9; }
.tabs a[aria-current="true"] { color: var(--brand); }
.tabs a[aria-current="true"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.brand-mark { display: none; }

/* ---------- sheet + toast */
dialog#sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 88dvh; border-radius: 24px 24px 0 0; background: var(--surface); color: var(--ink); }
dialog#sheet[open] { animation: sheet-in .26s var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
dialog#sheet::backdrop { background: rgb(15 17 22 / .5); }
.sheet-inner { padding: 8px var(--gutter) calc(16px + env(safe-area-inset-bottom)); }
.sheet-inner::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 1.2rem; font-weight: 750; }
.sheet-foot { position: sticky; bottom: 0; display: flex; gap: 10px; padding-top: 12px; background: var(--surface); }
.sheet-foot .btn { flex: 1; }
.fgroup { border: 0; padding: 0; margin: 0 0 18px; }
.fgroup legend { font-weight: 700; font-size: .9rem; margin-bottom: 10px; padding: 0; }
.confirm { font-size: 1.05rem; margin: 8px 0 16px; }
.sheet-steps { max-height: 60dvh; overflow: auto; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 20;
  display: flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-size: .92rem; font-weight: 600; transition: .22s var(--ease); max-width: calc(100% - 32px); }
#toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--go); flex: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.in-workout #toast { bottom: 24px; }

/* boot skeleton */
.skel { padding: 24px var(--gutter); display: grid; gap: 14px; }
.skel i { display: block; border-radius: 16px; background: linear-gradient(90deg, #eef1f5 0, #f6f8fa 50%, #eef1f5 100%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- larger screens */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  body { padding-bottom: 0; padding-left: 96px; }
  .tabs { top: 0; right: auto; width: 96px; height: 100dvh; grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start; padding: 16px 0; border-top: 0; border-right: 1px solid var(--line); }
  .tabs a[aria-current="true"]::before { top: 18px; left: 0; width: 3px; height: 36px; border-radius: 0 3px 3px 0; }
  .brand-mark { display: grid; place-items: center; height: 72px; }
  .brand-mark span { width: 40px; height: 40px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-stretch: 112%; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .home-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 24px; align-items: start; }
  .home-grid .section-title:first-child { margin-top: 0; }
  .home-grid .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .detail .d-left { position: sticky; top: 76px; }
  .detail .d-right { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .sticky-foot { bottom: 0; }
  #toast { bottom: 24px; }
  dialog#sheet { margin: auto; border-radius: 24px; }
  .wk { max-width: 760px; }
  body.in-workout { padding-left: 0; }
}
@media (hover: none) { .ex-link:hover { box-shadow: none; } }
@media (max-height: 700px) and (max-width: 599px) { .lib-tools { position: static; } } /* short phones: keep the catalog visible */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
