/* Polices auto-hébergées (facultatif : lancer scripts/get-fonts.sh). Sans les fichiers, les polices système prennent le relais. */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("/fonts/barlow-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url("/fonts/barlow-condensed-latin-800-normal.woff2") format("woff2"); }
:root { color-scheme: light; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
footer.foot { text-align: center; font-size: 12px; color: var(--ink-3); padding-block: 8px 24px; }
/* Concept : un carnet de course. Le dossard (compte à rebours) est le seul élément fort ; le reste est une grille calme de lignes de séance. */
:root {
  --bg: #EDF0F4; --surface: #FBFCFD; --surface-2: #F1F4F8;
  --ink: #10151C; --ink-2: #47525F; --ink-3: #6B7684;
  --line: #DCE1E8; --line-2: #C2CAD4;
  --accent: #2456D6; --accent-ink: #FFFFFF; --accent-soft: #D9E4FB; --accent-text: #1C47B8;
  --race: #E8642C; --hi: #F6C700; --hi-ink: #231C00;
  --good: #0CA30C; --good-text: #0B6B1F; --good-soft: #DDF3DF;
  --warn: #FAB219; --warn-text: #7A5200; --warn-soft: #FCEFCB;
  --crit: #D03B3B; --crit-text: #A82626; --crit-soft: #F9DFDF;
  --bib-bg: #FFFFFF; --bib-ink: #10151C;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1216; --surface: #171B21; --surface-2: #1E242C;
    --ink: #F1F4F8; --ink-2: #B7C0CC; --ink-3: #8C97A6;
    --line: #2A323D; --line-2: #3B4553;
    --accent: #5B8DF5; --accent-ink: #0B1220; --accent-soft: #22345A; --accent-text: #8FB0FA;
    --race: #E0703C; --hi: #F6C700; --hi-ink: #231C00;
    --good: #0CA30C; --good-text: #58CF63; --good-soft: #15321A;
    --warn: #FAB219; --warn-text: #F5C458; --warn-soft: #3A2E10;
    --crit: #D03B3B; --crit-text: #F08B8B; --crit-soft: #3B1A1A;
    --bib-bg: #F4F6F9; --bib-ink: #10151C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1216; --surface: #171B21; --surface-2: #1E242C;
  --ink: #F1F4F8; --ink-2: #B7C0CC; --ink-3: #8C97A6;
  --line: #2A323D; --line-2: #3B4553;
  --accent: #5B8DF5; --accent-ink: #0B1220; --accent-soft: #22345A; --accent-text: #8FB0FA;
  --race: #E0703C; --hi: #F6C700; --hi-ink: #231C00;
  --good: #0CA30C; --good-text: #58CF63; --good-soft: #15321A;
  --warn: #FAB219; --warn-text: #F5C458; --warn-soft: #3A2E10;
  --crit: #D03B3B; --crit-text: #F08B8B; --crit-soft: #3B1A1A;
  --bib-bg: #F4F6F9; --bib-ink: #10151C;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; text-wrap: balance; letter-spacing: .01em; line-height: 1.05; }
h2 { font-size: 26px; text-transform: uppercase; }
h3 { font-size: 20px; text-transform: uppercase; }
h4 { font-size: 14px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.app { max-width: 1120px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 64px; display: flex; flex-direction: column; gap: 18px; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack-s { display: flex; flex-direction: column; gap: 6px; } .stack-l { display: flex; flex-direction: column; gap: 22px; }
.grow { flex: 1 1 0; min-width: 0; }

/* En-tête et dossard */
.top { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.bib { position: relative; background: var(--bib-bg); color: var(--bib-ink); border: 1px solid var(--line-2); border-radius: 7px; width: 168px; flex: none; text-align: center; padding-bottom: 9px; overflow: hidden; }
.bib-top { background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; padding: 7px 18px 6px; }
.bib-num { font-family: var(--f-display); font-weight: 800; font-size: 76px; line-height: .92; padding-top: 6px; letter-spacing: -.01em; }
.bib-sub { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.bib i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-2); }
.bib i:nth-of-type(1) { left: 6px; top: 31px; } .bib i:nth-of-type(2) { right: 6px; top: 31px; } .bib i:nth-of-type(3) { left: 6px; bottom: 6px; } .bib i:nth-of-type(4) { right: 6px; bottom: 6px; }
.top h1 { font-size: 44px; text-transform: uppercase; font-weight: 800; }
.top .facts { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--ink-2); font-size: 14px; }
.top .facts b { color: var(--ink); font-weight: 600; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.sync.ok::before { background: var(--good); } .sync.err::before { background: var(--crit); }

/* Onglets */
.tabs { position: sticky; scroll-behavior: auto; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line-2); scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 12px 9px; font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Blocs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card.flat { background: none; border-style: dashed; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .v { font-family: var(--f-display); font-weight: 700; font-size: 34px; line-height: 1; }
.tile .v small { font-size: 16px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.tile .l { font-size: 13px; color: var(--ink-2); }
.tile .d { font-size: 12px; color: var(--ink-3); }
.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Boutons et formulaires */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit-text); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); min-width: 0; }
label.f small { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=date], input[type=number], select, textarea { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; font-weight: 400; color: var(--ink); }
textarea { min-height: 76px; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.days span { display: grid; place-items: center; width: 42px; height: 36px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--surface); }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Lignes de séance */
.sess { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 4px; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }
.sess:first-child { border-top: 0; }
.sess:hover { background: var(--surface-2); }
.sess .dt { text-align: center; line-height: 1.05; }
.sess .dt b { display: block; font-family: var(--f-display); font-size: 24px; font-weight: 700; }
.sess .dt span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.sess .tt { font-weight: 600; }
.sess .dd { font-size: 13px; color: var(--ink-2); }
.sess .km { font-family: var(--f-display); font-size: 24px; font-weight: 700; text-align: right; line-height: 1; white-space: nowrap; }
.sess .km small { font-size: 13px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.sess .side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.sess.is-today { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.kind { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--ink-2); margin-right: 6px; vertical-align: 1px; }
.kind.quality { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.kind.long { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.kind.race { background: var(--hi); border-color: var(--hi); color: var(--hi-ink); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip svg { width: 11px; height: 11px; flex: none; }
.chip.done { background: var(--good-soft); color: var(--good-text); }
.chip.partial { background: var(--warn-soft); color: var(--warn-text); }
.chip.missed, .chip.skipped { background: var(--crit-soft); color: var(--crit-text); }
.chip.today { background: var(--accent); color: var(--accent-ink); }
.chip.race { background: var(--hi); color: var(--hi-ink); }
.pace { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Semaine */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.strip > div { border: 1px solid var(--line); border-radius: 7px; padding: 6px 2px; text-align: center; min-width: 0; background: var(--surface); }
.strip .d { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.strip .k { font-family: var(--f-display); font-size: 20px; font-weight: 700; line-height: 1.1; }
.strip .s { font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .is-today { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.strip .st-done { background: var(--good-soft); border-color: transparent; }
.strip .st-missed, .strip .st-skipped { background: var(--crit-soft); border-color: transparent; }
.strip .st-partial { background: var(--warn-soft); border-color: transparent; }
details.week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
details.week[open] { border-color: var(--line-2); }
details.week > summary { list-style: none; cursor: pointer; display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
details.week > summary::-webkit-details-marker { display: none; }
details.week .wn { font-family: var(--f-display); font-size: 24px; font-weight: 700; min-width: 44px; }
details.week .wk { font-family: var(--f-display); font-size: 22px; font-weight: 700; white-space: nowrap; }
details.week .wk small { font-size: 13px; color: var(--ink-3); font-weight: 600; }
details.week .body { padding: 0 12px 6px; }
details.week.cur { border-color: var(--accent); }
details.week.past > summary { color: var(--ink-2); }
.phases { display: flex; gap: 3px; }
.phases > div { min-width: 0; padding: 8px 10px; border-radius: 6px; color: #fff; }
.phases b { display: block; font-family: var(--f-display); font-size: 17px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phases span { font-size: 12px; opacity: .9; white-space: nowrap; }
.ph-base { background: #5E86DD; } .ph-dev { background: #3A68D2; } .ph-spec { background: #2449B0; } .ph-taper { background: #172F7A; }

/* Messages */
.note { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 11px 12px; border-radius: 8px; background: var(--surface-2); align-items: start; }
.note svg { width: 20px; height: 20px; margin-top: 1px; color: var(--ink-3); }
.note b { display: block; }
.note.crit { background: var(--crit-soft); } .note.crit svg { color: var(--crit-text); }
.note.warn { background: var(--warn-soft); } .note.warn svg { color: var(--warn-text); }
.note.good { background: var(--good-soft); } .note.good svg { color: var(--good-text); }
.note .btn { margin-top: 8px; }

/* Tableaux */
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 7px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.hl td { background: var(--accent-soft); }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }

/* Graphiques */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f-body); font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
#tip { position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12px; line-height: 1.4; padding: 7px 9px; border-radius: 6px; max-width: 240px; }
#tip b { font-weight: 600; }

/* Fenêtre et notifications */
dialog { border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(8, 12, 18, .55); }
dialog form, dialog .dbody { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog .foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 0; border-top: 1px solid var(--line); }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 40; max-width: calc(100vw - 32px); }
.prose { max-width: 68ch; } .prose p + p { margin-top: 8px; }
ul.clean { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.check { display: flex; gap: 9px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.empty { text-align: center; color: var(--ink-3); padding: 26px 12px; }
@media (max-width: 560px) {
  .top h1 { font-size: 34px; }
  .bib { width: 132px; } .bib-num { font-size: 58px; }
  .sess { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; }
  .card { padding: 14px; }
  .phases span { display: none; }
}
@media (prefers-reduced-motion: no-preference) { .meter > span { transition: width .3s; } }
