:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #9aa1ae;
  --accent: #c6f432;      /* lima: entreno */
  --accent-ink: #11140a;
  --warm: #ff7a45;        /* naranja: nutrición */
  --protein: #5cc8ff;
  --carbs: #ffc857;
  --fat: #ff7aa8;
  --danger: #ff5d5d;
  --radius: 16px;
  --tabbar-h: 64px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.15; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; padding-top: calc(.75rem + env(safe-area-inset-top));
  background: rgba(15, 17, 21, .85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom)); outline: none; }
body.onboarding .tabbar { display: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(23, 26, 33, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }
.tabbar a[data-tab="nutricion"].active { color: var(--warm); }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.flat { background: var(--surface-2); border: none; }
.row { display: flex; gap: .75rem; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
.stack > * + * { margin-top: .75rem; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 1.5rem 0 .75rem; }
.section-title h2 { margin: 0; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: .7rem 1rem; border-radius: 12px; font: inherit; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.warm { background: var(--warm); color: #1a0d06; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: .4rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .chip:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }
.chip.warm.on { background: var(--warm); color: #1a0d06; }
button.chip { cursor: pointer; font: inherit; font-size: .8rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }

label.field { display: block; margin-bottom: .85rem; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit;
}
input[type="number"] { -moz-appearance: textfield; }
.search { margin-bottom: .75rem; }

/* opciones grandes tipo tarjeta en onboarding */
.options { display: grid; gap: .6rem; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.option {
  text-align: left; padding: .85rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer;
}
.option strong { display: block; margin-bottom: .15rem; }
.option small { color: var(--muted); }
.option.on { border-color: var(--accent); background: rgba(198, 244, 50, .08); }

.progress-dots { display: flex; gap: .35rem; margin-bottom: 1.25rem; }
.progress-dots i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.progress-dots i.on { background: var(--accent); }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item {
  display: flex; align-items: center; gap: .75rem; padding: .75rem; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; width: 100%; font: inherit; text-align: left;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; }
.list-item .sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 46px; height: 46px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.thumb svg { width: 40px; height: 46px; }

.level { display: inline-flex; gap: 2px; }
.level i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); }
.level i.on { background: var(--accent); }

/* ---------- stats / macros ---------- */
.stat { background: var(--surface-2); border-radius: 12px; padding: .75rem; }
.stat .v { font-size: 1.35rem; font-weight: 800; }
.stat .l { font-size: .75rem; color: var(--muted); }
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .3s ease; }
.bar.over > i { background: var(--danger); }
.macro-row { display: grid; grid-template-columns: 90px 1fr auto; gap: .6rem; align-items: center; font-size: .85rem; margin-bottom: .55rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: .35rem; }

.ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .center b { font-size: 1.5rem; display: block; }

/* ---------- entreno ---------- */
.day-tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; scrollbar-width: none; }
.day-tabs button { flex-shrink: 0; }
.exercise-block { border-top: 1px solid var(--line); padding: .85rem 0; }
.exercise-block:first-of-type { border-top: none; }
.set-table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .9rem; }
.set-table th { font-size: .7rem; color: var(--muted); text-align: left; font-weight: 600; padding: 0 .25rem .3rem; }
.set-table td { padding: .2rem .25rem; }
.set-table input { padding: .45rem; text-align: center; }
.set-table .done-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 1rem; }
.set-table tr.done .done-btn { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.set-table tr.done input { opacity: .7; }
.rest-timer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: 999px; font-weight: 800; z-index: 20;
  display: flex; gap: .75rem; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.rest-timer button { background: rgba(0,0,0,.15); border: none; border-radius: 999px; padding: .25rem .6rem; font: inherit; font-weight: 700; cursor: pointer; color: inherit; }

/* ---------- detalle ejercicio ---------- */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: center; }
@media (max-width: 520px) { .hero { grid-template-columns: 1fr; } }
.bodymap { display: flex; gap: .5rem; justify-content: center; background: var(--surface-2); border-radius: var(--radius); padding: .75rem; }
.bodymap svg { width: 46%; max-width: 150px; height: auto; }
.bodymap .m, .bodymap-mini .m { fill: #2b313d; stroke: #12151b; stroke-width: 1; }
.bodymap .m.primary, .bodymap-mini .m.primary { fill: var(--accent); }
.bodymap .m.secondary, .bodymap-mini .m.secondary { fill: #6d8a1c; }
.bodymap .base, .bodymap-mini .base { fill: #232833; }
.bodymap-mini { display: contents; }
.legend { display: flex; gap: 1rem; font-size: .75rem; color: var(--muted); justify-content: center; margin-top: .5rem; }
ol.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 0; }
ol.steps li { counter-increment: s; position: relative; padding: 0 0 .85rem 2.4rem; line-height: 1.5; }
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; font-size: .85rem;
}
ul.ticks, ul.crosses { padding-left: 0; list-style: none; margin: 0; }
ul.ticks li, ul.crosses li { padding: 0 0 .5rem 1.6rem; position: relative; line-height: 1.45; }
ul.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }
ul.crosses li::before { content: "✕"; position: absolute; left: 0; color: var(--danger); font-weight: 800; }

/* ---------- nutrición ---------- */
.meal { margin-bottom: 1rem; }
.meal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.entry { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.entry:last-child { border-bottom: none; }
.entry .x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 .3rem; }
.water { display: flex; gap: .35rem; flex-wrap: wrap; }
.water button { width: 34px; height: 42px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.water button.on { background: var(--protein); border-color: transparent; }
.recipe-card { padding: 0; overflow: hidden; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.recipe-card .top { height: 74px; display: flex; align-items: flex-end; padding: .75rem; background: linear-gradient(135deg, #3a2316, #1f232c); font-size: 1.8rem; }
.recipe-card .body { padding: .75rem; }
.macro-pills { display: flex; gap: .35rem; flex-wrap: wrap; font-size: .75rem; }
.macro-pills span { padding: .15rem .45rem; border-radius: 6px; background: var(--surface-2); }

/* ---------- modal / toast ---------- */
dialog {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 20px; padding: 0;
  width: min(560px, calc(100vw - 1.5rem)); max-height: 88dvh;
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
#modal-body { padding: 1.1rem; overflow-y: auto; max-height: 88dvh; }
#toast {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; font-weight: 650; font-size: .9rem;
  transition: all .25s ease; pointer-events: none; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.banner { background: linear-gradient(135deg, rgba(198,244,50,.16), rgba(255,122,69,.12)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.note { font-size: .8rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: .75rem; margin: 1rem 0; }
.cap::first-letter { text-transform: uppercase; }
b.cap { display: inline-block; }

/* ---------- demostración animada ---------- */
.demo { background: var(--surface-2); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.demo-stage { aspect-ratio: 240 / 225; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #232936, #181b22); }
.demo-svg, .demo-video { width: 100%; height: 100%; display: block; object-fit: contain; }
.demo-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .55rem .7rem; border-top: 1px solid var(--line); }
.demo-phase { font-size: .85rem; font-weight: 650; color: var(--accent); min-height: 1.2em; }
.d-ground { stroke: #3a4150; stroke-width: 2; }
.d-limb { fill: none; stroke: #e9edf3; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.d-far .d-limb { stroke: #6b7486; }
.d-torso { stroke: #e9edf3; stroke-width: 11; stroke-linecap: round; }
.d-head { fill: #e9edf3; }
.d-arm { stroke: #f4f6f9; }
.d-plate { fill: #2e3440; stroke: var(--accent); stroke-width: 3; }
.d-hub { fill: var(--accent); }
.d-db { fill: var(--accent); stroke: #11140a; stroke-width: 1; }
.d-bar { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.d-cable { stroke: #8a93a3; stroke-width: 1.5; stroke-dasharray: 3 3; }
.d-band { stroke: var(--warm); stroke-width: 2.5; }
.d-equip { fill: #3a4150; }
.d-equip-line { fill: none; stroke: #3a4150; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.linkish { background: none; border: none; color: inherit; font: inherit; font-weight: 700; padding: 0; cursor: pointer; text-align: left; }
.play-pill { display: inline-block; font-size: .7rem; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: .1rem .45rem; margin-left: .25rem; vertical-align: middle; }
