/* styles.css — tema oscuro deportivo, responsive (móvil + PC). */
:root {
  --bg: #0f1420;
  --bg2: #161d2e;
  --card: #1b2436;
  --card2: #212c42;
  --line: #2b3650;
  --txt: #eaf0fb;
  --muted: #95a3c0;
  --accent: #34d399;     /* verde */
  --accent2: #22c55e;
  --hi: #38bdf8;         /* azul */
  --warn: #f59e0b;
  --danger: #ef4444;
  --fig: #eaf0fb;
  --radius: 16px;
  --maxw: 760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, rgba(52, 211, 153, .08), transparent), var(--bg);
  background-color: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app { max-width: var(--maxw); margin: 0 auto; }
.view { padding: 16px 16px 90px; }
body.fullscreen .view { padding: 0; }
body.fullscreen #app { max-width: 100%; }

/* Topbar */
.topbar { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 14px; }
.topbar h1 { font-size: 1.5rem; margin: 0; letter-spacing: .3px; }
.ver { color: var(--muted); font-size: .8rem; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card-title { margin: 0 0 12px; font-size: 1.02rem; color: var(--txt); }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.error { color: var(--danger); }
.warn { color: var(--warn); font-size: .85rem; }
.src { color: var(--muted); font-size: .78rem; text-align: right; }
.loading { color: var(--muted); }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat-val { font-size: 1.3rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.stat.hi .stat-val { color: var(--hi); }
.stat.good .stat-val { color: var(--accent); }
.if-line { margin: 10px 0 0; font-size: .92rem; }
.proj-line { margin: 6px 0 0; font-size: .9rem; color: var(--accent); }

/* Buttons */
.btn {
  background: var(--card2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; font-size: .95rem; cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}
.btn:hover { background: #28344e; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #06281b; border: none; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: #fca5a5; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn.big { font-size: 1.6rem; width: 76px; height: 76px; border-radius: 50%; }
.btn-row, .plan-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.plan-actions { margin-bottom: 14px; }
.plan-actions .btn { flex: 1; }

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(15,20,32,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  max-width: var(--maxw); margin: 0 auto; padding-bottom: env(safe-area-inset-bottom);
}
body.fullscreen .tabbar { display: none; }
.tab { flex: 1; background: none; border: none; color: var(--muted); padding: 9px 0 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab-ico { font-size: 1.25rem; }
.tab-lbl { font-size: .68rem; }
.tab.active { color: var(--accent); }

/* Today card */
.today-card { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.today-card.rest { text-align: center; }
.today-focus { font-size: 1.1rem; font-weight: 700; }
.today-meta { color: var(--muted); font-size: .88rem; margin: 4px 0 0; }

/* Week mini */
.weekmini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.weekmini-day { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 8px 0; }
.weekmini-day.rest { opacity: .55; }
.weekmini-day.today { border-color: var(--accent); }
.weekmini-day .wd { display: block; font-size: .7rem; color: var(--muted); }
.weekmini-day .wm { font-size: 1rem; }

/* Plan days */
.plan-days { display: grid; gap: 12px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.day.today { border-color: var(--accent); }
.day.rest { opacity: .6; display: flex; justify-content: space-between; align-items: center; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; }
.day-name { font-weight: 700; }
.day-focus { color: var(--hi); font-size: .85rem; }
.day-meta { color: var(--muted); font-size: .82rem; margin: 6px 0; }
.day-ex { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: .76rem; color: var(--muted); }

/* Meals */
.meal-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ms { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.ms b { font-size: 1.1rem; color: var(--accent); }
.ms small { color: var(--muted); }
.meal { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.meal-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.meal-head span { color: var(--muted); font-size: .82rem; }
.meal-items { margin: 8px 0 4px; padding-left: 18px; }
.meal-steps { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }

/* History lists */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist li span { color: var(--muted); font-size: .82rem; width: 56px; }
.hist li small { color: var(--muted); margin-left: auto; font-size: .8rem; }

/* Forms */
.weight-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
input, select { width: 100%; margin-top: 5px; background: var(--bg2); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: .95rem; }
input[type="range"] { padding: 0; }
input[type="checkbox"] { width: auto; margin: 0 6px 0 0; }
.check { display: flex; align-items: center; color: var(--txt); }
.footer { text-align: center; color: var(--muted); font-size: .76rem; margin: 18px 0 4px; }

/* Onboarding */
.onb { padding: 20px 16px 40px; max-width: var(--maxw); margin: 0 auto; }
.onb-head h1 { font-size: 2rem; margin: 0 0 4px; }
.onb-head p { color: var(--muted); margin: 0 0 18px; }
.onb-form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; background: var(--card); }
.onb-form legend { padding: 0 8px; color: var(--accent); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.field-label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

/* Toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0b1020; border: 1px solid var(--accent); color: var(--txt); padding: 10px 16px; border-radius: 999px; opacity: 0; transition: all .25s ease; z-index: 50; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Gráfica de evolución ===== */
.chart-svg { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-ylab, .ch-xlab { fill: var(--muted); font-size: 9px; }
.ch-last { font-size: 10px; font-weight: 700; }
.chart-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.ch-leg { display: inline-flex; align-items: center; gap: 5px; }
.ch-leg i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* ===== Comparativa de fotos ===== */
.photo-compare { margin-top: 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cmp-selectors { display: flex; gap: 12px; }
.cmp-selectors label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); }
.cmp-selectors select { width: 100%; }
.cmp-delta { text-align: center; color: var(--accent); font-weight: 600; margin: 10px 0 4px; }
.cmp-row { display: grid; grid-template-columns: 22px 1fr 1fr; gap: 8px; align-items: center; margin-top: 10px; }
.cmp-pose { writing-mode: vertical-rl; transform: rotate(180deg); font-size: .7rem; color: var(--muted); text-align: center; }
.cmp-cell { display: flex; flex-direction: column; gap: 4px; }
.cmp-cell img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.cmp-cell span { font-size: .7rem; color: var(--muted); text-align: center; }
.cmp-empty { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: .7rem; }

/* ===== Perfiles ===== */
.profile-chip { background: var(--card2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: .85rem; font-weight: 600; cursor: pointer; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip:active { transform: scale(.97); }
.profile-list { display: grid; gap: 8px; margin-bottom: 10px; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.profile-row.active { border-color: var(--accent); }
.profile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-name em { color: var(--accent); font-style: normal; font-weight: 500; font-size: .8rem; }
.profile-acts { display: flex; gap: 6px; flex-shrink: 0; }

/* Pantalla "¿Quién entrena?" */
.picker { padding: 24px 16px; max-width: 520px; margin: 0 auto; }
.picker-head { text-align: center; margin: 12px 0 22px; }
.picker-head h1 { margin: 0 0 6px; }
.picker-head p { color: var(--muted); margin: 0; }
.profile-picks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.profile-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; color: var(--text); cursor: pointer; }
.profile-pick.active { border-color: var(--accent); }
.profile-pick.create { border-style: dashed; color: var(--muted); }
.profile-pick:active { transform: scale(.98); }
.pp-emoji { font-size: 2rem; line-height: 1; }
.pp-name { font-weight: 600; }

/* Barra de perfil sobre el onboarding */
.onb-profilebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--card2); border-bottom: 1px solid var(--line); }
.obp-who { font-size: .9rem; color: var(--muted); }

.focus-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(52,211,153,.12); border: 1px solid var(--accent); color: var(--accent); border-radius: 10px; padding: 8px 12px; font-size: .9rem; margin-bottom: 12px; }
.focus-banner .btn { margin-left: auto; }

/* ===== Progreso visual (fotos) ===== */
.due-banner { background: rgba(56, 189, 248, .12); border: 1px solid var(--hi); color: var(--hi); border-radius: 10px; padding: 8px 12px; font-size: .88rem; margin: 8px 0; }
.photo-form { margin-top: 10px; }
.pose-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pose-input { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; color: var(--muted); }
.pose-input input[type=file] { font-size: .72rem; }
.pose-prev { min-height: 60px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .72rem; overflow: hidden; }
.pose-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-list { margin-top: 12px; display: grid; gap: 12px; }
.checkin { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.checkin-head { display: flex; align-items: center; justify-content: space-between; }
.checkin-actions { display: flex; gap: 6px; }
.btn.small { padding: 5px 9px; font-size: .8rem; border-radius: 9px; }
.pthumbs { display: flex; gap: 8px; margin: 10px 0; }
.pthumb { width: 72px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.analysis { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: .9rem; }
.analysis .focus ul { margin: 4px 0 0; padding-left: 18px; }
.analysis .enc { color: var(--accent); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.lightbox-inner { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 44vw; max-height: 82vh; border-radius: 10px; }
.lightbox figcaption { color: var(--muted); font-size: .8rem; margin-top: 6px; }
@media (max-width: 560px) { .lightbox img { max-width: 86vw; max-height: 70vh; } }

/* ===== Sesión en vivo ===== */
.session-view { min-height: 100vh; }
.sess { display: flex; flex-direction: column; min-height: 100vh; padding: 14px; }
.sess-top { display: flex; align-items: center; justify-content: space-between; }
.sess-meta { text-align: right; }
.sess-focus { font-weight: 700; }
.sess-total { color: var(--muted); font-size: .85rem; }
.sess-total b { color: var(--hi); }
.sess-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.sess-stage[data-kind="water"] { color: var(--hi); }
.sess-stage[data-kind="rest"] { color: var(--muted); }
.sess-anim { width: min(60vw, 240px); height: min(60vw, 240px); }
.exfig { width: 100%; height: 100%; color: var(--fig); }
.sess-icon { font-size: 7rem; }
.sess-name { font-size: 1.5rem; font-weight: 800; }
.sess-cue { color: var(--muted); max-width: 320px; }
.sess-round { color: var(--accent); font-size: .9rem; }
.sess-next { color: var(--muted); font-size: .85rem; }

.ring-wrap { position: relative; width: 180px; height: 180px; }
.ring { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.sess-stage[data-kind="rest"] .ring-fg { stroke: var(--muted); }
.sess-stage[data-kind="water"] .ring-fg { stroke: var(--hi); }
.ring-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; font-weight: 800; }

.sess-controls { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0 8px; }
.sess-progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sess-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }

.sess-done { text-align: center; }
.sess-done-emoji { font-size: 4rem; }

/* Desktop tweaks */
@media (min-width: 720px) {
  .sess-anim { width: 260px; height: 260px; }
  .sess-name { font-size: 1.8rem; }
}
@media (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}
