:root {
  --bg: #0f1115; --card: #181b22; --card2: #20242d; --line: #2b303b; --tx: #eef1f5; --mu: #9aa3b2;
  --ac: #9fe870; --ac-ink: #10200a; --ac2: #4f7a3a;
  --ok: #5ad17a; --good: #b8e05a; --warn: #f2a33a; --bad: #ef6a5a; --ban: #8a8f99;
  --eh: #4aa3ff; --ev: #c084fc; --casa: #9fe870;
  --r: 16px; --nav: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1 { font-size: 1.45rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 22px 0 10px; color: var(--mu); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
h3 { margin: 0; font-size: 1.05rem; }
.muted { color: var(--mu); }
.small { font-size: .86rem; }

#view { padding: 16px 16px calc(var(--nav) + var(--safe-b) + 24px); max-width: 560px; margin: 0 auto; }
#view.with-palette { padding-bottom: calc(var(--nav) + var(--safe-b) + 110px); }

/* navegación inferior */
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(20, 23, 29, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; z-index: 20; }
nav#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--mu); }
nav#tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav#tabs button.on { color: var(--ac); }

.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.sp { flex: 1; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px; background: var(--card2); font-weight: 600; width: 100%; }
.btn.pri { background: var(--ac); color: var(--ac-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { min-height: 40px; width: auto; padding: 0 14px; font-size: .9rem; border-radius: 12px; }
.btn.danger { color: var(--bad); border: 1px solid #4a2a28; background: transparent; }
.btn:active { transform: scale(.98); }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-mejor { color: var(--ok); background: rgba(90, 209, 122, .13); }
.b-bueno { color: var(--good); background: rgba(184, 224, 90, .12); }
.b-ultimo { color: var(--warn); background: rgba(242, 163, 58, .14); }
.b-desaconsejado { color: var(--bad); background: rgba(239, 106, 90, .14); }
.b-prohibido { color: var(--ban); background: rgba(138, 143, 153, .15); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; font-size: .82rem; font-weight: 600; background: var(--card2); border: 1px solid transparent; }
.chip.k-eh, .chip.k-ph { color: var(--eh); background: rgba(74, 163, 255, .13); }
.chip.k-ev, .chip.k-pv { color: var(--ev); background: rgba(192, 132, 252, .14); }
.chip.k-ph, .chip.k-pv { border-color: currentColor; }
.chip.k-casa { color: var(--ac-ink); background: var(--ac); }
.chip .x { opacity: .7; font-size: .9em; margin-left: 2px; }

/* semana */
.wkhead { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.wkhead .btn.sm { width: 44px; padding: 0; }
.day { background: var(--card); border-radius: 14px; padding: 12px 12px; margin-bottom: 8px; display: grid; grid-template-columns: 52px 1fr; gap: 10px; border: 2px solid transparent; transition: border-color .15s; }
.day.today { border-color: var(--line); }
.day.past { opacity: .55; }
.day .dn { font-weight: 700; line-height: 1.1; }
.day .dn small { display: block; color: var(--mu); font-weight: 500; font-size: .78rem; }
.day .chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.day .why { font-size: .82rem; color: var(--mu); margin-top: 6px; }
.day.sel-target { border-style: dashed; border-color: var(--ac2); }
.day .acts { margin-top: 8px; }

.palette { position: fixed; left: 0; right: 0; bottom: calc(var(--nav) + var(--safe-b)); background: rgba(20, 23, 29, .97); border-top: 1px solid var(--line); padding: 8px 8px 10px; z-index: 19; }
.palette .lbl { font-size: .75rem; color: var(--mu); margin: 0 4px 6px; display: flex; justify-content: space-between; }
.palette .lbl button { color: var(--mu); text-decoration: underline; font-size: .78rem; }
.palette .items { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 560px; margin: 0 auto; }
.palette .chip { flex-direction: column; justify-content: center; gap: 2px; min-height: 54px; padding: 4px 2px; font-size: .72rem; border: 2px solid transparent; text-align: center; line-height: 1.1; }
.palette .chip.on { border-color: var(--tx); box-shadow: 0 0 0 3px rgba(255, 255, 255, .12); }
.palette .chip.empty { opacity: .35; }
.palette .chip b { font-size: .7rem; opacity: .8; }

/* sesión */
.mode { border-left: 4px solid var(--ac); }
.mode.m-moderada { border-color: var(--good); }
.mode.m-ligera { border-color: var(--warn); }
.seg { display: flex; background: var(--card2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border-radius: 9px; font-weight: 600; color: var(--mu); }
.seg button.on { background: var(--bg); color: var(--tx); }
.ex { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.ex:first-of-type { border-top: 0; }
.ex .th { background: var(--card2); border-radius: 10px; aspect-ratio: 6/5; overflow: hidden; }
.ex .nm { font-weight: 600; }
.ex .pr { font-size: .85rem; color: var(--mu); }
.ex .go { color: var(--mu); font-size: 1.4rem; }
.lvl { font-size: .72rem; color: var(--ac); font-weight: 700; }

.fig { width: 100%; height: 100%; display: block; }
.fg-floor { stroke: #3a404c; stroke-width: 1.5; }
.fg-limb, .fg-body { stroke: var(--ac); stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fg-far { stroke: var(--ac2); stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fg-head { fill: var(--ac); }
.fg-prop { fill: #343a46; }

/* hoja inferior */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .2s ease-out; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.anim { background: var(--card2); border-radius: 14px; aspect-ratio: 6/5; margin: 8px 0 14px; }
.sheet ul { margin: 6px 0 0; padding-left: 20px; }
.sheet li { margin: 4px 0; }
.levels .lv { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; }
.levels .lv.cur { background: var(--card2); }
.levels .lv .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--card2); }
.levels .lv.cur .n { background: var(--ac); color: var(--ac-ink); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* modo entreno */
#work { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; padding: 12px 16px calc(16px + var(--safe-b)); }
#work .top { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--mu); }
#work .bar { height: 4px; background: var(--card2); border-radius: 2px; margin: 10px 0 8px; overflow: hidden; }
#work .bar i { display: block; height: 100%; background: var(--ac); transition: width .3s; }
#work .stage { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 560px; width: 100%; margin: 0 auto; }
#work .anim { flex: 0 1 auto; max-height: 34dvh; aspect-ratio: 6/5; margin: 6px auto 10px; width: 100%; }
#work .title { font-size: 1.35rem; font-weight: 700; text-align: center; }
#work .sub { text-align: center; color: var(--mu); margin-top: 2px; }
#work .big { font-size: 4.2rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.05; margin: 8px 0; }
#work .big.over { color: var(--ac); }
#work .stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0; }
#work .stepper button { width: 64px; height: 64px; border-radius: 50%; background: var(--card2); font-size: 2rem; font-weight: 700; }
#work .stepper .val { font-size: 3.6rem; font-weight: 800; min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; }
#work .foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
#work .hint { text-align: center; font-size: .85rem; color: var(--mu); margin: 4px 0; }
#work .rest-ring { text-align: center; }
#work .tip { background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: .88rem; color: var(--mu); }
.sets-dots { display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.sets-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--card2); }
.sets-dots i.d { background: var(--ac); }
.sets-dots i.c { background: transparent; border: 2px solid var(--ac); }

/* progreso */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { font-size: .75rem; color: var(--mu); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; padding-top: 8px; }
.bars .bc { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--card2); min-height: 4px; }
.bars .b.full { background: var(--ac); }
.bars .b.half { background: var(--ac2); }
.bars small { font-size: .65rem; color: var(--mu); }
.spark { width: 90px; height: 28px; }
.spark polyline { fill: none; stroke: var(--ac); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + var(--safe-b) + 120px); transform: translateX(-50%); background: #2b303b; color: var(--tx); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: .9rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); animation: fade .2s; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.switch:first-child { border-top: 0; }
.tg { width: 50px; height: 30px; border-radius: 15px; background: var(--card2); position: relative; flex: none; }
.tg::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--mu); transition: .15s; }
.tg.on { background: var(--ac2); }
.tg.on::after { left: 23px; background: var(--ac); }
.empty-state { text-align: center; padding: 18px 8px; color: var(--mu); }
.done-tag { color: var(--ok); font-weight: 700; }

/* muñeco con volumen */
.fb-skin, .fb-skin * { fill: #e7b28a; }
.fb-shirt, .fb-shirt * { fill: var(--ac); }
.fb-shorts, .fb-shorts * { fill: #2f4f96; }
.fb-shoe, .fb-shoe * { fill: #eef1f5; }
.fb-hair { fill: #3a2a20; }
.fb-far { filter: brightness(.62); }
.fg-mat { fill: #2a303b; }
.mk-arrow { stroke: #ffd166; stroke-width: 1.8; stroke-linecap: round; }
.mk-head { fill: #ffd166; }
.mk-line { stroke: #7fd6ff; stroke-width: 1.1; stroke-dasharray: 2.5 2; }
.mk-angle { stroke: #ff8fa3; stroke-width: 1.3; fill: none; }
.mk-txt { font: 600 5.6px system-ui, sans-serif; paint-order: stroke; stroke: #0f1115; stroke-width: 2px; stroke-linejoin: round; }
.mk-txt-a { fill: #ffd166; } .mk-txt-l { fill: #7fd6ff; } .mk-txt-g { fill: #ff8fa3; }
.steps { display: grid; gap: 10px; margin: 8px 0 14px; }
.stepfig { margin: 0; background: var(--card2); border-radius: 14px; overflow: hidden; }
.stepfig svg { height: auto; }
.stepfig figcaption { padding: 8px 12px 12px; font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.stepfig figcaption b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ac); color: var(--ac-ink); display: grid; place-items: center; font-size: .8rem; }
.mk-txt-w { fill: #ffffff; }
