:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1b1f24; --muted: #667085;
  --border: #e3e6ea; --accent: #2a78d6; --warn: #b54708;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --surface: #1a1e24; --text: #e6e8eb; --muted: #98a2b3; --border: #2a3038; --accent: #5b9cf0; --warn: #f79009;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { margin: 0 0 8px; } h2 { font-size: 1.1rem; margin: 32px 0 12px; } h3 { margin: 0 0 8px; font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; } .warn { color: var(--warn); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.card h2 { margin: 0; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
dt { color: var(--muted); font-size: 0.8rem; } dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart { position: relative; height: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
section { overflow-x: auto; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.alert { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid var(--warn); padding: 10px 14px; border-radius: 8px; }
code { background: color-mix(in srgb, var(--muted) 15%, transparent); padding: 1px 5px; border-radius: 4px; }
.chart.tall { height: 420px; }
.chart-title { font-size: 0.95rem; margin: 24px 0 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.hero .stat strong { font-size: 1.6rem; }
h2.period { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); }
.race-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 0.9rem; }
.race { display: flex; flex-direction: column; gap: 2px; }
.race-title { font-size: 1.15rem; }
.race-time { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; }
.splits { margin-top: 2px; }
/* Cor das provas: mesma cor de cada modalidade nos gráficos; multiesporte em roxo */
[data-sport] { --sport: var(--muted); }
[data-sport="Corrida"] { --sport: var(--series-1); }
[data-sport="Natação"] { --sport: var(--series-5); }
[data-sport="Ciclismo"] { --sport: var(--series-3); }
[data-sport="Triatlo"], [data-sport="Aquatlo"], [data-sport="Duatlo"] { --sport: var(--series-7); }
.race { border-left: 4px solid var(--sport); }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sport); }
button.chip { font: inherit; color: var(--text); cursor: pointer; }
button.chip:hover { border-color: var(--sport); }
button.chip[aria-pressed="true"] { border-color: var(--sport); box-shadow: inset 0 0 0 1px var(--sport); }
.race[hidden] { display: none; }
/* Abas do "Cuidado e atenção" */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; overflow-x: auto; }
.tabs [role=tab] { font: inherit; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tabs [role=tab] .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sport); }
.tabs [role=tab][aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--sport); }
.tab-panel[hidden] { display: none; }
/* Treinos fortes (Insights) */
.hard-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.hard { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--sport); border-radius: 10px; padding: 10px 14px; }
.hard > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.zone-badge { flex: none; font-weight: 700; font-size: 0.85rem; border: 1.5px solid var(--text); border-radius: 6px; padding: 1px 6px; margin-top: 1px; }
/* Loading da sincronização: atleta fazendo um triatlo numa pista com as cores das modalidades */
.sync-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); }
.sync-overlay[hidden] { display: none; }
.sync-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 24px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.12); }
.sync-track { position: relative; width: 100%; height: 64px; margin-bottom: 10px; display: flex; align-items: flex-end; gap: 4px; }
.sync-track .leg { flex: 1; height: 6px; border-radius: 3px; opacity: 0.35; animation: leg 3.6s infinite; }
.sync-track .swim { background: var(--series-5); }
.sync-track .bike { background: var(--series-3); animation-delay: 1.2s; }
.sync-track .run { background: var(--series-1); animation-delay: 2.4s; }
@keyframes leg { 0%, 33% { opacity: 1; } 34%, 100% { opacity: 0.35; } }
.sync-track .athlete { position: absolute; bottom: 8px; left: 4%; width: 44px; height: 44px; margin-left: -22px;
  animation: move 3.6s linear infinite, bob 0.45s ease-in-out infinite alternate; }
.sync-track .athlete svg { position: absolute; inset: 0; width: 44px; height: 44px; fill: none; stroke: currentColor;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; animation: 3.6s step-end infinite; }
.sync-track .athlete .a-swim { color: var(--series-5); animation-name: show-swim; }
.sync-track .athlete .a-bike { color: var(--series-3); animation-name: show-bike; }
.sync-track .athlete .a-run { color: var(--series-1); animation-name: show-run; }
.sync-track .wave { stroke-width: 2; opacity: 0.7; }
@keyframes move { from { left: 4%; } to { left: 96%; } }
@keyframes show-swim { 0% { opacity: 1; } 33.33% { opacity: 0; } }
@keyframes show-bike { 0% { opacity: 0; } 33.33% { opacity: 1; } 66.66% { opacity: 0; } }
@keyframes show-run { 0% { opacity: 0; } 66.66% { opacity: 1; } }
@keyframes bob { from { margin-bottom: 0; } to { margin-bottom: 5px; } }
.sync-card strong { font-size: 1.1rem; }
.sync-card button { margin-top: 10px; }
.sync-overlay.failed .sync-track { opacity: 0.4; }
.sync-overlay.failed .sync-track * { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .sync-track .athlete { animation: none; left: 50%; }
  .sync-track .athlete svg { animation: none; }
  .sync-track .athlete .a-run { opacity: 1; }
  .sync-track .leg { animation: none; opacity: 1; }
}
/* Loading com GIF próprio: só o GIF; o texto aparece apenas se a sincronização falhar */
.sync-card.gif { background: none; border: 0; box-shadow: none; padding: 0; width: auto; }
.sync-gif { display: block; max-width: min(420px, 90vw); max-height: 60vh; border-radius: 16px;
  filter: drop-shadow(0 10px 24px rgb(0 0 0 / 0.18)); }  /* acompanha o contorno de GIF transparente */
.sync-card.gif > strong, .sync-card.gif > #sync-step { display: none; }
.sync-overlay.failed .sync-card.gif { background: var(--surface); border: 1px solid var(--border); padding: 20px; }
.sync-overlay.failed .sync-card.gif > strong, .sync-overlay.failed .sync-card.gif > #sync-step { display: block; }
.sync-overlay.failed .sync-gif { max-height: 30vh; opacity: 0.5; box-shadow: none; }
