/* ============================================================
   style.css — Oscuro por defecto, mobile-first, botones grandes.
   ============================================================ */

:root {
  --bg: #0d1117;
  --bg2: #151b24;
  --card: #1a212c;
  --card2: #212a37;
  --line: #2a3441;
  --txt: #e8edf3;
  --txt2: #95a3b5;
  --txt3: #64748b;
  --acc: #ff5a1f;
  --acc2: #ff7a45;
  --ok: #26c281;
  --warn: #f5b301;
  --bad: #ff4d4d;
  --info: #4a9eff;
  --r: 16px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-tema="claro"] {
  --bg: #f4f6f9; --bg2: #ffffff; --card: #ffffff; --card2: #eef1f6;
  --line: #dde3ec; --txt: #101720; --txt2: #5a6878; --txt3: #8b98a8;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--txt2); font-size: 13px; }
.center { text-align: center; }

/* ---------- LAYOUT ---------- */
.app { height: 100dvh; display: flex; flex-direction: column; }
.view { position: absolute; inset: 0; bottom: calc(var(--nav-h) + var(--safe-b)); display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + var(--safe-t)) 18px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.date { font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--txt2); }
.topbar-sub { font-size: 18px; font-weight: 800; margin-top: 2px; }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 28px; }

/* ---------- NAV ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg2); border-top: 1px solid var(--line);
}
.nav-btn {
  background: none; border: 0; color: var(--txt3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .05em; font-family: inherit;
}
.nav-btn span { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.55); transition: .15s; }
.nav-btn.active { color: var(--acc); }
.nav-btn.active span { filter: none; transform: translateY(-1px); }

/* ---------- CARDS ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; margin-bottom: 14px;
}
.card-tight { padding: 13px 14px; }
.card-title {
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  color: var(--txt2); margin-bottom: 12px; display: flex;
  align-items: center; justify-content: space-between; gap: 8px;
}

/* ---------- HERO ENTRENO ---------- */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--hero-c, var(--acc));
}
.hero-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 900; letter-spacing: .1em;
  color: var(--hero-c, var(--acc)); margin-bottom: 6px;
}
.hero-name { font-size: 26px; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.hero-sub { color: var(--txt2); font-size: 14px; margin-top: 3px; }
.hero-meta { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0 16px; }
.meta { display: flex; flex-direction: column; }
.meta-v { font-size: 19px; font-weight: 800; }
.meta-k { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--txt3); }

/* ---------- BOTONES ---------- */
.btn {
  font-family: inherit; font-weight: 800; border: 0; cursor: pointer;
  border-radius: 13px; padding: 14px 18px; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, filter .12s; width: 100%;
  background: var(--card2); color: var(--txt);
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--acc); color: #fff; }
.btn-primary:active { filter: brightness(1.1); }
.btn-ok { background: var(--ok); color: #04150e; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--txt); }
.btn-danger { background: transparent; border: 1.5px solid var(--bad); color: var(--bad); }
.btn-xl { padding: 19px; font-size: 17px; letter-spacing: .06em; border-radius: 15px; }
.btn-sm { padding: 9px 13px; font-size: 13px; width: auto; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  width: 42px; height: 42px; border-radius: 12px; font-size: 18px;
  cursor: pointer; flex-shrink: 0; display: grid; place-items: center; font-family: inherit;
}

/* ---------- MACROS ---------- */
.kcal-big { display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px; }
.kcal-n { font-size: 34px; font-weight: 900; letter-spacing: -.03em; }
.kcal-t { font-size: 15px; color: var(--txt3); font-weight: 700; }

.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .35s cubic-bezier(.4,0,.2,1); }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-top: 15px; }
.macro-k { font-size: 10px; font-weight: 800; letter-spacing: .07em; color: var(--txt3); }
.macro-v { font-size: 15px; font-weight: 800; margin: 3px 0 6px; }
.macro-v small { color: var(--txt3); font-weight: 700; font-size: 11px; }

/* ---------- AGUA ---------- */
.water-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.water-n { font-size: 22px; font-weight: 900; white-space: nowrap; }
.water-n small { font-size: 13px; color: var(--txt3); }

/* ---------- LISTAS ---------- */
.li {
  display: flex; align-items: center; gap: 13px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; margin-bottom: 9px; cursor: pointer;
}
.li-num {
  width: 30px; height: 30px; border-radius: 9px; background: var(--card2);
  display: grid; place-items: center; font-size: 12px; font-weight: 900;
  color: var(--txt2); flex-shrink: 0;
}
.li-main { flex: 1; min-width: 0; }
.li-t { font-weight: 700; font-size: 15px; }
.li-s { font-size: 12.5px; color: var(--txt2); margin-top: 1px; }
.li-r { text-align: right; flex-shrink: 0; }
.li.done { opacity: .5; }
.li.done .li-t { text-decoration: line-through; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 99px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  background: var(--card2); color: var(--txt2);
}
.pill.ok { background: rgba(38,194,129,.16); color: var(--ok); }
.pill.warn { background: rgba(245,179,1,.16); color: var(--warn); }
.pill.bad { background: rgba(255,77,77,.16); color: var(--bad); }
.pill.info { background: rgba(74,158,255,.16); color: var(--info); }

/* ---------- MODO ENTRENAMIENTO ---------- */
.workout {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
}
.wo-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 14px 10px; flex-shrink: 0;
}
.wo-top-mid { flex: 1; text-align: center; min-width: 0; }
.wo-name { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--txt2); }
.wo-clock { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.wo-progress { height: 3px; background: var(--card2); flex-shrink: 0; }
.wo-progress-fill { height: 100%; background: var(--acc); transition: width .3s; }
.wo-body { flex: 1; overflow-y: auto; padding: 20px 18px 10px; }
.wo-foot { padding: 12px 18px calc(18px + var(--safe-b)); flex-shrink: 0; }

.ex-head { margin-bottom: 4px; }
.ex-idx { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--acc); }
.ex-name { font-size: 29px; font-weight: 900; letter-spacing: -.03em; line-height: 1.08; margin: 4px 0 10px; }
.ex-specs { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 4px; }
.spec {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; font-size: 13px; font-weight: 700;
}
.spec b { color: var(--acc); }
.ex-note {
  background: rgba(245,179,1,.09); border: 1px solid rgba(245,179,1,.3);
  color: #ffd97a; border-radius: 11px; padding: 11px 13px;
  font-size: 13px; line-height: 1.4; margin-top: 12px;
}
[data-tema="claro"] .ex-note { color: #7a5a00; }

/* series */
.sets { margin-top: 18px; }
.set-row {
  display: grid; grid-template-columns: 34px 1fr 1fr 44px; gap: 9px;
  align-items: center; margin-bottom: 9px;
}
.set-n {
  font-size: 12px; font-weight: 900; color: var(--txt3);
  text-align: center; font-variant-numeric: tabular-nums;
}
.set-row input {
  width: 100%; background: var(--card); border: 1.5px solid var(--line);
  color: var(--txt); border-radius: 11px; padding: 13px 8px;
  font-size: 18px; font-weight: 800; text-align: center;
  font-family: inherit; font-variant-numeric: tabular-nums;
}
.set-row input:focus { outline: none; border-color: var(--acc); }
.set-check {
  width: 44px; height: 46px; border-radius: 11px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--txt3); font-size: 19px; cursor: pointer;
  display: grid; place-items: center; font-family: inherit;
}
.set-row.done .set-check { background: var(--ok); border-color: var(--ok); color: #04150e; }
.set-row.done input { opacity: .5; border-color: transparent; background: var(--card2); }
.set-row.active input { border-color: var(--acc); }
.set-hd {
  display: grid; grid-template-columns: 34px 1fr 1fr 44px; gap: 9px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .09em;
  color: var(--txt3); text-align: center; margin-bottom: 7px;
}

.prev-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-top: 16px; font-size: 13px;
}
.prev-box .k { font-size: 10px; font-weight: 800; letter-spacing: .09em; color: var(--txt3); }
.prev-sets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.prev-set { background: var(--card2); border-radius: 8px; padding: 4px 9px; font-weight: 700; font-size: 12.5px; }
.suggest {
  margin-top: 11px; padding: 10px 12px; border-radius: 10px;
  background: rgba(38,194,129,.12); border: 1px solid rgba(38,194,129,.32);
  color: var(--ok); font-size: 13px; font-weight: 700;
}

/* RIR */
.rir-ask { margin-top: 16px; }
.rir-q { font-size: 13px; font-weight: 700; color: var(--txt2); margin-bottom: 9px; text-align: center; }
.rir-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rir-b {
  padding: 15px 4px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--txt); font-weight: 800; font-size: 14px;
  cursor: pointer; font-family: inherit;
}
.rir-b.sel { background: var(--acc); border-color: var(--acc); color: #fff; }
.rir-timer { height: 2px; background: var(--acc); margin-top: 9px; border-radius: 2px; transition: width .95s linear; }

/* ---------- DESCANSO ---------- */
.rest {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 26px calc(26px) calc(30px + var(--safe-b));
}
.rest.almost { animation: pulseBg 1s ease-in-out infinite; }
@keyframes pulseBg { 0%,100% { background: var(--bg); } 50% { background: #2a1208; } }
.rest-label { font-size: 12px; font-weight: 900; letter-spacing: .18em; color: var(--txt2); }
.rest-next { font-size: 15px; font-weight: 700; color: var(--txt); text-align: center; min-height: 22px; }
.rest-ring { position: relative; width: min(72vw, 280px); aspect-ratio: 1; }
.rest-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--card2); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--acc); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 578; stroke-dashoffset: 0; transition: stroke-dashoffset .95s linear, stroke .3s;
}
.rest.almost .ring-fg { stroke: var(--bad); }
.rest-time {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 60px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.04em;
}
.rest-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 380px; }
.rest-btns .btn { padding: 15px 6px; font-size: 14px; }
.rest > .btn-xl { max-width: 380px; }

/* ---------- RESUMEN FINAL ---------- */
.finish { text-align: center; padding: 12px 0; }
.finish-emo { font-size: 58px; }
.finish-t { font-size: 25px; font-weight: 900; margin: 6px 0 20px; }
.finish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.finish-cell { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 15px; }
.finish-v { font-size: 25px; font-weight: 900; font-variant-numeric: tabular-nums; }
.finish-k { font-size: 10px; font-weight: 800; letter-spacing: .09em; color: var(--txt3); margin-top: 2px; }
.pr-badge {
  background: linear-gradient(135deg, var(--acc), #ff9a3d); color: #fff;
  border-radius: 13px; padding: 14px; margin-top: 12px; font-weight: 800; font-size: 15px;
}

/* ---------- SHEET ---------- */
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; }
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.sheet-card {
  position: relative; width: 100%; max-height: 88dvh; overflow-y: auto;
  background: var(--bg2); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 18px calc(24px + var(--safe-b));
  animation: up .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes up { from { transform: translateY(100%); } }
.sheet-handle { width: 42px; height: 4px; border-radius: 99px; background: var(--line); margin: 6px auto 16px; cursor: pointer; }
.sheet-title { font-size: 21px; font-weight: 900; letter-spacing: -.02em; margin-bottom: 3px; }
.sheet-sub { color: var(--txt2); font-size: 13px; margin-bottom: 16px; }
.sh-sec { margin-bottom: 15px; }
.sh-k { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--acc); margin-bottom: 5px; }
.sh-v { font-size: 14px; line-height: 1.55; color: var(--txt); }
.sh-v ul { padding-left: 18px; }
.sh-v li { margin-bottom: 4px; }
.media-slot {
  border: 1.5px dashed var(--line); border-radius: 13px; padding: 24px;
  text-align: center; color: var(--txt3); font-size: 13px; margin-bottom: 15px;
}

/* ---------- FORMULARIOS ---------- */
.onboarding { position: fixed; inset: 0; z-index: 100; background: var(--bg); overflow-y: auto; }
.ob-inner { max-width: 520px; margin: 0 auto; padding: calc(30px + var(--safe-t)) 20px calc(40px + var(--safe-b)); }
.ob-head { text-align: center; margin-bottom: 26px; }
.ob-logo { font-size: 46px; }
.ob-head h1 { font-size: 27px; font-weight: 900; letter-spacing: -.02em; margin: 6px 0 6px; }

.form label { display: block; margin-bottom: 13px; font-size: 12px; font-weight: 800; letter-spacing: .05em; color: var(--txt2); }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: 6px;
  background: var(--card); border: 1.5px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 13px 14px; font-size: 16px; font-weight: 600;
  font-family: inherit; letter-spacing: normal;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--acc); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form fieldset { border: 0; margin-bottom: 13px; }
.form legend { font-size: 12px; font-weight: 800; letter-spacing: .05em; color: var(--txt2); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--txt2); font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.disclaimer {
  font-size: 11.5px; line-height: 1.5; color: var(--txt3);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin: 16px 0;
}

/* ---------- GRÁFICOS ---------- */
.chart { width: 100%; height: 150px; display: block; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--txt3); margin-top: 6px; font-weight: 700; }

.wk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk-cell {
  border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  padding: 9px 3px; text-align: center;
}
.wk-cell.today { border-color: var(--info); box-shadow: 0 0 0 1px var(--info) inset; }
.wk-d { font-size: 10px; font-weight: 900; color: var(--txt3); }
.wk-i { font-size: 14px; margin-top: 5px; line-height: 1.25; }

/* ---------- MISC ---------- */
.food-row {
  display: grid; grid-template-columns: 1fr 78px 30px; gap: 9px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.food-row:last-of-type { border-bottom: 0; }
.food-n { font-size: 14px; font-weight: 600; }
.food-m { font-size: 11px; color: var(--txt3); }
.food-row input {
  background: var(--card2); border: 1.5px solid var(--line); color: var(--txt);
  border-radius: 9px; padding: 9px 6px; font-size: 15px; font-weight: 800;
  text-align: center; width: 100%; font-family: inherit;
}
.food-row input:focus { outline: none; border-color: var(--acc); }
.x-btn { background: none; border: 0; color: var(--txt3); font-size: 19px; cursor: pointer; font-family: inherit; }

.search {
  width: 100%; background: var(--card); border: 1.5px solid var(--line);
  color: var(--txt); border-radius: 12px; padding: 13px 14px;
  font-size: 16px; font-family: inherit; margin-bottom: 12px;
}
.search:focus { outline: none; border-color: var(--acc); }

.tabs { display: flex; gap: 7px; padding: 12px 16px 0; overflow-x: auto; flex-shrink: 0; }
.tab {
  padding: 8px 15px; border-radius: 99px; border: 1.5px solid var(--line);
  background: transparent; color: var(--txt2); font-size: 13px; font-weight: 800;
  white-space: nowrap; cursor: pointer; font-family: inherit;
}
.tab.active { background: var(--acc); border-color: var(--acc); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  transform: translateX(-50%); z-index: 120;
  background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  padding: 12px 20px; border-radius: 99px; font-size: 14px; font-weight: 700;
  box-shadow: 0 8px 28px rgba(0,0,0,.45); animation: up2 .2s;
  max-width: 90vw; text-align: center;
}
@keyframes up2 { from { transform: translate(-50%, 12px); opacity: 0; } }

.empty { text-align: center; padding: 46px 20px; color: var(--txt3); }
.empty-e { font-size: 42px; margin-bottom: 10px; }
.sec-h {
  font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--txt3);
  margin: 22px 0 10px;
}
.sec-h:first-child { margin-top: 0; }

@media (min-width: 700px) {
  .view, .workout, .rest { max-width: 560px; margin: 0 auto; }
  .nav { max-width: 560px; left: 50%; transform: translateX(-50%); }
  .sheet-card { max-width: 560px; margin: 0 auto; border-radius: 22px; margin-bottom: 20px; }
  .sheet { align-items: center; justify-content: center; padding: 20px; }
}
