:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eff1f5;
  --text: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --accent-2: #9333ea;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --on-accent: #ffffff;
  --good: #1a8a5e;
  --good-soft: rgba(26, 138, 94, 0.12);
  --warn: #b26a00;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 16, 30, 0.04), 0 4px 16px rgba(20, 16, 30, 0.06);
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f14;
    --surface: #171922;
    --surface-2: #20232e;
    --text: #f2f4f7;
    --muted: #98a2b3;
    --line: #2a2e3b;
    --accent: #8b87ff;
    --accent-2: #c084fc;
    --accent-soft: rgba(139, 135, 255, 0.14);
    --on-accent: #0e0f14;
    --good: #3ccf91;
    --good-soft: rgba(60, 207, 145, 0.14);
    --warn: #f0a640;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

h1, h2, h3, h4 { margin: 0 0 6px; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0 0 10px; }
a { color: inherit; text-decoration: none; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.lead { font-size: 18px; color: var(--muted); }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen.center { min-height: 80dvh; justify-content: center; align-items: center; }
.screen.center { text-align: center; }
.screen.center > * { max-width: 420px; width: 100%; }
.screen.center > .spinner { width: 40px; }
.screen.center > .logo, .screen.center > .summary-mark { width: auto; }
.logo { display: block; flex: none; }

/* ── Íconos ── */
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0 0 4px; }
.h-ico { display: flex; align-items: center; gap: 8px; }
.h-ico .ico { color: var(--accent); }
.summary-mark { color: var(--good); }
.summary-mark .ico { width: 64px; height: 64px; stroke-width: 1.5; }

/* ── Botones ── */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 14px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
}
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); }
.icon-btn {
  appearance: none;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 20px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.icon-btn.sm { width: 32px; height: 32px; font-size: 14px; background: transparent; color: var(--muted); }
.icon-btn.sm .ico { width: 16px; height: 16px; }
.link {
  appearance: none; border: 0; background: none; font: inherit; font-weight: 600;
  color: var(--accent); padding: 8px 0; cursor: pointer;
}
.link.muted { color: var(--muted); }

/* ── Tarjetas y bloques ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.left { text-align: left; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.notice {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.notice .ico { color: var(--accent); margin-top: 1px; }
.notice p { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card .tile { background: var(--surface-2); border-color: transparent; }
.tile b { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.accent b { color: var(--accent); }
.tiles-2 { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.tiles-sm { margin: 12px 0; }
.tiles-sm .tile b { font-size: 17px; }

.top { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.top.sticky {
  position: sticky; top: 0; z-index: 5;
  margin: calc(-16px - env(safe-area-inset-top)) -16px 0;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.h-sm { font-size: 19px; margin: 0; }
.top p { margin: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

/* ── Inicio ── */
.hero {
  border-radius: 22px;
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #7c3aed 100%);
}
.hero .big { font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.hero .big:not(:only-child) { margin-bottom: 4px; }
.hero-sub { opacity: 0.9; }
.progress { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.25); margin: 16px 0 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: #fff; border-radius: 99px; }
.hero-foot { display: flex; justify-content: space-between; font-size: 13px; opacity: 0.9; gap: 8px; }

.day-list { display: flex; flex-direction: column; gap: 10px; }
.day-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.08s;
}
.day-card:active { transform: scale(0.98); }
.day-card.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.day-icon .ico { width: 22px; height: 22px; stroke-width: 2.5; }
.day-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.day-body small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-state { font-size: 13px; font-weight: 700; color: var(--accent); flex: none; }
.day-card.done .day-state { color: var(--good); }
.day-card.disabled { opacity: 0.55; box-shadow: none; }
.day-card.disabled:active { transform: none; }

.week-nav {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.week-label { flex: 1; text-align: center; display: flex; flex-direction: column; }
.week-label b { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.week-label small { color: var(--muted); font-size: 13px; }
.week-nav .icon-btn { background: var(--surface); border: 1px solid var(--line); }

.date-card { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.date-card > .ico { color: var(--accent); }
.date-card .grow { display: flex; flex-direction: column; }
.date-card small { font-size: 12px; }
.date-card input { width: auto; min-height: 40px; padding: 8px 10px; font-size: 15px; }
.danger { color: #d92d20; }
.history-link { flex: 1; min-width: 0; }
.day-card.done .day-icon { background: var(--good-soft); color: var(--good); }

/* ── Formularios ── */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; }
input, select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; min-height: 0; }
.seg span {
  display: block; text-align: center; padding: 10px 6px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
@media (prefers-color-scheme: dark) { .seg input:checked + span { background: var(--line); } }

.stepper-dots { display: flex; gap: 6px; }
.stepper-dots i { height: 4px; flex: 1; border-radius: 4px; background: var(--line); }
.stepper-dots i.on { background: var(--accent); }
.steps-list { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }

/* ── Login ── */
.login { min-height: 100dvh; justify-content: center; gap: 28px; }
.login-hero h1 { font-size: 40px; margin-top: 12px; }
.login-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.login-points li { display: flex; gap: 14px; align-items: flex-start; }
.login-points li > span {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; flex: none;
}
.login-points div { display: flex; flex-direction: column; }
.login-points small { color: var(--muted); font-size: 14px; }
.login .btn-primary { background: var(--text); color: var(--bg); }

/* ── Entrenamiento ── */
.workout { padding-bottom: 180px; }
.warmup summary, .tip summary, .table-view summary { cursor: pointer; font-weight: 600; }
.warmup p { margin: 8px 0 0; color: var(--muted); }
.warmup summary .ico { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; color: var(--accent); }
.ex-card { display: flex; flex-direction: column; gap: 8px; }
.ex-head { display: flex; gap: 10px; align-items: flex-start; }
.ex-head h3 { margin: 0; }
.ss {
  background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 13px;
  border-radius: 8px; padding: 4px 7px; flex: none; margin-top: 2px;
}
.ex-rx { font-size: 14px; }
.ex-sug { font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); display: flex; gap: 8px; align-items: flex-start; }
.ex-sug .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--muted); }
.ex-sug.trend-up .ico { color: var(--good); }
.ex-sug.trend-down .ico { color: var(--warn); }
.ex-sug.trend-start .ico { color: var(--accent); }
.ex-sug.trend-up { background: var(--good-soft); }
.trend-up { color: var(--good); }
.ex-sug.trend-up { color: var(--text); }
.ex-last { font-size: 13px; color: var(--muted); }
.tip { font-size: 14px; }
.tip summary { color: var(--muted); font-size: 13px; }
.tip p { margin: 6px 0 0; color: var(--muted); }

.sets { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.set-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 48px;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-2);
  transition: background 0.15s;
}
.set-row.done { background: var(--good-soft); }
.set-n { font-weight: 700; color: var(--muted); text-align: center; font-size: 14px; }
.num { display: flex; align-items: center; gap: 2px; min-width: 0; }
.num button {
  appearance: none; border: 0; background: var(--surface); color: var(--text);
  width: 34px; height: 40px; border-radius: 10px; font-size: 20px; font-weight: 600;
  cursor: pointer; flex: none; touch-action: manipulation;
}
.num button:active { background: var(--line); }
.num label { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.num input {
  padding: 0; min-height: 26px; background: transparent; border: 0; text-align: center;
  font-size: 18px; font-weight: 700; -moz-appearance: textfield;
}
.num input::-webkit-outer-spin-button, .num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num small { font-size: 11px; color: var(--muted); line-height: 1; }
.check {
  appearance: none; border: 2px solid var(--line); background: var(--surface); color: var(--line);
  width: 48px; height: 48px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; touch-action: manipulation;
}
.check .ico { width: 24px; height: 24px; stroke-width: 2.75; }
.set-row.done .check { background: var(--good); border-color: var(--good); color: #fff; }
.ex-actions { display: flex; justify-content: space-between; }

.finish-bar, .rest-bar {
  position: fixed; left: 0; right: 0; z-index: 10;
  max-width: 560px; margin: 0 auto;
}
.finish-bar {
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.rest-bar {
  bottom: calc(80px + env(safe-area-inset-bottom));
  margin: 0 16px;
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg);
  padding: 10px 12px 10px 16px; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
@media (min-width: 592px) { .rest-bar { margin: 0 auto; } }
.rest-bar b { font-size: 24px; font-variant-numeric: tabular-nums; flex: 1; }
.rest-bar .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.rest-bar[hidden] { display: none; }

.summary .tiles { width: 100%; }

/* ── Progreso ── */
.select { margin-bottom: 4px; }
.chart-title { font-size: 14px; font-weight: 600; margin: 14px 0 6px; color: var(--muted); }
.chart { position: relative; height: 200px; }
.table-view { margin-top: 12px; font-size: 14px; }
.table-view summary { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.inline-form { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 8px; margin-top: 12px; }
.inline-form input { padding: 10px; }
.plain-list { list-style: none; padding: 0; margin: 8px 0 0; }
.plain-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li > span { flex: 1; min-width: 0; }

/* ── Navegación inferior ── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav[hidden] { display: none; }
.nav a {
  flex: 1; max-width: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav a.active { color: var(--accent); }

/* ── Misc ── */
.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); z-index: 50;
  transform: translate(-50%, calc(-100% - 40px));
  opacity: 0;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center;
  transition: transform 0.25s ease, opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
