:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1b2434;
  --surface-3: #232e40;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f6;
  --muted: #8e97aa;
  --accent: #ff6a4d;
  --accent-soft: rgba(255, 106, 77, 0.16);
  --s-squat: #e6513a;
  --s-hip: #3a78e0;
  --s-calf: #b8851f;
  --s-lunge: #29a377;
  --s-other: #8a65e0;
  --up: #34c98f;
  --down: #ff6a4d;
  --radius: 18px;
  --radius-s: 12px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button { font: inherit; color: inherit; }

.wrap {
  width: min(1080px, 100% - 32px);
  margin-inline: auto;
}

.muted { color: var(--muted); }

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }

h1 { font-size: clamp(30px, 6vw, 44px); font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }

/* ---------- Masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 15, 23, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark { width: 28px; height: 28px; flex: none; }

.topnav { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; }

.topnav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 120ms ease, background 120ms ease;
}

.topnav a[aria-current="page"] { background: var(--surface-3); color: var(--text); }

.topnav a:hover { color: var(--text); }

@media (max-width: 480px) {
  .brand span { display: none; }
}

/* ---------- Page ---------- */

main { padding-block: 28px 64px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
}

.page-head p { margin: 4px 0 0; color: var(--muted); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 18px;
}

.back:hover { color: var(--text); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 42px;
  min-width: 240px;
}

.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }

.search input {
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  width: 100%;
}

.search input::placeholder { color: var(--muted); }

/* ---------- Tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tile .label { color: var(--muted); font-size: 13px; font-weight: 500; }

.tile .value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .value small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

.tile .sub { color: var(--muted); font-size: 12.5px; line-height: 1.3; }

.tile.up .value { color: var(--up); }
.tile.down .value { color: var(--down); }

/* ---------- Athlete grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.card-link:hover, .card-link:focus-visible {
  border-color: var(--line-2);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.avatar {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: #0b0f17;
  background: linear-gradient(135deg, #ff8f6d, #ff5a3d);
  flex: none;
}

.avatar.big { width: 64px; height: 64px; font-size: 22px; }

.card-link .name { grid-column: 2; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

.card-link .meta { grid-column: 2; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; line-height: 1.35; white-space: nowrap; }

.card-link .meta b { color: var(--text); font-weight: 600; }

.card-link .spark { grid-column: 3; grid-row: 1 / 3; width: 72px; height: 36px; }

.card-link.hidden { display: none; }

.card-link.is-empty .avatar { background: var(--surface-3); color: var(--muted); }

/* ---------- Athlete header ---------- */

.athlete-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.athlete-head .last { color: var(--muted); margin: 2px 0 0; }

.athlete-head .last b { color: var(--text); font-weight: 600; }

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.chip:hover { color: var(--text); }

.chip[aria-pressed="true"] { background: var(--surface-3); color: var(--text); border-color: var(--line-2); }

/* ---------- Chart ---------- */

.chart {
  position: relative;
  width: 100%;
  height: 240px;
}

@media (max-width: 640px) { .chart { height: 200px; } }

.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }

.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .tick { fill: var(--muted); font-size: 11px; font-weight: 500; }
.chart .area { opacity: 0.9; }
.chart .series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--surface); stroke-width: 2; }
.chart .halo { fill: none; stroke-width: 6; opacity: 0.28; }
.chart .lbl { fill: var(--text); font-size: 12px; font-weight: 700; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; opacity: 0; }
.chart .focus { opacity: 0; stroke: var(--text); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }

.chart-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.chart-foot b { color: var(--text); font-weight: 600; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 80ms ease;
  z-index: 2;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}

.tooltip .t-week { color: var(--muted); font-size: 12px; }

.tooltip .t-val { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }

.tooltip.is-on { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .chart .series.draw {
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
    animation: draw 900ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  .chart .area.draw { animation: fade 900ms ease-out forwards; opacity: 0; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes fade { to { opacity: 0.9; } }
}

/* ---------- Session tables ---------- */

.session { padding: 0; overflow: hidden; }

.session-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px;
}

.session-head h2 { font-size: 18px; }

.session-head .when { color: var(--muted); font-size: 13px; font-weight: 500; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 201, 143, 0.14);
  color: var(--up);
}

.status.none { background: var(--surface-3); color: var(--muted); }

table.log { width: 100%; border-collapse: collapse; }

.log th, .log td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.log th { color: var(--muted); font-weight: 500; font-size: 12px; padding-top: 6px; padding-bottom: 6px; background: rgba(255, 255, 255, 0.02); }

.log td:first-child, .log th:first-child { padding-left: 16px; }
.log td:last-child, .log th:last-child { padding-right: 16px; }

.log .col-exo { width: 34%; }
.log .col-vol { width: 15%; }
.log .col-target { width: 22%; }

.log .exo { font-weight: 600; }

.log .exo::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--c, var(--line-2));
  vertical-align: 1px;
}

.log .note { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; }

.log .vol, .log .target { color: var(--muted); }

.sets { display: flex; flex-wrap: wrap; gap: 4px; }

.set {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 13px;
}

.set.is-top { background: var(--accent); color: #0b0f17; }

.set.is-text { font-weight: 500; color: var(--muted); }

.dash { color: var(--line-2); }

@media (max-width: 640px) {
  .log thead { display: none; }
  .log, .log tbody { display: block; }
  .log tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; padding: 10px 14px; border-top: 1px solid var(--line); }
  .log td { display: block; border: 0; padding: 0; }
  .log .exo { grid-column: 1; }
  .log .vol { grid-column: 2; grid-row: 1; text-align: right; font-size: 13px; white-space: nowrap; }
  .log .target { grid-column: 1 / -1; font-size: 13px; }
  .log .target::before { content: "Demandé : "; }
  .log .target.empty { display: none; }
  .log td.done { grid-column: 1 / -1; }
  .log td.done.empty { display: none; }
  .log td.done .set { min-width: 40px; font-size: 14px; padding: 4px 10px; }
}

/* History */

.history { display: grid; gap: 8px; }

.history details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.history summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 14px 16px;
  font-weight: 700;
}

.history summary::-webkit-details-marker { display: none; }

.history summary .recap { color: var(--muted); font-weight: 500; font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }

.history summary .recap b { color: var(--text); font-weight: 600; }

.history summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-left: auto;
  transition: transform 160ms ease;
}

.history details[open] summary::after { transform: rotate(-135deg); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}

.section-title p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Warm-up ---------- */

.drills { display: grid; gap: 10px; }

.drill {
  display: grid;
  gap: 8px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

@media (min-width: 720px) { .drill { grid-template-columns: 220px 1fr 220px; } }

.drill .volume { margin: 4px 0 0; color: var(--accent); font-weight: 700; font-size: 14px; }

.drill .cues { margin: 0; white-space: pre-line; color: var(--text); }

.drill .goal { font-size: 13px; color: var(--muted); }

.drill .goal b { color: var(--text); font-weight: 600; display: block; margin-bottom: 2px; }

/* ---------- Colophon ---------- */

.colophon { padding-bottom: 32px; color: var(--muted); font-size: 12.5px; }

.colophon p { max-width: 70ch; margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }