:root {
  color-scheme: light;
  --bg: #e8f0fa;
  --surface: rgb(255 255 255 / .66);
  --text: #13233a;
  --muted: #5b6b82;
  --line: rgb(40 80 140 / .14);
  --accent: #1f6fd1;
  --accent-soft: rgb(31 111 209 / .12);
  --other-day: rgb(255 255 255 / .38);
  --ok: #2f8a57;
  --pending: #d08a1c;
  --error: #c0392b;
  --error-soft: #fbe9e7;
  --warmup: #7aa5c9;
  --repeat: #c9643b;
  --recovery: #8fb58c;
  --cooldown: #9a8fc0;
  /* Réalisé (sorties Intervals) : neutre, distinct du prévu (vert). */
  --act: rgb(110 135 170 / .13);
  --act-line: #7c8ea6;
  /* Courbes : palette catégorielle validée (daltonisme, contraste). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  /* Statuts : toujours accompagnés d'une icône et d'un texte. */
  --good: #0ca30c;
  --warning: #b77f00;
  --critical: #d03b3b;
  --shadow: 0 4px 18px rgb(30 70 130 / .08);
  /* Zones d'intensité (profil des séances) : une seule teinte, claire → foncée. */
  --z0: #b9c4d3;
  --z1: #86b6ef;
  --z2: #5598e7;
  --z3: #2a78d6;
  --z4: #1c5cab;
  --z5: #104281;
  /* Types de séance : ordre catégoriel fixe, toujours avec un libellé. */
  --t-long: #2a78d6;
  --t-intense: #eb6834;
  --t-endurance: #1baf7a;
  --t-tempo: #eda100;
  --t-recovery: #e87ba4;
  --t-hills: #4a3aa7;
  /* Fond : dégradé bleuté ; les cartes en verre dépoli le laissent transparaître. */
  --page-bg: linear-gradient(160deg, #eef5fd 0%, #dbe7f7 55%, #e6edfa 100%);
  --glass: blur(14px) saturate(1.3);
  --solid: #f4f8fe;
  color-scheme: light;
}

/* Sombre : réglage du téléphone, sauf si « Clair » est choisi dans le menu ; ou forcé par « Sombre ». */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="glass"]) {
    --bg: #0b1424;
    --surface: rgb(255 255 255 / .06);
    --text: #e8eef8;
    --muted: #93a3bb;
    --line: rgb(160 190 235 / .14);
    --accent: #4d9cff;
    --accent-soft: rgb(77 156 255 / .16);
    --other-day: rgb(255 255 255 / .025);
    --error-soft: #3a2220;
    --act: rgb(255 255 255 / .06);
    --act-line: #7f93ad;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --warning: #fab219;
    --shadow: none;
    --z0: #3d4a60;
    --z1: #1c5cab;
    --z2: #256abf;
    --z3: #3987e5;
    --z4: #6da7ec;
    --z5: #9ec5f4;
    --t-long: #3987e5;
    --t-intense: #d95926;
    --t-endurance: #199e70;
    --t-tempo: #c98500;
    --t-recovery: #d55181;
    --t-hills: #9085e9;
    --page-bg: linear-gradient(160deg, #0b1424 0%, #11203c 60%, #0c182c 100%);
    --solid: #111d33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1424;
  --surface: rgb(255 255 255 / .06);
  --text: #e8eef8;
  --muted: #93a3bb;
  --line: rgb(160 190 235 / .14);
  --accent: #4d9cff;
  --accent-soft: rgb(77 156 255 / .16);
  --other-day: rgb(255 255 255 / .025);
  --error-soft: #3a2220;
  --act: rgb(255 255 255 / .06);
  --act-line: #7f93ad;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --warning: #fab219;
  --shadow: none;
  --z0: #3d4a60;
  --z1: #1c5cab;
  --z2: #256abf;
  --z3: #3987e5;
  --z4: #6da7ec;
  --z5: #9ec5f4;
  --t-long: #3987e5;
  --t-intense: #d95926;
  --t-endurance: #199e70;
  --t-tempo: #c98500;
  --t-recovery: #d55181;
  --t-hills: #9085e9;
  --page-bg: linear-gradient(160deg, #0b1424 0%, #11203c 60%, #0c182c 100%);
  --solid: #111d33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* L'attribut hidden doit primer sur les display: flex/grid des composants. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg) var(--page-bg) fixed;
  min-height: 100vh;
  color: var(--text);
}
body.busy { cursor: progress; }
body.busy main { opacity: .7; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--error); }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
}
textarea { width: 100%; resize: vertical; }
/* Une liste aux options longues (courses) ne doit pas élargir la page sur téléphone. */
select { max-width: 100%; }

/* ---------- En-tête ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.toolbar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; padding: 5px 12px; background: var(--surface); }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.icon-btn { width: 34px; height: 32px; padding: 0; font-size: 17px; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.top h1 { margin: 0; font-size: 20px; color: var(--accent); }
.month-nav { display: flex; align-items: center; gap: 8px; }
#month-label { min-width: 150px; text-align: center; font-weight: 600; text-transform: capitalize; border: none; background: none; font-size: 15px; }
/* Titre repliable des panneaux : affiché sur mobile seulement. */
.panel-summary { display: none; }

.burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 34px;
  padding: 0 9px;
}
.burger span { display: block; height: 2px; border-radius: 1px; background: var(--text); }

/* ---------- Menu latéral ---------- */

dialog.drawer {
  margin: 0;
  width: min(380px, 100vw);
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 0 16px 24px;
  background: var(--bg);
  overflow-y: auto;
}
.drawer-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 10px;
  background: var(--bg);
  z-index: 1;
}
.drawer-head h2 { margin: 0; font-size: 20px; color: var(--accent); }
.drawer section { padding: 12px 0; border-top: 1px solid var(--line); }
.drawer h3 { margin: 0 0 10px; font-size: 15px; }
.drawer details { margin-top: 10px; }

.profile { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.profile .wide { grid-column: 1 / -1; }
.profile .unit { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.profile .unit input { width: 100%; min-width: 0; }
.profile input, .profile select { color: var(--text); }
.profile p { margin: 0; }
.hr-zones-input { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.hr-zones-input legend { padding: 0 4px; font-size: 13px; color: var(--muted); }
.hr-zones-input .z5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.hr-zones-input input { width: 100%; min-width: 0; }
.hr-zones-input p { margin-top: 6px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

.import-btn { width: 100%; margin-top: 8px; }
.import-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
}
.import-panel p { margin: 0 0 8px; }
.import-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.import-row .small { grid-column: 2 / -1; }
.import-row.same { opacity: .6; }

table.zones { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 13px; }
table.zones caption { caption-side: bottom; padding-top: 4px; text-align: left; font-size: 12px; color: var(--muted); }
table.zones th, table.zones td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; font-weight: normal; }
table.zones td { text-align: right; font-variant-numeric: tabular-nums; }

.links { margin: 0 0 10px; padding: 0; list-style: none; }
.links li { padding: 5px 0; }
.links a { color: var(--accent); font-weight: 600; }
.link-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; margin-bottom: 6px; }
.link-row input { min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; }

.stack { display: flex; flex-direction: column; gap: 8px; }
a.button, label.button {
  display: block;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  text-align: center;
  text-decoration: none;
}
a.button:hover, label.button:hover { border-color: var(--accent); }
#intervals-status { margin: 0 0 10px; font-size: 13px; }

#alerts {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border: 1px solid var(--pending);
  border-radius: 8px;
  background: var(--surface);
}
#alerts.has-errors { border-color: var(--error); background: var(--error-soft); }
#alerts p { margin: 4px 0; }
#alerts ul { margin: 6px 0 0; padding-left: 20px; }
.alert-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }

/* ---------- Mise en page ---------- */

main { max-width: 1500px; margin: 0 auto; padding: 14px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
#alerts { margin: 12px 16px 0; }

/* ---------- Tableau de bord ---------- */


/* ---------- Semaine et journée ---------- */




.day-focus { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.focus-title { margin: 0; font-size: 18px; }
.focus-card {
  --t: var(--accent);
  border-radius: 14px; padding: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--t) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--t) 35%, var(--line));
  display: flex; flex-direction: column; gap: 8px;
}
.focus-card.act { --t: var(--act-line); }
.focus-card.missed { opacity: .7; }
.focus-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.focus-name { font-size: 17px; flex: 1; min-width: 0; }
.focus-kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.focus-kind.act { color: var(--act-line); }
.sync { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; }
.focus-profile .profile-svg { height: 56px; }
.focus-sum { font-size: 13px; color: var(--muted); }
.focus-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.focus-meta b { color: var(--text); font-size: 16px; }
.focus-meta.big b { font-size: 20px; }
.focus-linked { font-size: 13px; padding: 6px 8px; border-radius: 8px; background: var(--surface); }
.focus-empty { text-align: center; padding: 14px 8px; color: var(--muted); }
.focus-empty p { margin: 0 0 10px; }

.type-chip {
  --t: var(--accent);
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--text);
  background: color-mix(in srgb, var(--t) 22%, var(--surface)); border: 1px solid var(--t);
}
.t-long { --t: var(--t-long); }
.t-intense { --t: var(--t-intense); }
.t-endurance { --t: var(--t-endurance); }
.t-tempo { --t: var(--t-tempo); }
.t-recovery { --t: var(--t-recovery); }
.t-hills { --t: var(--t-hills); }
.t-strength { --t: #7d8799; }
/* Éditeur, renfo : ni terrain ni étapes, une durée indicative et les exercices en notes. */
#editor-form.is-strength .no-strength, #editor-form:not(.is-strength) .only-strength { display: none !important; }
#ed-strength p { margin: 4px 0 0; }
#ed-strength input { width: 7em; }
.strength-notes { margin: 0; padding-left: 1.2em; }

/* Profil de séance : zones d'intensité. */
.profile-svg { display: block; width: 100%; height: 16px; }
.profile-svg .z0 { fill: var(--z0); }
.profile-svg .z1 { fill: var(--z1); }
.profile-svg .z2 { fill: var(--z2); }
.profile-svg .z3 { fill: var(--z3); }
.profile-svg .z4 { fill: var(--z4); }
.profile-svg .z5 { fill: var(--z5); }
.profile-svg .lap { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 2; }
.card-profile { margin: 3px 0 2px; }

.goal-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
}
.goal-count { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.goal-count small { font-size: 18px; }
.goal-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.goal-info strong { font-size: 15px; }
.chart .goal-line { stroke: var(--text); stroke-width: 1.5; }
.show-past { display: none; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.tile-label { font-size: 12.5px; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-sub { font-size: 12.5px; color: var(--muted); }
.tile.warn .tile-sub { color: var(--warning); font-weight: 600; }
.zone { font-weight: 600; }
.zone.good { color: var(--good); }
.zone.critical { color: var(--critical); }
.zone.neutral { color: var(--muted); }
.totals-panel { overflow-x: auto; }
table.totals { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.totals caption { caption-side: bottom; padding-top: 6px; text-align: left; font-size: 12px; color: var(--muted); }
table.totals th, table.totals td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.totals thead th { font-size: 12px; font-weight: 600; color: var(--muted); }
table.totals tbody th { text-align: left; font-weight: 600; }
table.totals tbody tr:last-child > * { border-bottom: none; }

/* ---------- Calendrier ---------- */

.calendar-panel { padding: 10px; }
.weekdays, #calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(120px, .9fr);
  gap: 4px;
}
.weekdays { margin-bottom: 4px; }
.weekdays span { text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; }

.day {
  min-height: 118px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.day.other { background: var(--other-day); }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day.over { background: var(--accent-soft); }
.day-head { display: flex; justify-content: space-between; align-items: center; }
.day-num { font-size: 13px; color: var(--muted); }
.day.today .day-num { color: var(--accent); font-weight: 700; }
.day-num .wd { display: none; }
.add { padding: 0 7px; border: none; background: none; color: var(--muted); opacity: 0; }
.day:hover .add, .add:focus { opacity: 1; }

.card {
  position: relative;
  padding: 4px 6px 4px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  cursor: pointer;
  font-size: 12.5px;
  min-width: 0;
}
.card:hover { filter: brightness(.97); }
.card-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sum { color: var(--muted); overflow-wrap: anywhere; }
.card-foot { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.st-ok .dot { background: var(--ok); }
.st-pending .dot { background: var(--pending); }
.st-error .dot { background: var(--error); }
.card.st-error { border-left-color: var(--error); background: var(--error-soft); }
.card.plan { --t: var(--accent); border-left-color: var(--t); background: color-mix(in srgb, var(--t) 10%, var(--surface)); }
.card-type { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.card.plan.missed { opacity: .65; }
.card.plan.missed .card-top strong { text-decoration: line-through; }
.card.act { background: var(--act); border-left-color: var(--act-line); }
.card.act:not(.run) { opacity: .8; }
.act-icon { flex: none; font-size: 12px; }

.badge { display: inline-block; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; line-height: 1.5; }
.badge.good { color: var(--good); }
.badge.warning { color: var(--warning); }
.badge.critical { color: var(--critical); }
.badge.missed { color: var(--muted); }
.badge.link { color: var(--act-line); }
.badge.plan { color: var(--accent); }

#calendar[data-filter="plan"] .card.act,
#calendar[data-filter="done"] .card.plan { display: none; }

.week {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--other-day);
  border: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}
.week-head { font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; }
.week-main { font-size: 17px; font-weight: 700; color: var(--text); }
.week-load { margin-top: 4px; color: var(--text); font-weight: 600; }

.help { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }
.legend-chip { display: inline-block; padding: 0 8px; border-radius: 4px; border-left: 3px solid; font-size: 12px; }
.legend-chip.plan { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.legend-chip.act { background: var(--act); border-color: var(--act-line); color: var(--text); }

/* ---------- Courbes ---------- */

.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.chart-head h2 { margin: 0; font-size: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.sw.ctl { border-color: var(--series-1); }
.sw.atl { border-color: var(--series-2); }
.sw.tsb { border-color: var(--series-3); }
.sw.proj { border-top: 2px dashed var(--muted); }
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.ctl { stroke: var(--series-1); }
.chart .ln.atl { stroke: var(--series-2); }
.chart .ln.tsb { stroke: var(--series-3); }
.chart .ln.proj { stroke-dasharray: 5 4; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.ref { stroke-dasharray: 2 3; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .tick.strong { fill: var(--text); font-weight: 600; }
.chart .today-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .dot-ctl { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .dot-atl { fill: var(--series-2); stroke: var(--surface); stroke-width: 2; }
.chart .dot-tsb { fill: var(--series-3); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
  position: absolute;
  top: 24px;
  width: 190px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgb(0 0 0 / .12);
  font-size: 12.5px;
  pointer-events: none;
}
.chart-tip div { display: flex; align-items: center; gap: 6px; }
.chart-values { margin-top: 6px; }
.chart-panel > p { margin: 8px 0 0; }

/* ---------- Fiche d'une sortie ---------- */

dialog.sheet { width: min(560px, calc(100vw - 16px)); }
.sheet-inner { position: relative; padding: 16px; }
.sheet-close { position: absolute; top: 12px; right: 12px; }
.sheet h2 { margin: 0 36px 2px 0; font-size: 18px; }
.sheet p { margin: 6px 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.note { padding: 8px 10px; border-left: 3px solid var(--warning); background: var(--surface); font-size: 13px; }
.act-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin: 8px 0; }
.act-link > div { width: 100%; }

/* Éditeur : charge prévue et sortie reliée */
.ed-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#editor-form .link-select { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.link-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
button.linkish { border: none; background: none; color: var(--accent); text-decoration: underline; padding: 0 2px; }
.history { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }

/* ---------- Éditeur ---------- */

dialog {
  width: min(760px, calc(100vw - 16px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .4); }
#editor-form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
#editor-form label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
#editor-form label input, #editor-form label textarea { color: var(--text); }
.ed-head { display: flex; align-items: baseline; gap: 12px; }
.ed-head h2 { margin: 0; font-size: 18px; }
.status { font-size: 13px; font-weight: 600; }
.status.st-ok { color: var(--ok); }
.status.st-pending { color: var(--pending); }
.status.st-error { color: var(--error); }
.ed-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ed-row .grow { flex: 1; min-width: 180px; }

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.b-warmup { border-left-color: var(--warmup); }
.b-repeat { border-left-color: var(--repeat); }
.b-recovery { border-left-color: var(--recovery); }
.b-cooldown { border-left-color: var(--cooldown); }
.b-run { border-left-color: var(--t-long); }
.block-head { display: flex; align-items: center; gap: 8px; }
.block-head .spacer { flex: 1; }
#editor-form .reps { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.reps input { width: 60px; }
button.icon { padding: 2px 8px; }

.step { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
#editor-form .step > label { flex-direction: row; align-items: center; gap: 6px; }
.step-label { min-width: 50px; font-weight: 600; font-size: 13px; }
.dur { width: 72px; }
#editor-form .chk { flex-direction: row; align-items: center; gap: 4px; color: var(--text); }
.target { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.watts { width: 72px; }
.hint { font-size: 12px; }
.rec { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }

.ed-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ed-total { margin: 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
pre {
  margin: 6px 0 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: 13px;
}
pre.invalid { color: var(--error); }
.error-text { margin: 0; color: var(--error); }
.ed-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding-top: 6px; }
.ed-foot > div, #ed-dup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  z-index: 10;
}
#toast.error { background: var(--error); color: #fff; }

/* ---------- Connexion ---------- */

body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-box h1 { margin: 0; color: var(--accent); }
.login-box label { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Écrans moyens et mobile ---------- */

@media (max-width: 1100px) {
  }

@media (max-width: 700px) {
  /* En-tête : ☰ ‹ mois › puis filtres et actualisation. */
  .top { gap: 8px; padding: 8px 10px; }
  #today { display: none; }
  .month-nav { flex: 1; justify-content: center; }
  #month-label { min-width: 0; flex: 1; }
  .toolbar { margin-left: 0; width: 100%; }
  .segmented { flex: 1; }
  .segmented button { flex: 1; padding: 4px 8px; }
  main { padding: 8px 10px 88px; gap: 8px; }

  /* Alertes : le titre et le bouton suffisent. */
  #alerts { margin: 8px 10px 0; padding: 8px 10px; font-size: 14px; }
  #alerts ul { display: none; }

  /* Tableau de bord : trois petites tuiles, totaux et courbes repliés. */
  .tiles { gap: 6px; }
  .tile { padding: 6px 8px; }
  .tile-label { font-size: 11px; }
  .tile-value { font-size: 20px; }
  .tile:not(.tsb) .tile-sub { display: none; }
  .panel-summary { display: list-item; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text); }
  details.card-panel { padding: 10px 12px; }
  details.card-panel[open] > .panel-summary { margin-bottom: 8px; }
  .chart-head h2, .chart-panel > p { display: none; }

  /* Jours passés du mois masqués, affichables d'un toucher. */
  .show-past { display: block; width: 100%; margin-bottom: 6px; color: var(--muted); }
  #calendar:not(.show-past) .day.past, #calendar:not(.show-past) .week.past { display: none; }
  .card-type { display: none; }

  /* Calendrier en agenda : seulement les jours utiles, date à gauche. */
  .calendar-panel { padding: 0; background: none; border: none; box-shadow: none; }
  .weekdays, .help { display: none; }
  #calendar { grid-template-columns: 1fr; gap: 6px; }
  .day.empty:not(.today) { display: none; }
  .day.other { background: var(--surface); }
  .day {
    min-height: 0;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 8px;
    row-gap: 4px;
    align-items: start;
    padding: 6px 8px;
  }
  .day-head { grid-column: 1; grid-row: 1; flex-direction: column; align-items: center; }
  .day-num { display: flex; flex-direction: column; align-items: center; line-height: 1.1; font-size: 20px; font-weight: 700; color: var(--text); }
  .day-num .wd { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
  .day.today .day-num, .day.today .day-num .wd { color: var(--accent); }
  .day.empty.today::after { content: 'Rien de prévu'; grid-column: 2; color: var(--muted); font-size: 13px; align-self: center; }
  .add { display: none; }
  .day > .card { grid-column: 2; }
  .card { font-size: 13px; }
  .card-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card.act .card-foot { display: none; }

  /* Bilan de la semaine sur une ligne. */
  .week { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 5px 10px; margin-bottom: 8px; border-style: solid; font-size: 12px; }
  .week.empty, .week-extra { display: none; }
  .week-main { font-size: 14px; }
  .week-load { margin-top: 0; }


  table.totals tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Style « appli » : pavés colorés, dégradés ---------- */

.card-panel, .tile, .focus-card, .goal-card { border-radius: 18px; }

/* Types de séance : dégradés assez sombres pour du texte blanc lisible. */
.t-long { --g1: #2d6fd6; --g2: #1b3f8f; }
.t-intense { --g1: #e2582d; --g2: #a82c17; }
.t-endurance { --g1: #16946d; --g2: #0b5e52; }
.t-tempo { --g1: #c47300; --g2: #8a4500; }
.t-recovery { --g1: #c2457a; --g2: #7d2a63; }
.t-hills { --g1: #6246d8; --g2: #33258c; }
.t-strength { --g1: #5d6880; --g2: #343b4d; }

.focus-card.plan, .focus-card.act {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, var(--g1, #2d6fd6), var(--g2, #1b3f8f));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--g2, #1d4535) 35%, transparent);
}
.focus-card.act { --g1: #52627a; --g2: #2f3a4c; }
.focus-card.missed { filter: grayscale(.8); opacity: .75; }
.focus-card .focus-name { font-size: 20px; }
.focus-card .focus-sum, .focus-card .focus-meta, .focus-card .sync, .focus-card .focus-kind { color: rgb(255 255 255 / .82); }
.focus-card .focus-meta b { color: #fff; font-size: 20px; }
.focus-card .type-chip { color: #fff; background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .45); }
.focus-card .focus-linked { background: rgb(255 255 255 / .16); color: #fff; }
.focus-card .badge { background: #fff; border-color: #fff; }
.focus-card .badge.missed { color: #555; }
.focus-card .dot { box-shadow: 0 0 0 2px rgb(255 255 255 / .6); }
/* Profil sur fond coloré : blanc, de plus en plus opaque avec la zone. */
.focus-card .profile-svg .z0 { fill: rgb(255 255 255 / .28); }
.focus-card .profile-svg .z1 { fill: rgb(255 255 255 / .5); }
.focus-card .profile-svg .z2 { fill: rgb(255 255 255 / .66); }
.focus-card .profile-svg .z3 { fill: rgb(255 255 255 / .8); }
.focus-card .profile-svg .z4 { fill: rgb(255 255 255 / .92); }
.focus-card .profile-svg .z5 { fill: #fff; }
.focus-card .profile-svg .lap { stroke: #fff; }
.focus-profile { padding: 8px 8px 0; border-radius: 10px; background: rgb(0 0 0 / .12); }

/* Tuiles forme / fatigue / fraîcheur : teintées, icône. */
.tile { position: relative; overflow: hidden; border: none; --c: var(--accent); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.tile::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--c); }
.tile.ctl { --c: var(--series-1); }
.tile.atl { --c: var(--series-2); }
.tile.tsb { --c: var(--muted); }
.tile.tsb.z-good { --c: var(--good); }
.tile.tsb.z-critical { --c: var(--critical); }
.tile-label { display: flex; align-items: center; gap: 5px; font-weight: 600; }
.tile-icon { font-size: 14px; }
.tile-value { font-size: 30px; }

/* Bilan de la semaine en pavés colorés. */
.pave { --c: var(--accent); display: flex; flex-direction: column; padding: 8px 10px; border-radius: 14px; background: color-mix(in srgb, var(--c) 15%, var(--surface)); min-width: 0; }
.pave b { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pave span:last-child { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pave-icon { font-size: 14px; }
.p-km { --c: var(--t-long); }
.p-dplus { --c: var(--t-hills); }
.p-time { --c: var(--t-endurance); }
.p-load { --c: var(--t-intense); }

/* Objectif : bandeau en dégradé. */
.goal-card { color: #fff; border: none; background: linear-gradient(135deg, #1f7a5a, #0f4c6b); box-shadow: 0 6px 18px rgb(15 76 107 / .3); }
.goal-card .goal-count { color: #fff; font-size: 42px; }
.goal-card .muted { color: rgb(255 255 255 / .8); }

/* Jour sélectionné : pastille pleine en dégradé. */

/* Cartes du calendrier : un peu plus de couleur. */
.card.plan { background: color-mix(in srgb, var(--t) 16%, var(--surface)); border-left-width: 4px; border-radius: 8px; }
.card.act { border-radius: 8px; }

@media (max-width: 700px) {
    .tile-value { font-size: 22px; }
  .goal-card .goal-count { font-size: 34px; }
  .focus-card .focus-name { font-size: 18px; }
}

/* Totaux : une carte par période, valeurs étiquetées (tient dans la colonne). */
table.totals, table.totals tbody { display: block; }
table.totals thead { display: none; }
table.totals caption { display: block; }
table.totals tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
table.totals tbody tr:last-child { border-bottom: none; }
table.totals th, table.totals td { border: none; padding: 0; text-align: left; white-space: normal; }
table.totals tbody th { grid-column: 1 / -1; font-size: 14px; }
table.totals td { font-weight: 600; }
table.totals td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* ---------- Cartes : tracé d'une sortie, carte du mois ---------- */

.sheet-map { height: 260px; border-radius: 12px; overflow: hidden; margin: 8px 0; background: var(--other-day); }
.elev { margin: 4px 0 8px; }
.elev-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.elev-area { fill: color-mix(in srgb, var(--series-2) 22%, transparent); }
.elev-line { fill: none; stroke: var(--series-2); stroke-width: 2; }
.elev-svg .tick, .map-panel .tick { fill: var(--muted); font-size: 11px; }
.elev-svg .tick.strong { fill: var(--text); font-weight: 600; }
.elev-svg .cross { stroke: var(--muted); }
.map-summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.map-panel p { margin: 6px 0; }
.map-actions { display: flex; gap: 6px; }
.month-map { height: 420px; border-radius: 12px; overflow: hidden; background: var(--other-day); }
.leaflet-container { font: inherit; }
.theme-select { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }

/* ---------- Agenda (mobile) ---------- */

.agenda { display: none; }
.ag-week { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; margin-bottom: 12px; }
.ag-week.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ag-head { padding: 10px 12px; background: var(--other-day); border-bottom: 1px solid var(--line); }
.ag-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ag-dates { font-weight: 700; font-size: 16px; }
.ag-pill { padding: 1px 8px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.ag-pill.goal { background: var(--accent); color: #fff; }
.ag-total { margin-top: 2px; font-size: 13px; color: var(--muted); }
.ag-total b { color: var(--text); }
.ag-day { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px 8px 8px; border-bottom: 1px solid var(--line); min-height: 58px; }
.ag-day:last-child { border-bottom: none; }
.ag-date { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ag-date span { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ag-date b { font-size: 18px; }
.ag-day.today .ag-date b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 15px; }
.ag-day.past .ag-date { opacity: .6; }
.ag-items { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ag-add { grid-column: 2 / -1; justify-self: start; border: none; background: none; color: var(--muted); font-size: 15px; padding: 6px 4px; }
.ag-add span { font-size: 20px; line-height: 1; }
.ag-plus { border: none; background: none; color: var(--muted); font-size: 22px; padding: 0 6px; }
.ag-card {
  display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; text-align: left;
  padding: 0 10px 0 0; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; color: var(--text);
}
.ag-card.done { border-color: color-mix(in srgb, var(--text) 45%, var(--line)); }
.ag-card.missed { opacity: .6; }
.ag-bar { align-self: stretch; width: 6px; flex: none; background: linear-gradient(180deg, var(--g1, var(--accent)), var(--g2, var(--accent))); }
.ag-card.act .ag-bar { background: var(--act-line); }
.ag-card.act.other { opacity: .75; }
.ag-body { display: flex; flex-direction: column; gap: 1px; padding: 8px 0; min-width: 0; flex: 1; }
.ag-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-check { margin-left: auto; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 12px; flex: none; }
.ag-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-err { color: var(--critical); }
.agenda[data-filter="plan"] .ag-card.act, .agenda[data-filter="done"] .ag-card.plan { display: none; }

@media (max-width: 700px) {
  #calendar, .calendar-panel .weekdays { display: none; }
  .agenda { display: block; }
  .agenda:not(.show-past) .ag-week.past { display: none; }
  .month-map { height: 60vh; }
  .map-panel .panel-head > .segmented, .map-actions { flex: 1 1 100%; }
  .map-actions button { flex: 1; }
  .sheet-map { height: 220px; }
}

/* ---------- Pages ---------- */

/* Mois et filtres seulement là où ils servent. */
.month-nav, .toolbar .segmented { display: none; }
body[data-page="calendar"] .month-nav, body[data-page="map"] .month-nav { display: flex; }
body[data-page="calendar"] .toolbar .segmented { display: inline-flex; }
.top h1 { font-size: 19px; }
.page { display: flex; flex-direction: column; gap: 14px; }
.page[hidden] { display: none; }
.page.card-panel { gap: 10px; }
.page-narrow { width: 100%; max-width: 760px; margin: 0 auto; }
/* Onglets d'une page (Plan, Réglages) : pastilles qui passent à la ligne, jamais de débordement. */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs a:hover { border-color: var(--accent); }
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-off { display: none !important; }
div[data-tab]:not(.card-panel) { display: flex; flex-direction: column; gap: 14px; }
div[data-tab][hidden] { display: none; }
.page-home { width: 100%; max-width: 1100px; margin: 0 auto; }
.panel-title { margin: 0 0 8px; font-size: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.panel-head .panel-title { margin: 0; }
.page-suivi .card-panel { display: flex; flex-direction: column; gap: 8px; }
a.button.inline { display: inline-block; }

/* Menu : navigation entre les pages. */
.nav-list { display: flex; flex-direction: column; gap: 4px; padding: 8px 0 12px; }
.nav-list a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; }
.nav-list a span { font-size: 19px; width: 26px; text-align: center; }
.nav-list a:hover { background: var(--surface); }
.nav-list a[aria-current="page"] { background: var(--accent); color: #fff; }
.logout-link { margin-top: 10px; }

/* ---------- Accueil : jours glissants ---------- */

.tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rolling-panel { padding: 12px 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.rolling-head { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.rolling-head h2 { margin: 0; font-size: 16px; flex: 1; }
.rolling {
  display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-left: 0;
  padding: 2px 12px 6px 0; scrollbar-width: thin; overscroll-behavior-x: contain;
}
.roll-day {
  scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; min-height: 150px;
  padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; position: relative;
}
.roll-day.past { opacity: .8; }
.roll-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.roll-day[aria-current="date"] { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.roll-date { display: flex; align-items: baseline; gap: 5px; }
.roll-date span { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.roll-date b { font-size: 20px; }
.roll-day.today .roll-date span, .roll-day.today .roll-date b { color: var(--accent); }
.roll-date .roll-month { text-transform: none; font-weight: 500; }
.roll-items { display: flex; flex-direction: column; gap: 5px; }
.roll-item {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; padding: 6px 7px; border-radius: 10px; border: none;
  color: #fff; background: linear-gradient(135deg, var(--g1, var(--accent)), var(--g2, var(--accent)));
}
.roll-item.missed { filter: grayscale(.8); opacity: .7; }
.roll-item.act { background: var(--act); color: var(--text); border-left: 3px solid var(--act-line); }
.roll-item.act.other { opacity: .75; }
.roll-name { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-check { margin-left: auto; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: #1f5a44; font-size: 10px; flex: none; }
.roll-sub { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-item .profile-svg { height: 14px; }
.roll-item.plan .profile-svg .z0 { fill: rgb(255 255 255 / .3); }
.roll-item.plan .profile-svg .z1 { fill: rgb(255 255 255 / .5); }
.roll-item.plan .profile-svg .z2 { fill: rgb(255 255 255 / .66); }
.roll-item.plan .profile-svg .z3 { fill: rgb(255 255 255 / .8); }
.roll-item.plan .profile-svg .z4 { fill: rgb(255 255 255 / .92); }
.roll-item.plan .profile-svg .z5 { fill: #fff; }
.roll-item.plan .profile-svg .lap { stroke: #fff; }
.roll-rest { color: var(--muted); font-size: 13px; margin-top: 4px; }
.roll-add { margin-top: auto; align-self: flex-end; width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; color: var(--muted); }
.page-home .day-focus { border-top: none; padding-top: 0; }

/* ---------- Suivi annuel ---------- */

.year-nav { display: flex; align-items: center; gap: 8px; }
.year-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ybars-title { margin: 8px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.ybars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 130px; align-items: end; }
.ybar-col { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; }
.ybar { width: 70%; min-height: 0; border-radius: 4px 4px 0 0; background: var(--series-1); }
.ybars.dplus .ybar { background: var(--t-hills); }
.ybar-col.future .ybar { opacity: .35; }
.ybar-val { font-size: 10.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ybar-lbl { font-size: 11px; color: var(--muted); font-weight: 600; }

@media (max-width: 700px) {
  .top h1 { font-size: 17px; flex: 1; }
  /* Calendrier et carte : le nom du mois suffit comme titre. */
  body[data-page="calendar"] .top h1, body[data-page="map"] .top h1 { display: none; }
  body:not([data-page="calendar"]) .toolbar { width: auto; margin-left: auto; }
  .rolling { grid-auto-columns: 34vw; gap: 6px; }
  .roll-day { min-height: 104px; padding: 7px; }
  .roll-date b { font-size: 18px; }
  .roll-date .roll-month { display: none; }
  .rolling-hint { display: none; }
  #roll-prev, #roll-next { display: none; }
  .year-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ybar-val { display: none; }
}

/* ---------- Statuts des tuiles : pastille couleur + icône + texte ---------- */

:root { --fresh: #2a78d6; }
.status-pill {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
  padding: 2px 9px 2px 3px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  color: var(--text); background: color-mix(in srgb, var(--c) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
}
.pill-icon { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--c); color: #fff; font-size: 11px; line-height: 1; }
.s-good { --c: var(--good); }
.s-warning { --c: var(--warning); }
.s-critical { --c: var(--critical); }
.s-fresh { --c: var(--fresh); }
.s-neutral { --c: var(--muted); }
.tile-detail { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
/* La tuile prend la couleur de son statut (plus fort que la couleur de série). */
.tile.s-good { --c: var(--good); }
.tile.s-warning { --c: var(--warning); }
.tile.s-critical { --c: var(--critical); }
.tile.s-fresh { --c: var(--fresh); }
.tile.s-neutral { --c: var(--muted); }
.tile.s-good, .tile.s-warning, .tile.s-critical, .tile.s-fresh, .tile.s-neutral { background: color-mix(in srgb, var(--c) 13%, var(--surface)); }
.tile.s-good::before, .tile.s-warning::before, .tile.s-critical::before, .tile.s-fresh::before, .tile.s-neutral::before { background: var(--c); width: 6px; }
.tile .tile-sub { display: block !important; }

@media (max-width: 700px) {
  .tiles { gap: 6px; }
  .status-pill { font-size: 11px; padding-right: 7px; }
  .tile-detail { display: none; }
}

/* ---------- Thème bleu translucide : verre dépoli ---------- */

.top, .card-panel, .tile, .roll-day, .ag-week, .card, .day, .week, .status-pill, .pave, #alerts {
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.top { background: color-mix(in srgb, var(--solid) 75%, transparent); }
.card-panel, .tile, .ag-week { border: 1px solid rgb(255 255 255 / .55); }
:root[data-theme="dark"] .card-panel, :root[data-theme="dark"] .tile, :root[data-theme="dark"] .ag-week { border-color: rgb(255 255 255 / .08); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="glass"]) .card-panel, :root:not([data-theme="light"]):not([data-theme="glass"]) .tile, :root:not([data-theme="light"]):not([data-theme="glass"]) .ag-week { border-color: rgb(255 255 255 / .08); }
}
/* Fenêtres et menu : opaques pour la lisibilité. */
dialog, dialog.drawer, .drawer-head { background: var(--solid); }
.chart-tip, pre, .stat, .act-link, .ed-link, .block, .import-panel, .focus-linked, .note { background: color-mix(in srgb, var(--solid) 85%, transparent); }
input, select, textarea, button { background-color: color-mix(in srgb, var(--solid) 80%, transparent); }
button.primary { background: var(--accent); }
.segmented button[aria-pressed="true"], .nav-list a[aria-current="page"] { background: var(--accent); color: #fff; }
.goal-card { background: linear-gradient(135deg, #1f6fd1, #4338ca); box-shadow: 0 8px 22px rgb(31 111 209 / .3); }
.roll-check { color: var(--accent); }
.day.today, .roll-day.today, .ag-week.current { border-color: var(--accent); }

/* ---------- Accueil : cases jour compactes ---------- */

.rolling { align-items: start; }
.roll-day { min-height: 0; height: 128px; gap: 5px; overflow: hidden; }
.roll-date { align-items: center; }
.roll-add { margin: 0 0 0 auto; width: 24px; height: 24px; font-size: 16px; align-self: center; }
.roll-more { font-size: 11px; font-weight: 700; color: var(--muted); padding-left: 2px; }

/* ---------- Courbes d'une sortie ---------- */

.curves { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.curves-head { display: flex; justify-content: space-between; align-items: baseline; }
.curve-km { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.curve-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 12.5px; }
.curve-title { font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.curve-title::before { content: ''; width: 12px; height: 3px; border-radius: 2px; background: var(--cc); }
.curve-stats { color: var(--muted); }
.curve-now { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.curve-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.curve-svg .tick { fill: var(--muted); font-size: 10px; }
.curve-svg .cross { stroke: var(--muted); stroke-width: 1; }
.curve-line { fill: none; stroke: var(--cc); stroke-width: 1.8; stroke-linejoin: round; }
.curve-area { fill: color-mix(in srgb, var(--cc) 20%, transparent); stroke: none; }
.curve-dot { fill: var(--cc); stroke: var(--solid); stroke-width: 2; }
.c-alt { --cc: #eb6834; }
.c-hr { --cc: #e34948; }
.c-watts { --cc: #6a55d8; }
.c-pace { --cc: #2a78d6; }
.c-cad { --cc: #1baf7a; }
.curve-axis { display: flex; justify-content: space-between; padding-left: 40px; font-size: 11px; color: var(--muted); }

@media (max-width: 700px) {
  .roll-day { height: 116px; }
}

/* ---------- Thème « Verre » (par défaut) : dégradé violet → bleu, sphères floues, cartes en verre ---------- */

:root[data-theme="glass"] {
  color-scheme: dark;
  --bg: #7b7ccb;
  --page-bg: linear-gradient(180deg, #1d2758 0%, #3f4590 38%, #6c63b8 66%, #a77aa8 88%, #d4907f 100%);
  --surface: rgb(255 255 255 / .16);
  --solid: #3e3f8c;
  --text: #ffffff;
  --muted: rgb(255 255 255 / .76);
  --line: rgb(255 255 255 / .38);
  --accent: #8f83d8;
  --accent-soft: rgb(255 255 255 / .16);
  --other-day: rgb(255 255 255 / .07);
  --act: rgb(255 255 255 / .12);
  --act-line: rgb(255 255 255 / .85);
  --ok: #7ee8b8;
  --pending: #ffd166;
  --error: #ff8a8a;
  --error-soft: rgb(255 120 120 / .22);
  --series-1: #a9d1ff;
  --series-2: #ffb890;
  --series-3: #8ff0c3;
  --good: #6fe39a;
  --warning: #ffd166;
  --critical: #ff8a8a;
  --fresh: #a9d1ff;
  --z0: rgb(255 255 255 / .28);
  --z1: rgb(255 255 255 / .42);
  --z2: rgb(255 255 255 / .56);
  --z3: rgb(255 255 255 / .7);
  --z4: rgb(255 255 255 / .85);
  --z5: #ffffff;
  --t-long: #9fc5ff;
  --t-intense: #ffab85;
  --t-endurance: #7ee8b8;
  --t-tempo: #ffd166;
  --t-recovery: #ffa8cf;
  --t-hills: #c3b6ff;
  --shadow: 0 8px 30px rgb(30 20 90 / .22);
  --glass: blur(18px) saturate(1.15);
}
:root[data-theme="glass"] .card-panel, :root[data-theme="glass"] .tile, :root[data-theme="glass"] .ag-week,
:root[data-theme="glass"] .roll-day, :root[data-theme="glass"] .day, :root[data-theme="glass"] .week,
:root[data-theme="glass"] .pave, :root[data-theme="glass"] .ag-card, :root[data-theme="glass"] #alerts {
  background: rgb(255 255 255 / .14);
  border: 1px solid rgb(255 255 255 / .55);
  box-shadow: 0 8px 30px rgb(30 20 90 / .18), inset 0 1px 0 rgb(255 255 255 / .35);
}
:root[data-theme="glass"] .top { background: rgb(255 255 255 / .12); border-bottom-color: rgb(255 255 255 / .35); }
:root[data-theme="glass"] .top h1 { color: #fff; }
/* Verre un peu plus dense derrière les chiffres, pour la lisibilité au soleil. */
:root[data-theme="glass"] .tile, :root[data-theme="glass"] .pave { background: rgb(40 30 110 / .22); }
:root[data-theme="glass"] .tile.s-good, :root[data-theme="glass"] .tile.s-warning, :root[data-theme="glass"] .tile.s-critical,
:root[data-theme="glass"] .tile.s-fresh, :root[data-theme="glass"] .tile.s-neutral { background: color-mix(in srgb, var(--c) 22%, rgb(40 30 110 / .22)); }
:root[data-theme="glass"] .status-pill { background: rgb(255 255 255 / .16); border-color: color-mix(in srgb, var(--c) 70%, transparent); }
:root[data-theme="glass"] .pill-icon { color: #1c1f4a; }
:root[data-theme="glass"] .card.plan { background: color-mix(in srgb, var(--t) 30%, rgb(255 255 255 / .1)); }
:root[data-theme="glass"] .card.act { background: rgb(255 255 255 / .12); }
:root[data-theme="glass"] .card-type, :root[data-theme="glass"] .card-sum, :root[data-theme="glass"] .card-foot { color: rgb(255 255 255 / .8); }
:root[data-theme="glass"] .type-chip { color: #fff; background: color-mix(in srgb, var(--t) 35%, transparent); }
:root[data-theme="glass"] .badge { background: rgb(255 255 255 / .14); }
:root[data-theme="glass"] .badge.plan { color: #fff; border-color: rgb(255 255 255 / .55); }
:root[data-theme="glass"] .legend-chip { color: #fff; }
/* Contrôles : verre clair, texte blanc. */
:root[data-theme="glass"] input, :root[data-theme="glass"] select, :root[data-theme="glass"] textarea, :root[data-theme="glass"] button {
  background-color: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .45); color: #fff;
}
:root[data-theme="glass"] input::placeholder, :root[data-theme="glass"] textarea::placeholder { color: rgb(255 255 255 / .55); }
:root[data-theme="glass"] button:hover:not(:disabled) { border-color: #fff; }
:root[data-theme="glass"] button.primary { background: rgb(255 255 255 / .3); border-color: rgb(255 255 255 / .6); color: #fff; }
:root[data-theme="glass"] .segmented button[aria-pressed="true"], :root[data-theme="glass"] .nav-list a[aria-current="page"] { background: rgb(255 255 255 / .3); color: #fff; }
:root[data-theme="glass"] a { color: #fff; }
:root[data-theme="glass"] .links a { color: #fff; }
:root[data-theme="glass"] .tabs a { background: rgb(255 255 255 / .12); border-color: rgb(255 255 255 / .35); color: #fff; }
:root[data-theme="glass"] .tabs a[aria-current="page"] { background: rgb(255 255 255 / .32); border-color: rgb(255 255 255 / .7); }
:root[data-theme="glass"] button.linkish { color: #fff; }
:root[data-theme="glass"] .burger span { background: #fff; }
/* Fenêtres, menu, infobulles : fond dense pour lire. */
:root[data-theme="glass"] dialog, :root[data-theme="glass"] dialog.drawer, :root[data-theme="glass"] .drawer-head { background: linear-gradient(160deg, #4a48a0, #33367a); color: #fff; border-color: rgb(255 255 255 / .35); }
:root[data-theme="glass"] .chart-tip, :root[data-theme="glass"] pre, :root[data-theme="glass"] .stat, :root[data-theme="glass"] .act-link,
:root[data-theme="glass"] .ed-link, :root[data-theme="glass"] .block, :root[data-theme="glass"] .import-panel,
:root[data-theme="glass"] .focus-linked, :root[data-theme="glass"] .note, :root[data-theme="glass"] .ag-head, :root[data-theme="glass"] .drawer-head {
  background: rgb(255 255 255 / .1);
}
:root[data-theme="glass"] .drawer-head { background: transparent; }
:root[data-theme="glass"] .chart-tip { background: #3e3f8c; }
:root[data-theme="glass"] .ag-pill { background: #fff; color: #33367a; }
:root[data-theme="glass"] .ag-day.today .ag-date b, :root[data-theme="glass"] .roll-check, :root[data-theme="glass"] .ag-check { background: #fff; color: #33367a; }
:root[data-theme="glass"] .goal-card { background: linear-gradient(135deg, rgb(255 255 255 / .28), rgb(255 255 255 / .1)); border: 1px solid rgb(255 255 255 / .6); box-shadow: 0 8px 30px rgb(30 20 90 / .22); }
:root[data-theme="glass"] .chart .grid { stroke: rgb(255 255 255 / .22); }
:root[data-theme="glass"] .chart .zero, :root[data-theme="glass"] .chart .today-line { stroke: rgb(255 255 255 / .8); }
:root[data-theme="glass"] .chart .goal-line { stroke: #fff; }
:root[data-theme="glass"] .curve-dot, :root[data-theme="glass"] .chart .dot-ctl, :root[data-theme="glass"] .chart .dot-atl, :root[data-theme="glass"] .chart .dot-tsb { stroke: #3e3f8c; }
:root[data-theme="glass"] .c-alt { --cc: #ffb890; }
:root[data-theme="glass"] .c-hr { --cc: #ff8a8a; }
:root[data-theme="glass"] .c-watts { --cc: #c3b6ff; }
:root[data-theme="glass"] .c-pace { --cc: #a9d1ff; }
:root[data-theme="glass"] .c-cad { --cc: #8ff0c3; }
:root[data-theme="glass"] .ybar { background: #a9d1ff; }
:root[data-theme="glass"] .ybars.dplus .ybar { background: #c3b6ff; }
:root[data-theme="glass"] table.zones th, :root[data-theme="glass"] table.zones td, :root[data-theme="glass"] table.totals th, :root[data-theme="glass"] table.totals td { border-color: rgb(255 255 255 / .25); }
:root[data-theme="glass"] .login-box { background: rgb(255 255 255 / .14); border-color: rgb(255 255 255 / .55); -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass); }
:root[data-theme="glass"] .login-box h1 { color: #fff; }
:root[data-theme="glass"] #toast { background: #fff; color: #33367a; }
:root[data-theme="glass"] #toast.error { background: #ff8a8a; color: #3b0d0d; }
/* Contrôles Leaflet : ils restent sur fond blanc, texte sombre. */
:root[data-theme="glass"] .leaflet-bar a, :root[data-theme="glass"] .leaflet-control-attribution, :root[data-theme="glass"] .leaflet-control-attribution a,
:root[data-theme="glass"] .leaflet-control-layers, :root[data-theme="glass"] .leaflet-control-layers label { color: #333; }

/* ---------- Comptes ---------- */

.menu-user { margin: 0 0 6px; padding: 8px 12px; border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; }
.key-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.key-form input { flex: 1; min-width: 200px; }
.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.user-row.inactive { opacity: .6; }
.user-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.temp-password { border-color: var(--accent); }
.temp-code { display: block; margin: 8px 0; padding: 10px 14px; border-radius: 10px; background: var(--solid); color: #fff; font-size: 22px; letter-spacing: .08em; font-family: ui-monospace, monospace; user-select: all; }
/* Listes déroulantes ouvertes : fond sombre explicite (sinon blanc sur blanc sur certains navigateurs). */
:root[data-theme="glass"] option, :root[data-theme="glass"] optgroup { background: #3e3f8c; color: #fff; }
:root[data-theme="glass"] select { background-color: rgb(62 63 140 / .75); }

/* ---------- Fond « crêtes au crépuscule » (thème Verre) et « nuit » (thème Sombre) ---------- */

:root[data-theme="glass"] body, :root[data-theme="dark"] body { position: relative; isolation: isolate; }
/* Halo de soleil (ou de lune), bas, derrière la crête la plus lointaine. */
:root[data-theme="glass"] body::before, :root[data-theme="dark"] body::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  left: 22vw; bottom: 18vh; width: 46vmin; height: 46vmin; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 214 170 / .55) 0%, rgb(255 190 150 / .22) 35%, transparent 70%);
}
:root[data-theme="dark"] body::before { left: auto; right: 14vw; bottom: 34vh; width: 22vmin; height: 22vmin;
  background: radial-gradient(circle, rgb(220 230 255 / .55) 0%, rgb(190 205 255 / .18) 40%, transparent 70%); }
/* Trois lignes de crêtes, de plus en plus proches et denses. */
:root[data-theme="glass"] body::after, :root[data-theme="dark"] body::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none; left: 0; right: 0; bottom: 0; height: 40vh;
  background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 1440 420%22 preserveAspectRatio=%22xMidYMax slice%22%3E%3Cpath fill=%22rgb(38,32,96,0.42)%22 d=%22M0 300 L120 250 L210 275 L330 190 L420 230 L520 160 L640 240 L760 200 L880 250 L1000 180 L1110 230 L1230 205 L1340 250 L1440 215 L1440 420 L0 420 Z%22/%3E%3Cpath fill=%22rgb(30,26,82,0.62)%22 d=%22M0 340 L90 315 L180 335 L300 280 L390 300 L470 262 L590 320 L700 290 L820 330 L930 275 L1050 305 L1170 285 L1290 325 L1440 290 L1440 420 L0 420 Z%22/%3E%3Cpath fill=%22rgb(22,20,64,0.85)%22 d=%22M0 385 L110 365 L230 380 L350 345 L460 365 L580 335 L700 370 L840 350 L960 378 L1080 345 L1200 365 L1320 350 L1440 372 L1440 420 L0 420 Z%22/%3E%3C/svg%3E") bottom center / cover no-repeat;
}
:root[data-theme="dark"] { --page-bg: linear-gradient(180deg, #05080f 0%, #0b1424 45%, #14213c 80%, #1d2b4a 100%); }
:root[data-theme="dark"] body::after {
  background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 1440 420%22 preserveAspectRatio=%22xMidYMax slice%22%3E%3Cpath fill=%22rgb(70,90,130,0.35)%22 d=%22M0 300 L120 250 L210 275 L330 190 L420 230 L520 160 L640 240 L760 200 L880 250 L1000 180 L1110 230 L1230 205 L1340 250 L1440 215 L1440 420 L0 420 Z%22/%3E%3Cpath fill=%22rgb(45,62,98,0.6)%22 d=%22M0 340 L90 315 L180 335 L300 280 L390 300 L470 262 L590 320 L700 290 L820 330 L930 275 L1050 305 L1170 285 L1290 325 L1440 290 L1440 420 L0 420 Z%22/%3E%3Cpath fill=%22rgb(22,32,56,0.9)%22 d=%22M0 385 L110 365 L230 380 L350 345 L460 365 L580 335 L700 370 L840 350 L960 378 L1080 345 L1200 365 L1320 350 L1440 372 L1440 420 L0 420 Z%22/%3E%3C/svg%3E") bottom center / cover no-repeat;
}
@media (max-width: 700px) {
  :root[data-theme="glass"] body::after, :root[data-theme="dark"] body::after { height: 30vh; }
  :root[data-theme="glass"] body::before { left: 10vw; bottom: 14vh; width: 60vmin; height: 60vmin; }
}
/* Aujourd'hui : pastille blanche et liseré blanc, visibles sur le verre. */
:root[data-theme="glass"] .roll-day.today, :root[data-theme="glass"] .day.today, :root[data-theme="glass"] .ag-week.current {
  border: 2px solid #fff; box-shadow: 0 0 0 4px rgb(255 255 255 / .22), 0 8px 30px rgb(30 20 90 / .25), inset 0 1px 0 rgb(255 255 255 / .35);
}
:root[data-theme="glass"] .roll-day.today .roll-date span, :root[data-theme="glass"] .roll-day.today .roll-date .roll-month { color: #fff; }
:root[data-theme="glass"] .roll-day.today .roll-date b, :root[data-theme="glass"] .day.today .day-num {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: #fff; color: #33367a; font-weight: 800; font-size: 15px;
}
:root[data-theme="glass"] .day.today .day-num .wd { color: #33367a; }
:root[data-theme="glass"] .roll-day[aria-current="date"] { background: rgb(255 255 255 / .26); }

/* Étapes : longueur et cible au choix. */
.step select { max-width: 130px; }
.pace { width: 62px; text-align: center; }
.run-block { display: flex; flex-direction: column; gap: 6px; }
#editor-form .run-block > .elev { flex-direction: row; align-items: center; gap: 6px; }

/* ---------- Éditeur : boucles ---------- */

.b-intense, .b-climb { border-left-color: var(--repeat); }
.b-flat { border-left-color: var(--series-1); }
.b-descent { border-left-color: var(--series-3); }
.b-rest, .b-chair { border-left-color: var(--recovery); }
.block.loop { border-left: 4px solid var(--accent); gap: 8px; }
.loop-title { font-size: 14px; }
.loop-steps { display: flex; flex-direction: column; gap: 6px; padding-left: 10px; border-left: 2px dashed var(--line); }
.loop-steps .block { padding: 6px 8px; }
.loop-add { font-size: 12px; }
.loop-add button { padding: 2px 8px; font-size: 12px; }
.add-loop { font-weight: 700; }
.dup-loop { font-size: 12.5px; }

/* ---------- Présentation d'une séance ---------- */

.outline { display: flex; flex-direction: column; gap: 10px; }
.ol-section h4 { margin: 0 0 6px; font-size: 15px; }
.ol-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ol-section .ol-row:last-child { border-bottom: none; }
.ol-pill {
  flex: none; min-width: 64px; padding: 2px 10px; border-radius: 8px; text-align: center; font-weight: 700; font-size: 14px;
  background: color-mix(in srgb, var(--warning) 45%, transparent); color: var(--text);
}
.ol-reps { min-width: 48px; border-radius: 999px; padding: 10px 8px; align-self: center; }
.ol-steps { display: flex; flex-direction: column; gap: 4px; }
.ol-step { display: flex; gap: 8px; align-items: baseline; }
.ol-icon { width: 22px; text-align: center; color: var(--muted); font-size: 12px; }
.ol-text b { font-weight: 800; }
.focus-outline { font-size: 14px; }
.focus-card .ol-row { border-color: rgb(255 255 255 / .2); }
.focus-card .ol-pill { background: rgb(255 255 255 / .22); color: #fff; }
.focus-card .ol-icon { color: rgb(255 255 255 / .8); }
.roll-today { padding: 2px 10px; font-size: 12.5px; font-weight: 700; }

/* Glisser-déposer des étapes : poignée, élément tenu, emplacement d'arrivée. */
button.icon.drag { cursor: grab; touch-action: none; user-select: none; padding: 2px 6px; }
.block.dragging { position: relative; z-index: 5; opacity: .75; pointer-events: none; box-shadow: var(--shadow); }
.drop-marker { height: 4px; margin: -1px 0; border-radius: 2px; background: var(--accent); }

/* Courses (Profil) */
.races-panel { margin-top: 12px; }
#races-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.race-row { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 8px 10px; }
.race-row.past { opacity: .6; }
.race-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.prio { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 700; color: #fff; flex: none; }
.prio-A { background: var(--critical); }
.prio-B { background: var(--warning); }
.prio-C { background: #6b7a90; }
#race-editor { width: min(640px, calc(100vw - 32px)); }
#race-form { padding: 16px; }
#race-analysis .analysis { margin-top: 4px; }
/* Fiche course : une ligne par jour (départ, distance, D+). */
#race-days { display: grid; gap: 8px; }
.race-day { align-items: flex-end; }
.race-day > label { flex: 1 1 88px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.race-day-n { flex-basis: 100%; font-size: 13px; font-weight: 600; }
#race-days .unit { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#race-days .unit input { width: 100%; min-width: 0; }
/* Réglages du plan */
fieldset.days { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; }
fieldset.days legend { padding: 0 4px; font-size: 13px; color: var(--muted); }
fieldset.sports { flex-direction: column; flex-wrap: nowrap; }
fieldset.sports p { margin: 0; }
.sport-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.sport-row > .chk { flex: 0 0 15em; }
.sport-row select { max-width: 100%; }
.other-row input[type=text] { flex: 0 1 11em; min-width: 0; }
.other-days { display: flex; flex-wrap: wrap; gap: 2px 10px; flex: 1 1 100%; }
.other-row + .other-row { border-top: 1px solid var(--line); padding-top: 8px; }
/* Séance lointaine pas encore envoyée : neutre, ce n'est pas un retard. */
.st-scheduled .dot { background: var(--muted); }
.status.st-scheduled { color: var(--muted); }

/* Plan d'entraînement : import et aperçu */
#import-text { width: 100%; font-family: ui-monospace, monospace; font-size: 13px; }
.file-btn { cursor: pointer; }
.import-errors { border: 1px solid var(--critical); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.import-errors ul, .import-warnings ul { margin: 6px 0 0; padding-left: 20px; }
.import-errors li { color: var(--critical); }
.import-warnings { border: 1px solid var(--warning); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.plan-preview h3 { margin: 12px 0 2px; }
.plan-logic { white-space: pre-line; }
.preview-weeks { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.pw-week { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pw-week.shock { border-color: var(--warning); }
.pw-week.compact { padding: 4px 10px; }
.pw-week.current { border-color: var(--accent); border-width: 2px; }
.pw-week.past { opacity: .6; }
.pw-session { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px dashed var(--line); }
.pw-date { white-space: nowrap; }
.pw-main { display: flex; flex-direction: column; min-width: 0; }
.pw-meta { white-space: nowrap; }
@media (max-width: 560px) { .pw-session { grid-template-columns: 1fr; gap: 0; } }

/* Plan préparé par l'IA locale (ialocal) */
.ai-box { border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin: 4px 0 10px; }
.ai-box.error { border-color: var(--critical); }
.ai-box p { margin: 4px 0; }
.ai-progress { font-weight: 600; overflow-wrap: anywhere; }
.ai-answer pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; font-size: 12px; margin: 6px 0; }

/* Suivi du plan : cadre → réalisé */
.fw-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.fw-cell.low b:last-of-type { color: var(--critical); }
.fw-cell.high b:last-of-type { color: var(--warning); }
.fw-cell.ok b:last-of-type { color: var(--good); }
.adjust-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.climb-stats { margin-top: 8px; }

/* Éditeur : actions repliées (⋯) et ajout en liste sur téléphone, boutons sur ordinateur. */
.mob-only { display: none !important; }
details.more { position: relative; }
details.more > summary { list-style: none; padding: 4px 12px; font-size: 18px; line-height: 1.2; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
details.more > summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; gap: 2px; min-width: 170px;
  padding: 6px; background: var(--solid, var(--bg)); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.more-menu button { text-align: left; }
.add-menu > summary { list-style: none; display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; }
.add-menu > summary::-webkit-details-marker { display: none; }
.add-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.acts { display: inline-flex; gap: 6px; align-items: center; }

@media (max-width: 700px) {
  .mob-only { display: revert !important; }
  details.mob-only { display: block !important; }
  .desk-only { display: none !important; }
  dialog#editor { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: none; border-radius: 0; }
  #editor-form { padding: 0 10px 10px; gap: 8px; }
  #editor .ed-head { position: sticky; top: 0; z-index: 10; margin: 0 -10px; padding: 8px 10px; align-items: center; gap: 8px;
    background: var(--solid, var(--bg)); border-bottom: 1px solid var(--line); }
  #editor .ed-head h2 { flex: 1; font-size: 16px; min-width: 0; }
  #editor .ed-head .status { display: none; }
  #editor .ed-total { position: sticky; bottom: 0; z-index: 9; margin: 0 -10px; padding: 8px 10px; font-size: 14px;
    background: var(--solid, var(--bg)); border-top: 1px solid var(--line); }
  #editor .block { padding: 6px 8px; }
  #editor .block-head { gap: 6px; }
  #editor .block-head > select { flex: 1; min-width: 0; width: auto; max-width: none; }
  #editor .block-head > .spacer { display: none; }
  #editor .block-head > details.more { margin-left: auto; }
  #editor .loop-steps { padding-left: 4px; }
  #editor .loop-steps .block { padding: 6px; }
  #editor .loop-title { white-space: nowrap; }
  #editor .step { gap: 6px 10px; }
  /* Cible : la zone sur toute la largeur, puis min – max et l'unité, puis l'indication. */
  #editor .target { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 6px; width: 100%; }
  #editor .target > select, #editor .target > .hint { grid-column: 1 / -1; width: 100%; max-width: none; }
  #editor .target > input { width: 100%; min-width: 0; }
  #editor .ed-total { font-size: 13px; }
  #editor .ed-row > label { flex: 1 1 140px; }
  #editor .ed-foot { flex-wrap: wrap; gap: 8px; }
}

/* Réglages du plan : montées (durée, D+, lieux) */
fieldset.climbs label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
fieldset.climbs label.wide { flex: 1 1 100%; }
fieldset.climbs input[type=number] { width: 90px; }

.big-import { display: block; text-align: center; padding: 14px; font-size: 16px; font-weight: 600; margin: 6px 0; cursor: pointer;
  background: var(--accent); color: #fff; border: none; border-radius: 8px; }
#import-paste { margin-top: 6px; }

/* Calendrier du mois : séances au style de la vue semaine par semaine (carte plus
   opaque, liseré de la couleur du type de séance), case semaine d'une autre teinte. */
.card.plan { border-left: 5px solid var(--g1, var(--t)); background: var(--bg); }
.card.plan.st-error { border-left-color: var(--g1, var(--t)); box-shadow: inset 0 0 0 1px var(--error); }
.week { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-left: 4px solid var(--accent); }
:root[data-theme="glass"] .card.plan { background: rgb(30 22 95 / .42); border-color: rgb(255 255 255 / .3); border-left-color: var(--g1, var(--t)); }
:root[data-theme="glass"] .card.act { background: rgb(255 255 255 / .2); }
:root[data-theme="glass"] .week { background: rgb(20 14 70 / .32); border: 1px solid rgb(255 255 255 / .35); border-left: 4px solid rgb(255 255 255 / .75); }
@media (max-width: 700px) {
  .week { border-left-width: 1px; }
  :root[data-theme="glass"] .week { border-left-width: 1px; }
}
:root[data-theme="glass"] .big-import { background: rgb(255 255 255 / .88); color: #2f2f7a; border: none; }
