/* gamba di legno · app del club. Oscuro por defecto (tipo WHOOP/Oura), versión clara crema según el sistema. */

@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/spacegrotesk-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #161d1b;
  --bg-top: #26302d;
  --card: rgba(255, 255, 255, 0.045);
  --card-solid: #1f2725;
  --line: rgba(243, 235, 226, 0.09);
  --fg: #f3ebe2;
  --muted: #98a39e;
  --track: rgba(243, 235, 226, 0.1);
  --good: #4cc28c;
  --warn: #e8b84a;
  --bad: #ec6a55;
  --info: #8fb3d9;
  --strain: #e67a44;
  --sleep: #a3bde6;
  --c-bike: #e67a44;
  --c-run: #d8e3a8;
  --c-swim: #8fb3d9;
  --c-other: #6f7c77;
  --band: rgba(76, 194, 140, 0.14);
  --z-fresh: rgba(143, 179, 217, 0.12);
  --z-neutral: rgba(243, 235, 226, 0.03);
  --z-build: rgba(76, 194, 140, 0.12);
  --z-risk: rgba(236, 106, 85, 0.16);
  --radius: 18px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3ebe2;
    --bg-top: #eae1d6;
    --card: #fbf7f1;
    --card-solid: #fbf7f1;
    --line: rgba(58, 72, 67, 0.12);
    --fg: #26302d;
    --muted: #6b7873;
    --track: rgba(58, 72, 67, 0.1);
    --good: #2f8f5f;
    --warn: #c18a14;
    --bad: #c8473a;
    --info: #4f79b5;
    --sleep: #5b82c0;
    --c-run: #9bb04a;
    --c-swim: #5b82c0;
    --c-other: #a7b0ac;
    --band: rgba(47, 143, 95, 0.13);
    --z-fresh: rgba(79, 121, 181, 0.1);
    --z-neutral: rgba(58, 72, 67, 0.03);
    --z-build: rgba(47, 143, 95, 0.1);
    --z-risk: rgba(200, 71, 58, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--fg);
  background: linear-gradient(180deg, var(--bg-top) 0, var(--bg) 420px) no-repeat, var(--bg);
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
@media (min-width: 760px) { body { padding-bottom: 40px; } }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--strain); outline-offset: 3px; border-radius: 8px; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px; }

/* Cabecera */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 4px; padding-top: calc(14px + env(safe-area-inset-top)); }
.wordmark { display: block; width: 92px; aspect-ratio: 210.97 / 84.47; background: var(--fg); -webkit-mask: url("/img/wordmark.svg") left center / contain no-repeat; mask: url("/img/wordmark.svg") left center / contain no-repeat; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.avatar[aria-current="page"] { border-color: var(--strain); color: var(--strain); }

/* Navegación */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav ul { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 520px; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; letter-spacing: 0.02em; color: var(--muted); }
.nav a[aria-current="page"] { color: var(--fg); }
.nav a[aria-current="page"] svg { color: var(--strain); }
.nav svg { width: 22px; height: 22px; }
@media (min-width: 760px) {
  .nav { position: static; background: none; border: 0; backdrop-filter: none; }
  .nav ul { max-width: 680px; display: flex; gap: 4px; padding: 6px 16px 0; }
  .nav a { flex-direction: row; font-size: 14px; padding: 7px 13px; border-radius: 999px; gap: 7px; }
  .nav a[aria-current="page"] { background: var(--card); }
  .nav svg { width: 17px; height: 17px; }
}

main { padding: 10px 0 28px; display: flex; flex-direction: column; gap: 14px; }

/* Tipografía */
.eyebrow, .lbl, .kpi-l, .sec, .stat-l { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.big { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.big-s { font-size: 28px; font-weight: 600; display: flex; align-items: center; gap: 10px; margin: 2px 0 4px; }
.c-bad { color: var(--bad); }
.c-warn { color: var(--warn); }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sec span, .sec a { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.sec a { text-decoration: underline; text-underline-offset: 3px; }

/* Hero de hoy */
.hero { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 6px; }
.hero-center { align-items: center; text-align: center; padding: 8px 0; }
.hero-split { flex-direction: row; justify-content: space-between; align-items: center; }
.rings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px 0 4px; }
.kpi { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ring-v { fill: var(--fg); font-family: var(--font); font-weight: 600; }
.say { font-size: 25px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.say.tone-good { color: var(--good); }
.say.tone-warn { color: var(--warn); }
.say.tone-bad { color: var(--bad); }
.why { color: var(--muted); font-size: 15.5px; }
.target { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.target-h { display: flex; justify-content: space-between; align-items: baseline; }
.target-h b { font-size: 20px; color: var(--strain); }

/* Medidor de esfuerzo */
.gauge-track { position: relative; height: 10px; border-radius: 999px; background: var(--track); }
.gauge-band { position: absolute; top: -4px; bottom: -4px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 10%, transparent); border: 1.5px solid var(--fg); opacity: 0.75; }
.gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--strain); }
.gauge-mark { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--fg); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }

/* Insights */
.ins-list { display: flex; flex-direction: column; gap: 8px; }
.ins { display: grid; grid-template-columns: 10px 1fr; gap: 12px; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; }
.ins h3 { font-size: 15px; font-weight: 600; }
.ins p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.ins-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--info); }
.ins.tone-good .ins-dot { background: var(--good); }
.ins.tone-warn .ins-dot { background: var(--warn); }
.ins.tone-bad .ins-dot { background: var(--bad); }
.ins.tone-bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

/* Estadísticas clave */
.stat { display: grid; grid-template-columns: 1fr auto 74px; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.stat:first-of-type { border-top: 0; padding-top: 2px; }
.stat-l { font-size: 11px; }
.stat-v { font-size: 17px; font-weight: 600; }
.delta { font-size: 12.5px; font-weight: 600; text-align: right; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

/* Factores */
.contrib { padding: 9px 0; border-top: 1px solid var(--line); }
.contrib:first-of-type { border-top: 0; padding-top: 0; }
.contrib-h { display: flex; justify-content: space-between; font-size: 14.5px; }
.contrib-b { display: grid; grid-template-columns: 1fr 76px; gap: 12px; align-items: center; margin-top: 6px; }
.contrib-v { text-align: right; font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--fg); opacity: 0.85; }
.bar span.warn { background: var(--warn); opacity: 1; }
.st { font-size: 12.5px; font-weight: 600; }
.st-good { color: var(--good); }
.st-info { color: var(--fg); }
.st-warn { color: var(--warn); }
.st-bad { color: var(--bad); }
.st-none { color: var(--muted); }

/* Teselas */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile b { font-size: 21px; font-weight: 600; }
.tile .lbl { font-size: 10.5px; }
@media (max-width: 380px) { .tile b { font-size: 18px; } }

/* Selector de periodo */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg a { padding: 5px 11px; border-radius: 999px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.seg a[aria-current="page"] { background: var(--fg); color: var(--bg); }

/* Gráficos */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11.5px; fill: var(--muted); }
.chart text.strong { fill: var(--fg); font-weight: 600; }
.chart text.zone-l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.chart .grid { stroke: var(--line); }
.chart .band { fill: var(--band); }
.chart .refline { stroke: var(--fg); stroke-dasharray: 4 4; opacity: 0.5; }
.chart .cursor { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; pointer-events: none; }
.chart .cursor-dot { stroke: var(--bg); stroke-width: 2; pointer-events: none; }
svg[data-chart] { touch-action: pan-y; cursor: crosshair; }
.tip { position: absolute; z-index: 20; pointer-events: none; background: var(--card-solid); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 13px; line-height: 1.4; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); max-width: 260px; display: flex; flex-direction: column; gap: 2px; }
.tip[hidden] { display: none; }
.tip em { font-style: normal; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.tip b { font-weight: 600; }
[data-tip] { cursor: pointer; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.spark { width: 120px; height: 36px; flex: none; }
.split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; }
.split span { display: block; height: 100%; }
.ef { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Ratio de carga */
.ratio b { font-size: 26px; font-weight: 600; display: block; margin-bottom: 8px; }
.ratio-bar { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--info) 0 25%, var(--good) 25% 56.25%, var(--warn) 56.25% 68.75%, var(--bad) 68.75%); opacity: 0.9; }
.ratio-mark { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--fg); box-shadow: 0 0 0 2px var(--bg); }
.ratio-scale { position: relative; height: 16px; margin-top: 5px; font-size: 11px; color: var(--muted); }
.ratio-scale span { position: absolute; transform: translateX(-50%); }
.ratio-scale span:first-child { transform: none; }
.ratio-scale span:last-child { transform: translateX(-100%); }

/* Calendario */
.cal-h, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-h span { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.cal-d { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 11.5px; background: var(--track); color: var(--muted); }
.cal-d.l1 { background: color-mix(in srgb, var(--strain) 25%, transparent); color: var(--fg); }
.cal-d.l2 { background: color-mix(in srgb, var(--strain) 50%, transparent); color: var(--fg); }
.cal-d.l3 { background: color-mix(in srgb, var(--strain) 75%, transparent); color: #fff; }
.cal-d.l4 { background: var(--strain); color: #fff; }
.cal-d.today { outline: 2px solid var(--fg); outline-offset: 1px; }
.cal-d.future { opacity: 0.3; }

/* Sesiones */
.act { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.card > .act:first-of-type, .sec + .act { border-top: 0; }
.act-i { width: 38px; height: 38px; border-radius: 11px; background: var(--track); display: grid; place-items: center; color: var(--fg); }
.sport-i { width: 21px; height: 21px; }
.act-m { min-width: 0; }
.act-t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-d { font-size: 13px; color: var(--muted); }
.act-v { text-align: right; display: flex; flex-direction: column; }
.act-v b { font-size: 17px; color: var(--strain); }
.act-v span { font-size: 11.5px; color: var(--muted); }
.act.done { opacity: 0.6; }
.act-i.race { background: color-mix(in srgb, var(--strain) 30%, transparent); color: var(--strain); }
.race-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--strain); margin-right: 6px; }
.c-muted { color: var(--muted); }
.comp.good { color: var(--good); }
.comp.warn { color: var(--warn); }
.comp.bad { color: var(--bad); }
.plan-v { margin-top: 8px; }
.pre { white-space: pre-wrap; margin-top: 6px; }
details.act-d-wrap { border-top: 1px solid var(--line); }
details.act-d-wrap:first-child { border-top: 0; }
details.act-d-wrap .act { border-top: 0; }
details.act-d-wrap summary { list-style: none; cursor: pointer; }
details.act-d-wrap summary::-webkit-details-marker { display: none; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; margin: 0 0 12px 50px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* Formularios, botones, avisos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 600; cursor: pointer; background: var(--fg); color: var(--bg); font-size: 15px; }
.btn.orange { background: var(--strain); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); }
.btn.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.btn.full { width: 100%; }
input[type="text"], input[type="password"] { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-solid); font-size: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
form .field { margin-bottom: 14px; }
.alert { border-radius: 14px; padding: 13px 15px; background: color-mix(in srgb, var(--bad) 18%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); font-size: 15px; }
.note { border-radius: 14px; padding: 13px 15px; background: color-mix(in srgb, var(--good) 16%, transparent); font-size: 15px; }
.card h2:not(.sec) { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.card p + p { margin-top: 6px; }
.title { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.lead { font-size: 17px; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.steps li::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--track); font-weight: 600; font-size: 14px; }
.steps li.done::before { content: "✓"; background: var(--good); color: #fff; }
.steps b { display: block; }
.steps a { text-decoration: underline; }

details.more summary { cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; padding: 6px 0; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " ›"; }
details.more[open] summary::after { content: " ⌄"; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .t { font-weight: 600; }
.row .d { font-size: 13px; color: var(--muted); }
code { font-size: 13px; background: var(--track); padding: 1px 5px; border-radius: 5px; }

/* Portada pública */
.hero-public { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 32px 0; }
.hero .logo, .hero-public .logo { width: 170px; aspect-ratio: 191.97 / 123.26; background: var(--fg); -webkit-mask: url("/img/logo-club.svg") left center / contain no-repeat; mask: url("/img/logo-club.svg") left center / contain no-repeat; }
.foot { text-align: center; font-size: 12.5px; color: var(--muted); padding: 18px 0; }
.foot a { color: var(--muted); text-decoration: underline; }
.prose p, .prose ul { margin-bottom: 12px; color: var(--fg); }
.prose h2 { font-size: 18px; margin: 18px 0 8px; }
.prose ul { padding-left: 20px; }
.prose a { text-decoration: underline; }
