/* Sistema de diseño de RunnerPlanner, portado de globals.css de la landing (runnerplanner.com).
   Si cambias un token aquí, cámbialo también allí. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Las variantes de texto (#156b3a, #84500f, #a61f1f) son los verdes, ámbar y rojos de la marca oscurecidos para AA. */
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --text: #0f1729;
  --muted: #5d6578;
  --faint: #9aa3b5;
  --border: #e6e9f0;
  --blue: #1e4fd8;
  --blue-2: #2f6bf2;
  --cyan: #12b5e5;
  --gradient: linear-gradient(120deg, #1e4fd8 0%, #2f80ed 55%, #19c2f0 100%);
  --green-bg: #e7f8ee;
  --green: #1f9d55;
  --red-bg: #fdecec;
  --red: #d64545;
  --amber-bg: #fff4e0;
  --amber: #b7741a;
  --blue-bg: #e6eefe;
  --radius: 22px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
a { color: var(--blue); }
code { font-size: 0.9em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue-2) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.page { flex: 1; display: grid; gap: 18px; align-content: start; padding-top: 16px; padding-bottom: 40px; }

/* Cabecera */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.6rem; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.pill-tag { background: var(--surface); border-radius: 999px; padding: 10px 16px; font-size: 0.88rem; font-weight: 500; white-space: nowrap; }
@media (max-width: 480px) {
  .brand { font-size: 1.2rem; gap: 8px; }
  .brand svg { width: 28px; height: 28px; }
}

/* Tarjetas */
.panel { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgb(15 23 41 / 0.03); min-width: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 36px 32px; justify-items: start; }
.hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800; max-width: 22em; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 46em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
@media (max-width: 480px) {
  .hero { padding: 26px 20px; }
  .actions { width: 100%; }
  .actions > a { flex: 1 1 100%; white-space: normal; text-align: center; }
  .pill-tag { padding: 8px 12px; font-size: 0.8rem; }
}

.eyebrow { display: inline-block; background: var(--blue-bg); color: var(--blue); border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 600; }
.eyebrow.danger { background: var(--red-bg); color: #a61f1f; }

.badge { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: #156b3a; }
.badge.red { background: var(--red-bg); color: #a61f1f; }
.badge.amber { background: var(--amber-bg); color: #84500f; }
.badge.blue { background: var(--blue-bg); color: var(--blue); }

/* Botones (micro-animación: elevación al pasar el ratón y pulsación al hacer clic) */
.btn-gradient, .btn-primary, .btn-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 0; border-radius: 999px; font: inherit; font-weight: 600; font-size: 0.92rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), filter 0.15s ease;
}
.btn-gradient { background: var(--gradient); color: #fff; padding: 11px 20px; box-shadow: 0 6px 16px rgb(30 79 216 / 0.28); }
.btn-primary { background: linear-gradient(120deg, #1e4fd8, #2f6bf2); color: #fff; padding: 11px 20px; }
.btn-light { background: var(--surface-2); color: var(--text); padding: 11px 22px; }
.btn-gradient:hover, .btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 10px 22px rgb(30 79 216 / 0.32); }
.btn-light:hover { transform: translateY(-1px); }
.btn-gradient:active, .btn-primary:active, .btn-light:active { transform: scale(0.98); }

/* Pasos */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; } }
.steps li { counter-increment: step; background: var(--surface); border-radius: var(--radius); padding: 20px; font-size: 0.92rem; color: var(--muted); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--gradient); color: #fff; font-weight: 700; margin-bottom: 10px; }
.steps strong { display: block; color: var(--text); margin-bottom: 4px; }

/* Pie */
.footer { padding: 28px 0 36px; font-size: 0.88rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* Skeleton: replica el layout real mientras cargan los datos (sin saltos de maquetación) */
.skeleton {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 0%, #e9edf5 40%, var(--surface-2) 80%);
  background-size: 300% 100%;
  animation: rp-shimmer 1.4s ease-in-out infinite;
}
@keyframes rp-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Entrada suave y escalonada: style="--i: 2" retrasa cada elemento */
.fade-up { animation: rp-fade-up 0.5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rp-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton { animation: none; background: var(--surface-2); }
}

/* Cabecera con sesión */
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu form { margin: 0; }
.user-menu .pill-tag { text-decoration: none; color: var(--text); transition: background 0.15s ease; }
.user-menu .pill-tag:hover { background: var(--surface-2); }
@media (max-width: 560px) { .user-menu .pill-name { display: none; } }
.feedback-link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.feedback-link svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
@media (max-width: 900px) { .feedback-link { padding: 10px 12px; } .feedback-link .feedback-text { display: none; } }
.feedback-card { display: grid; gap: 4px; border: 1px solid var(--blue-bg); }
.segmented.rating label > span { min-width: 48px; text-align: center; }
@media (max-width: 420px) { .brand span { display: none; } }

/* Navegación principal: píldora con pestañas, como la barra de la landing (§8.3) */
.main-nav { display: flex; gap: 4px; padding: 5px; background: var(--surface); border-radius: 999px; }
.main-nav .tab { padding: 9px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; color: var(--muted); text-decoration: none; transition: background 0.15s ease, color 0.15s ease; }
.main-nav .tab:hover { color: var(--text); background: var(--surface-2); }
.main-nav .tab.active { color: #fff; background: var(--gradient); }

/* En el móvil las pestañas van abajo, al alcance del pulgar */
.bottom-nav { display: none; }
@media (max-width: 720px) {
  .main-nav { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; min-height: 48px; padding: 6px 0; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 14px; }
  .bottom-nav svg { width: 24px; height: 24px; fill: currentColor; }
  .bottom-nav a.active { color: var(--blue); background: var(--blue-bg); }
  body:has(.bottom-nav) .footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Saltar al contenido (teclado y lectores de pantalla) */
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 999px; background: var(--text); color: #fff; font-weight: 600; text-decoration: none; transition: top 0.15s ease; }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }

/* Transición suave entre páginas donde el navegador la admite (§9.2); se apaga con prefers-reduced-motion */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* Zona de peligro (borrar la cuenta) */
.danger-zone { border: 1px solid var(--red-bg); }

/* Cabecera de página */
.page-head { padding: 8px 0 4px; }
.page-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; }
.page-sub { color: var(--muted); margin-top: 6px; }
.panel h2 { font-size: 1.15rem; margin-bottom: 4px; }
.panel-sub { color: var(--muted); font-size: 0.9rem; margin: 4px 0 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

/* Formularios */
.auth-card { width: 100%; max-width: 460px; margin: 12px auto 0; padding: 32px 30px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; }
@media (max-width: 480px) { .auth-card { padding: 26px 20px; } }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field input {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2);
  border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; min-height: 48px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.field input:hover { background: #eef1f7; }
.field input:focus { outline: none; background: var(--surface); border-color: var(--blue-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-2) 15%, transparent); }
.field input.invalid { border-color: var(--red); }
.field input:disabled { opacity: 0.6; }
.field-help { color: var(--muted); font-size: 0.82rem; }
.field-error, .validation-message { color: #a61f1f; font-size: 0.84rem; font-weight: 500; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; color: var(--muted); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.auth-links { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.form button[type="submit"] { width: 100%; }
.settings-grid .form button[type="submit"] { width: auto; justify-self: start; }

/* Avisos (con entrada suave) */
.alert { margin: 0; padding: 12px 16px; border-radius: 14px; font-size: 0.92rem; animation: rp-fade-up 0.3s var(--ease-out) both; }
/* Textos de aviso un tono más oscuros que los de la marca para llegar a AA (4,5:1) sobre su fondo */
.alert.error { background: var(--red-bg); color: #a61f1f; }
.alert.success { background: var(--green-bg); color: #156b3a; }
ul.alert { padding-left: 32px; }
.alert p + p { margin-top: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; word-break: break-all; color: var(--text); }
.empty { color: var(--muted); padding: 18px 0; }

/* Botones de texto y estado de carga */
.link-button { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--blue); cursor: pointer; }
.link-button.danger { color: #b42323; }
.link-button:disabled { opacity: 0.5; cursor: default; }
.btn-gradient:disabled, .btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }
.spinner { width: 14px; height: 14px; border: 2px solid rgb(255 255 255 / 0.4); border-top-color: #fff; border-radius: 50%; animation: rp-spin 0.7s linear infinite; }
@keyframes rp-spin { to { transform: rotate(360deg); } }

/* Tabla, barra de progreso y skeleton de filas */
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue-2) 55%, transparent); outline-offset: 2px; border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { background: var(--surface-2); text-align: left; font-weight: 500; color: #333b4d; padding: 12px 14px; white-space: nowrap; }
.table th:first-child { border-radius: 12px 0 0 12px; }
.table th:last-child { border-radius: 0 12px 12px 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 14px; justify-content: flex-end; }
.row-in { animation: rp-fade-up 0.35s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; background: var(--gradient); border-radius: 999px; transition: width 0.3s var(--ease-out); }
.skeleton-table { display: grid; gap: 14px; padding: 6px 0; }
.skeleton-row { display: flex; gap: 18px; }
.skeleton-row .skeleton { height: 16px; }

/* Ajustes finos */
.auth-card > .eyebrow, .hero > .eyebrow { justify-self: start; }
.badge + .badge, td .badge { margin-left: 6px; }
input[type="file"] { font: inherit; font-size: 0.88rem; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.88rem; margin-right: 12px; border: 0; border-radius: 999px;
  padding: 10px 18px; background: var(--blue-bg); color: var(--blue); cursor: pointer; transition: filter 0.15s ease;
}
input[type="file"]::file-selector-button:hover { filter: brightness(0.97); }

/* ---------- Fase 2: perfil del corredor ---------- */

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-stack { display: grid; gap: 18px; }

/* Más tipos de campo con el mismo aspecto que los inputs */
.field select, .field textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2);
  border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; min-height: 48px; width: 100%;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.field textarea { resize: vertical; min-height: 72px; }
.field select:hover, .field textarea:hover { background: #eef1f7; }
.field select:focus, .field textarea:focus { outline: none; background: var(--surface); border-color: var(--blue-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-2) 15%, transparent); }
.field select.invalid, .field textarea.invalid { border-color: var(--red); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form .form-actions button[type="submit"] { width: auto; min-width: 160px; }
@media (max-width: 480px) { .form .form-actions > * { flex: 1 1 100%; } }
.panel h3 { font-size: 1rem; margin: 0 0 4px; }

/* Opciones en píldora (sexo) y en tarjeta (nivel) */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label, .day-pill { position: relative; cursor: pointer; }
.segmented input, .choice input, .day-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--surface-2);
  font-size: 0.9rem; font-weight: 500; transition: background 0.15s ease, color 0.15s ease;
}
.segmented label:hover span { background: #eef1f7; }
.segmented input:checked + span { background: var(--blue-bg); color: var(--blue); font-weight: 600; }
.segmented input:focus-visible + span, .choice input:focus-visible + span, .day-pill input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--blue-2) 55%, transparent); outline-offset: 2px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .choice-grid { grid-template-columns: 1fr; } }
.choice { position: relative; cursor: pointer; }
.choice > span {
  display: grid; gap: 4px; height: 100%; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 2px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s var(--ease-out);
}
.choice small { color: var(--muted); font-size: 0.84rem; }
.choice:hover > span { transform: translateY(-1px); }
.choice input:checked + span { border-color: var(--blue-2); background: var(--surface); box-shadow: 0 6px 16px rgb(30 79 216 / 0.12); }

/* Días de la semana */
.day-pills { display: grid; grid-template-columns: repeat(7, minmax(0, 48px)); gap: 6px; }
.day-pill span[aria-hidden] {
  display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--surface-2);
  font-weight: 700; color: var(--muted); transition: background 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-out);
}
.day-pill:hover span[aria-hidden] { transform: translateY(-1px); }
.day-pill:active span[aria-hidden] { transform: scale(0.94); }
.day-pill input:checked + span { background: var(--gradient); color: #fff; box-shadow: 0 6px 14px rgb(30 79 216 / 0.25); }

/* Molestias */
.injury-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin-top: 8px; }
@media (max-width: 640px) { .injury-grid { grid-template-columns: 1fr; } }
.injury-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 10px; }
.injury-row label { font-weight: 500; font-size: 0.9rem; }
.injury-row select { font: inherit; font-size: 0.9rem; padding: 8px 10px; min-height: 44px; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); color: var(--text); }
.injury-row select:focus { outline: none; border-color: var(--blue-2); background: var(--surface); }

/* Consentimiento y cuestionario de salud */
.consent, .health { display: grid; gap: 10px; background: var(--surface-2); border-radius: 18px; padding: 18px; }
.consent p { color: var(--muted); font-size: 0.9rem; }
.consent .consent-given { color: #156b3a; font-weight: 600; }
.health legend { float: left; width: 100%; margin-bottom: 0; }
.health legend h3 { margin: 0; }
.check-strong { color: var(--text); font-weight: 500; }

/* Stepper del onboarding: la barra se llena al avanzar y el panel entra deslizándose */
.stepper { position: relative; padding: 4px 0 2px; }
.stepper ol { position: relative; display: grid; grid-template-columns: repeat(var(--steps, 4), 1fr); margin: 0; padding: 0; list-style: none; }
.stepper-bar { position: absolute; left: calc(50% / var(--steps, 4)); right: calc(50% / var(--steps, 4)); top: 23px; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.stepper-bar span { display: block; height: 100%; width: var(--to); background: var(--gradient); border-radius: 999px; animation: rp-fill 0.6s 0.1s var(--ease-out) both; }
@keyframes rp-fill { from { width: var(--from); } to { width: var(--to); } }
.stepper-step { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; font-size: 0.82rem; color: var(--muted); }
.stepper-step a { display: grid; justify-items: center; gap: 6px; color: inherit; text-decoration: none; }
.stepper-dot {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border); font-weight: 700; color: var(--muted);
  transition: transform 0.2s var(--ease-out);
}
.stepper-step.done .stepper-dot { background: var(--blue-bg); border-color: var(--blue-bg); color: var(--blue); }
.stepper-step.done a:hover .stepper-dot { transform: scale(1.06); }
.stepper-step.current { color: var(--text); font-weight: 600; }
.stepper-step.current .stepper-dot { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgb(30 79 216 / 0.3); animation: rp-pop 0.4s var(--ease-out) both; }
.stepper-dot svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; animation: rp-draw 0.4s 0.1s var(--ease-out) both; }
@keyframes rp-draw { from { stroke-dashoffset: 14; } to { stroke-dashoffset: 0; } }
@keyframes rp-pop { from { transform: scale(0.8); } 60% { transform: scale(1.08); } to { transform: none; } }
@media (max-width: 560px) {
  .stepper-label { display: none; }
  .stepper-step.current .stepper-label { display: block; white-space: nowrap; }
}
.step-panel { display: grid; gap: 4px; animation: rp-slide-in 0.45s var(--ease-out) both; }
@keyframes rp-slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.step-panel > .form { margin-top: 10px; }
.vdot-found { margin-bottom: 10px; }

/* Inicio: KPI, ritmos y predicciones */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi { display: grid; gap: 6px; align-content: start; transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out); }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgb(15 23 41 / 0.06); }
.kpi-label { color: var(--muted); font-size: 0.86rem; font-weight: 500; }
.kpi-value { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 1rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.kpi-help { color: var(--muted); font-size: 0.84rem; }
/* Contador que sube hasta el VDOT sin JavaScript (@property + counter) */
@property --int { syntax: "<integer>"; initial-value: 0; inherits: false; }
@property --dec { syntax: "<integer>"; initial-value: 0; inherits: false; }
.count { counter-reset: int var(--int) dec var(--dec); animation: rp-count 1.1s 0.2s var(--ease-out) both; }
.count::after { content: counter(int) "," counter(dec); background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes rp-count { from { --int: 0; --dec: 0; } }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .home-grid { grid-template-columns: 1fr; } }
.pace-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; }
.pace { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pace:last-child { border-bottom: 0; }
.pace-text { display: grid; gap: 2px; min-width: 0; }
.pace-text small { color: var(--muted); font-size: 0.82rem; }
.pace-tag { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; font-weight: 800; }
.pace-tag.e { background: var(--green-bg); color: #156b3a; }
.pace-tag.m { background: var(--blue-bg); color: var(--blue); }
.pace-tag.t { background: var(--amber-bg); color: #84500f; }
.pace-tag.i { background: #fde8f0; color: #c2366b; }
.pace-tag.r { background: var(--red-bg); color: #a61f1f; }
.pace-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pace-value small { display: block; color: var(--muted); font-weight: 500; font-size: 0.78rem; }
@media (max-width: 480px) { .pace { grid-template-columns: 36px minmax(0, 1fr); } .pace-value { grid-column: 2; text-align: left; } .pace-value small { display: inline; margin-left: 2px; } }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table td.muted { color: var(--muted); font-weight: 500; }
.alert.warning { background: var(--amber-bg); color: #84500f; margin-top: 14px; }

/* Ajustes: resumen del perfil */
.summary { display: grid; margin: 0; }
.summary > div { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.summary > div:last-child { border-bottom: 0; }
.summary dt { color: var(--muted); font-weight: 500; }
.summary dd { margin: 0; min-width: 0; }
.summary dd a { font-weight: 600; text-decoration: none; }
@media (max-width: 480px) { .summary > div { grid-template-columns: 1fr auto; } .summary dt { grid-column: 1 / -1; } }
/* El rojo de la marca no llega a AA sobre el gris claro: texto un tono más oscuro */
.btn-light.danger { color: #b42323; }
.form .btn-light.danger { width: auto; justify-self: start; }

/* Skeleton con retraso: si los datos llegan en menos de ~150 ms ni se ve (sin parpadeo) */
.skeleton-delay { animation: rp-appear 0.2s 0.15s both; }
@keyframes rp-appear { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .count, .stepper-bar span, .step-panel, .stepper-dot, .stepper-dot svg, .skeleton-delay { animation: none; }
}

/* ---------- Fase 3: plan de entrenamiento ---------- */
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.plan-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.list-title { font-size: 0.92rem; margin: 14px 0 6px; }
.plain-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--muted); font-size: 0.92rem; }
.plain-list strong { color: var(--text); }
.generate-card .actions { margin-top: 4px; }

/* «Generando tu plan»: stepper con el estado real y un pulso que indica que sigue vivo */
.stepper-bar span { transition: width 0.6s var(--ease-out); }
.generating { display: grid; gap: 18px; }
.generating-status { display: flex; align-items: center; gap: 12px; }
.generating-status p { margin: 0; }
.pulse { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--blue-2); flex: none; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--blue-2); animation: rp-pulse 1.4s ease-out infinite; }
@keyframes rp-pulse { from { transform: scale(1); opacity: 0.6; } to { transform: scale(2.6); opacity: 0; } }

/* Semanas y sesiones */
.weeks { display: grid; gap: 12px; }
.week { padding: 0; overflow: hidden; }
.week > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; cursor: pointer; list-style: none; }
.week > summary::-webkit-details-marker { display: none; }
.week > summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(45deg); transition: transform 0.2s var(--ease-out); flex: none; }
.week[open] > summary::after { transform: rotate(225deg); }
.week.current { box-shadow: 0 0 0 2px var(--blue-bg), 0 8px 24px rgb(30 79 216 / 0.08); }
.week > .panel-sub, .week > .sessions { margin-left: 22px; margin-right: 22px; }
.week > .sessions { margin-bottom: 16px; }
.week-title { display: grid; gap: 2px; }
.week-meta { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.week-km { font-weight: 700; white-space: nowrap; }
.sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.session { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--surface-2); transition: transform 0.15s var(--ease-out), background 0.15s ease; }
.session:hover { transform: translateY(-1px); }
.session.today { box-shadow: inset 0 0 0 2px var(--blue-2); }
.session.done { background: var(--green-bg); }
.session.skipped { opacity: 0.6; }
.session-date { display: grid; justify-items: center; line-height: 1.1; font-size: 0.75rem; color: var(--muted); text-transform: capitalize; }
.session-date strong { font-size: 1.15rem; color: var(--text); }
.session-main { display: grid; gap: 2px; min-width: 0; color: var(--text); text-decoration: none; }
.session-type { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.session-detail { color: var(--muted); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--green); }
.kind.long { background: var(--blue); }
.kind.quality { background: var(--amber); }
.kind.recovery { background: var(--faint); }
.kind.race { background: var(--red); }
.session-actions { display: flex; align-items: center; gap: 6px; }
.session-actions form { margin: 0; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--surface); color: var(--muted); cursor: pointer; transition: transform 0.15s var(--ease-out), background 0.15s ease, color 0.15s ease; }
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.ok:hover { background: var(--green-bg); color: #156b3a; }
.icon-btn svg, .drawn-check { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.session-state { display: inline-flex; align-items: center; gap: 4px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.session-state.ok { color: #156b3a; }
.drawn-check { stroke-dasharray: 14; animation: rp-draw 0.45s 0.1s var(--ease-out) both; }
@media (max-width: 560px) {
  .session { grid-template-columns: 40px minmax(0, 1fr); }
  .session-actions { grid-column: 2; }
  .week > summary { padding: 16px; }
  .week > .panel-sub, .week > .sessions { margin-left: 12px; margin-right: 12px; }
}

/* Inicio: la semana en curso de un vistazo */
.week-strip { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-strip li { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; background: var(--surface-2); font-size: 0.82rem; text-align: center; }
.week-strip li a { font-weight: 700; text-decoration: none; }
.week-strip li.today { box-shadow: inset 0 0 0 2px var(--blue-2); }
.week-strip li.done { background: var(--green-bg); }
.week-strip li.done a { color: #156b3a; }
.week-strip li.skipped { opacity: 0.55; }
.week-strip .day { font-weight: 600; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .pulse::after, .drawn-check, .row-in { animation: none; }
  .session, .icon-btn, .stepper-bar span { transition: none; }
}
.generate-card .form button[type="submit"] { width: auto; }

/* Filtros del plan por tipo de sesión */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.88rem; font-weight: 600; text-decoration: none; transition: background 0.15s ease, transform 0.15s var(--ease-out); }
.chip:hover { background: var(--surface-2); transform: translateY(-1px); }
.chip.active { background: var(--gradient); color: #fff; }

/* Fase 6: panel de métricas (embudo y comentarios) */
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.funnel li { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); gap: 4px 14px; align-items: center; font-size: 0.92rem; }
.funnel-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.funnel-bar span { display: block; height: 100%; min-width: 4px; background: var(--gradient); border-radius: 999px; }
.funnel-value { grid-column: 2; font-variant-numeric: tabular-nums; }
.funnel-value small { color: var(--muted); }
@media (max-width: 480px) { .funnel li { grid-template-columns: 1fr; } .funnel-value { grid-column: 1; } }
.feedback-list { list-style: none; margin: 0; padding: 0; display: grid; }
.feedback-list li { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.feedback-list li:last-child { border-bottom: 0; }
.feedback-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: 0.84rem; }
.feedback-meta > * { min-width: 0; overflow-wrap: anywhere; }
.feedback-meta .badge + span { margin-left: 0; }
.feedback-text-body { white-space: pre-line; overflow-wrap: anywhere; }

/* Dispositivos (relojes): actividades por confirmar en Inicio y estado en Ajustes. */
.pending-activity { padding: 12px 0; border-top: 1px solid var(--border); }
.pending-activity p { margin: 0 0 8px; }
.pending-activity .actions { align-items: center; margin-top: 0; }
.pending-activity form { margin: 0; }
.summary dd .alert { display: block; margin-top: 6px; }
.summary dd .badge + span { margin-left: 8px; }
