:root {
  --bg: #0b0f14;
  --bg2: #121822;
  --card: #161e2a;
  --card2: #1c2636;
  --line: #243044;
  --txt: #e8eef6;
  --muted: #8aa0b8;
  --pri: #34d399;
  --pri-d: #10b981;
  --accent: #60a5fa;
  --warn: #f59e0b;
  --hot: #f87171;
  --radius: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h2 { font-size: 1.4rem; margin: .2em 0 .3em; }
h3 { font-size: 1.05rem; margin: 1.4em 0 .4em; color: var(--txt); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.cap { text-transform: capitalize; }
.center { text-align: center; }
b { color: #fff; font-weight: 600; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .3px; }
.brand span { color: var(--pri); }

#app { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 24px); }
.container { padding: 4px 16px 8px; max-width: 640px; margin: 0 auto; }

/* ---- tabbar ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(13,18,26,.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
#tabbar button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .68rem; font-family: inherit; cursor: pointer;
}
#tabbar button .ico { font-size: 1.3rem; filter: grayscale(.4); opacity: .7; }
#tabbar button.active { color: var(--pri); }
#tabbar button.active .ico { filter: none; opacity: 1; }
body.runner-open #tabbar, body.runner-open .topbar, body.runner-open #app { display: none; }

/* ---- day strip ---- */
.day-strip { display: flex; gap: 8px; justify-content: space-between; margin: 6px 0 14px; }
.chip {
  flex: 1; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-weight: 700; font-size: .9rem;
  cursor: pointer; position: relative;
}
.chip.str { border-color: #2a4; }
.chip.cardio { border-color: #46c; }
.chip.rest { opacity: .6; }
.chip.today::after { content: ''; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.chip.sel { background: var(--pri); color: #04110b; border-color: var(--pri); }

.today-head { margin-bottom: 8px; }
.session-title { font-size: 1.5rem; font-weight: 800; margin: 2px 0 12px; }

/* ---- exercise cards ---- */
.ex-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.ex-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.ex-thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--card2); flex: none; }
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 600; }
.badge { font-size: .78rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge.up { background: rgba(52,211,153,.16); color: var(--pri); }
.badge.hold { background: rgba(96,165,250,.16); color: var(--accent); }
.badge.new { background: var(--card2); color: var(--muted); }

.rota-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 2px; text-decoration: underline; }
.link.danger { color: var(--hot); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.rest-card { text-align: center; }
.big-emoji { font-size: 3rem; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card2); color: var(--txt);
  font: inherit; font-weight: 600; border-radius: 14px; padding: 12px 16px;
  cursor: pointer; width: 100%; margin: 6px 0; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--pri), var(--pri-d)); color: #042016; border: 0; box-shadow: 0 6px 20px rgba(16,185,129,.25); }
.btn.big { padding: 16px; font-size: 1.1rem; }
.btn.ghost { background: transparent; }
.btn.sm { width: auto; padding: 8px 12px; font-size: .85rem; margin: 0; }
.btn.danger { color: var(--hot); border-color: rgba(248,113,113,.4); }

/* ---- plan ---- */
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-row { text-align: left; background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; cursor: pointer; color: var(--txt); font: inherit; }
.plan-row.str { border-left-color: var(--pri); }
.plan-row.cardio { border-left-color: var(--accent); }
.plan-row.rest { border-left-color: var(--line); opacity: .8; }
.plan-day { font-weight: 700; }
.plan-day .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; margin-left: 4px; }

/* ---- progress ---- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat-n { font-size: 1.6rem; font-weight: 800; color: var(--pri); }
.stat-l { font-size: .78rem; color: var(--muted); }
.ex-select { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.pill { white-space: nowrap; background: var(--card); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .85rem; cursor: pointer; }
.pill.sel { background: var(--pri); color: #042016; border-color: var(--pri); font-weight: 700; }
.pill.empty { opacity: .5; }
.rec { border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: .9rem; }
.rec.up { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.4); color: #aef0d6; }
.rec.hold { background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.rec.mini { font-size: .85rem; padding: 8px 10px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.chart-title { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 9px; }
.chart .xlab { text-anchor: middle; }
.chart-empty { color: var(--muted); font-size: .85rem; padding: 24px 0; text-align: center; }
.hist-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 6px; }
.hist-table th, .hist-table td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.hist-table th { color: var(--muted); font-weight: 600; }
.hist-list { display: flex; flex-direction: column; gap: 6px; }
.sess-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }

/* ---- settings ---- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--pri); border-color: var(--pri); }
.switch input:checked + span::before { transform: translateX(20px); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--card2); border: 0; color: var(--muted); padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--pri); color: #042016; }
.steps { padding-left: 1.2em; }
.steps li { margin: 4px 0; }
.voice-status { margin-top: 10px; }
.resume-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(96,165,250,.12); border: 1px solid rgba(96,165,250,.4); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; }
.resume-banner .btn { width: auto; margin: 0; }

/* ---- calentamiento ---- */
.warmup { padding: 12px 14px; margin-bottom: 16px; }
.warmup > summary { cursor: pointer; font-weight: 700; list-style: none; }
.warmup > summary::-webkit-details-marker { display: none; }
.warmup > summary::before { content: '▸ '; color: var(--muted); }
.warmup[open] > summary::before { content: '▾ '; }
.warmup-block { margin-top: 10px; }
.warmup-name { font-weight: 600; font-size: .92rem; }
.warmup .cues { margin: 4px 0 0; color: var(--muted); }

/* =========================================================
   RUNNER
   ========================================================= */
.runner:not([hidden]) {
  position: fixed; inset: 0; z-index: 20;
  background: radial-gradient(120% 70% at 50% 0%, #16233a 0%, var(--bg) 60%);
  display: flex; flex-direction: column;
  padding-top: var(--safe-t);
}
.runner-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.runner-title { flex: 1; text-align: center; font-size: .85rem; color: var(--muted); }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line); color: var(--txt); font-size: 1rem; cursor: pointer; flex: none; }
.dots { display: flex; gap: 5px; flex: none; min-width: 38px; justify-content: flex-end; }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.sdot.on { background: var(--pri); }
.sdot.cur { background: var(--accent); box-shadow: 0 0 0 3px rgba(96,165,250,.25); }

.runner-scroll { flex: 1; overflow-y: auto; padding: 4px 18px 18px; -webkit-overflow-scrolling: touch; text-align: center; }
.ex-h { font-size: 1.5rem; margin: 4px 0 12px; }

.demo { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 0 auto 14px; max-width: 360px; }
.demo img { width: 100%; border-radius: 10px; background: #fff; aspect-ratio: 4/3; object-fit: contain; }
.demo.no-img img { display: none; }
.demo.no-img::before { content: '🎥 Toca “Ver vídeo” para la demostración'; display: block; color: var(--muted); padding: 28px 10px; font-size: .9rem; }
.demo-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.cues { text-align: left; margin: 10px 4px 2px; padding-left: 1.2em; color: var(--muted); font-size: .9rem; }
.cues li { margin: 3px 0; }

.timer-wrap { max-width: 420px; margin: 0 auto; }
.state-label { font-size: 1rem; font-weight: 700; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
.state-label.hot { color: var(--hot); }
.timer { font-size: 4.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; margin: 4px 0; }
.timer-bartrack { height: 8px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 8px auto 14px; max-width: 320px; }
.timer-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--pri)); transition: width .2s linear; }
.controls { display: flex; gap: 10px; }
.controls .btn { margin: 6px 0; }

.ask { max-width: 360px; margin: 6px auto; }
.ask-q { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; }
.ask-actions { margin-top: 6px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0 18px; }
.stepper input {
  width: 130px; text-align: center; font-size: 2.6rem; font-weight: 800;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; color: var(--txt);
  padding: 8px 4px; font-variant-numeric: tabular-nums;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step { width: 60px; height: 60px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line); color: var(--txt); font-size: 1.8rem; font-weight: 700; cursor: pointer; flex: none; }

.done { max-width: 360px; margin: 20px auto; }
.cardio-emoji { font-size: 3.2rem; margin: 10px 0; }

/* ---- mic bar ---- */
.mic-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line); background: rgba(13,18,26,.9); backdrop-filter: blur(10px);
}
.mic-toggle { width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--line); background: var(--card2); font-size: 1.4rem; cursor: pointer; flex: none; }
.mic-bar.on .mic-toggle { background: rgba(52,211,153,.18); border-color: var(--pri); animation: pulse 1.6s infinite; }
.mic-bar.speaking .mic-toggle { background: rgba(96,165,250,.2); border-color: var(--accent); }
.mic-bar.off .mic-toggle { opacity: .6; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,.4); } 50% { box-shadow: 0 0 0 8px rgba(52,211,153,0); } }
.mic-info { text-align: left; min-width: 0; flex: 1; }
.mic-state { font-size: .82rem; color: var(--muted); }
.mic-heard { font-size: .95rem; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
