/* Jetons de l'ancien « Tableau de bord Robin » : mêmes couleurs par catégorie, un seul accent. */
:root {
  --bg: #eef1f1; --surface: #fbfcfc; --surface-2: #f3f6f6; --ink: #14202b; --ink-2: #465462; --muted: #66737e;
  --line: #d8dfe2; --line-2: #c3ccd1; --accent: #0d6b80; --accent-ink: #ffffff; --accent-soft: #d9edf1;
  --good: #0a7d0a; --warn: #9a6500; --crit: #c23434; --good-bg: #e3f3e3; --warn-bg: #fbefd6; --crit-bg: #f9e1e1;
  --c-cours: #2a78d6; --c-perso: #4a3aa7; --c-element: #eb6834; --c-muscu: #1baf7a; --c-course: #d55181;
  --c-travail: #7a6a1f; --c-autre: #898781;
  --band: rgba(20, 32, 43, .07);
  --z1: #e698ba; --z2: #d86a9a; --z3: #c0477c; --z4: #98315f; --z5: #661e3f;
  --r: 10px; --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1214; --surface: #151b1e; --surface-2: #1b2327; --ink: #edf2f4; --ink-2: #b4c0c7; --muted: #8d9aa2;
    --line: #253035; --line-2: #334047; --accent: #45b3cb; --accent-ink: #071417; --accent-soft: #163038;
    --good: #3cc23c; --warn: #f0ad2a; --crit: #ef6b6b; --good-bg: #132a15; --warn-bg: #2d2412; --crit-bg: #331717;
    --c-cours: #3987e5; --c-perso: #9085e9; --c-element: #d95926; --c-muscu: #199e70; --c-course: #d55181;
    --c-travail: #c9b458; --c-autre: #898781;
    --band: rgba(237, 242, 244, .08);
    --z1: #853359; --z2: #ab4675; --z3: #d06396; --z4: #e78fb7; --z5: #f6c3da;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1214; --surface: #151b1e; --surface-2: #1b2327; --ink: #edf2f4; --ink-2: #b4c0c7; --muted: #8d9aa2;
  --line: #253035; --line-2: #334047; --accent: #45b3cb; --accent-ink: #071417; --accent-soft: #163038;
  --good: #3cc23c; --warn: #f0ad2a; --crit: #ef6b6b; --good-bg: #132a15; --warn-bg: #2d2412; --crit-bg: #331717;
  --c-cours: #3987e5; --c-perso: #9085e9; --c-element: #d95926; --c-muscu: #199e70; --c-course: #d55181;
  --c-travail: #c9b458; --c-autre: #898781;
  color-scheme: dark;
}

/* Taille de texte : suit le réglage « Taille du texte » de l'iPhone (Dynamic Type). */
html { font: -apple-system-body; font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
@supports not (font: -apple-system-body) { html { font-size: 17px; } }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }

/* Structure */
.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; padding: calc(var(--safe-t) + 8px) 16px calc(76px + var(--safe-b)); }
.top { display: flex; align-items: center; gap: 8px; padding: 8px 0 12px; }
.top h1 { font-size: 1.6rem; font-weight: 700; flex: 1; }
.top .date { color: var(--muted); font-size: .85rem; font-weight: 500; }
.iconbtn { min-width: var(--tap); min-height: var(--tap); border: 0; border-radius: 50%; background: var(--surface); color: var(--accent);
  display: inline-grid; place-items: center; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: var(--safe-b); z-index: 10; }
.tabs a { min-height: 56px; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted);
  text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--accent); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card > h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; }
.card > h2 .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.empty { color: var(--muted); padding: 4px 0; }

.banner { border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; border: 1px solid; }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner.crit { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* État du corps */
.light { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot.vert { background: #1e9e3a; } .dot.orange { background: #f08a00; } .dot.rouge { background: #d93030; } .dot.gris { background: var(--line-2); }
.light strong { font-size: 1.15rem; }
.signals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.signal { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; border-left: 3px solid var(--line-2); }
.signal.alerte { border-left-color: #f08a00; } .signal.forte { border-left-color: var(--crit); } .signal.ok { border-left-color: var(--good); }
.signal .lab { font-size: .75rem; color: var(--muted); font-weight: 600; }
.signal .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.signal .ref { font-size: .75rem; color: var(--ink-2); }
details.info { margin-top: 8px; font-size: .85rem; color: var(--ink-2); }
details.info summary { cursor: pointer; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; }

/* Séance */
.session-title { font-size: 1.1rem; font-weight: 700; }
.session-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--surface-2);
  color: var(--ink-2); border: 1px solid var(--line); vertical-align: middle; }
.chip.coach { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.steps { margin: 8px 0 0; padding: 0; list-style: none; font-size: .92rem; }
.steps li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.steps li:first-child { border-top: 0; }
.steps .what { flex: 1; } .steps .how { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.why { margin-top: 8px; font-size: .88rem; color: var(--ink-2); }
s { color: var(--muted); }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-height: 76px; }
.kpi .lab { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kpi .val { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .val.crit { color: var(--crit); }
.kpi .sub { font-size: .75rem; color: var(--ink-2); }

/* Listes d'agenda */
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: grid; grid-template-columns: 52px 4px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start; }
.items li:first-child { border-top: 0; }
.items .t { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--ink-2); padding-top: 1px; }
.items .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--cc, var(--c-autre)); }
.items .ttl { font-weight: 600; }
.items .sub { font-size: .82rem; color: var(--ink-2); }
.cat-cours { --cc: var(--c-cours); } .cat-perso { --cc: var(--c-perso); } .cat-element { --cc: var(--c-element); }
.cat-muscu { --cc: var(--c-muscu); } .cat-course { --cc: var(--c-course); } .cat-travail { --cc: var(--c-travail); } .cat-autre { --cc: var(--c-autre); }
.countdown { font-weight: 700; font-variant-numeric: tabular-nums; }
.countdown.soon { color: var(--crit); }

.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 6px 0 12px; }

/* Boutons et formulaires */
.btn { min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface);
  font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); padding: 0 12px; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 80px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* Feuille (ajout rapide) */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 20; display: grid; align-items: end; }
.sheet { background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); max-height: 92dvh; overflow: auto;
  max-width: 640px; width: 100%; margin: 0 auto; }
.sheet h2 { font-size: 1.15rem; margin-bottom: 12px; }

/* Agenda (grille) */
.nav { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.nav .lbl { flex: 1; text-align: center; font-weight: 700; }
.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: calc(100dvh - 250px); }
.grid { display: grid; position: relative; }
.grid .hours { position: relative; }
.grid .hour { height: var(--hh); font-size: .66rem; color: var(--muted); text-align: right; padding-right: 4px; transform: translateY(-.5em); font-variant-numeric: tabular-nums; }
.grid .col { position: relative; border-left: 1px solid var(--line); background:
  repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hh) - 1px), var(--line) calc(var(--hh) - 1px), var(--line) var(--hh)); }
.grid .head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line);
  text-align: center; font-size: .72rem; font-weight: 700; padding: 6px 0; color: var(--ink-2); }
.grid .head.today { color: var(--accent); }
.ev { position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 2px 4px; font-size: .68rem; line-height: 1.2; overflow: hidden;
  background: color-mix(in srgb, var(--cc) 18%, var(--surface)); border-left: 3px solid var(--cc); color: var(--ink); cursor: pointer; }
.ev.coach { background: color-mix(in srgb, var(--cc) 30%, var(--surface)); font-weight: 700; }
.ev.ghost { background: transparent; border: 1px dashed var(--cc); text-decoration: line-through; color: var(--muted); }
.ev.allday { position: static; margin: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-weight: 600; text-align: left; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--crit); z-index: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .75rem; color: var(--ink-2); margin: 8px 0; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--cc); margin-right: 5px; vertical-align: -1px; }

/* Connexion */
.login { max-width: 420px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { font-size: 2rem; margin-bottom: 4px; }
.err { color: var(--crit); font-size: .9rem; margin: 6px 0; }

.items .t { white-space: pre-line; }

/* Graphiques */
.chart-sub { margin: -2px 0 8px; font-size: .85rem; color: var(--ink-2); }
.chart-box { position: relative; width: 100%; min-width: 0; }
.chart-note { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }
.spark { position: relative; height: 26px; margin-top: 4px; width: 100%; min-width: 0; overflow: hidden; }
.signal { min-width: 0; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; border-radius: 3px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.stat .lab { font-size: .72rem; color: var(--muted); font-weight: 700; }
.stat .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .72rem; color: var(--ink-2); }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: .72rem; color: var(--muted); font-weight: 700; padding: 4px 4px 6px 0; }
.table td { border-top: 1px solid var(--line); padding: 7px 4px 7px 0; vertical-align: top; }
.table .r { text-align: right; }
.rir { display: flex; gap: 4px; flex-wrap: wrap; }
.rir button { min-width: 40px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; cursor: pointer; }
.rir button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.setrow { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.setrow .rir { flex-wrap: nowrap; } .setrow .rir button { flex: 1; min-height: 44px; }
.setrow .load { display: flex; gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }
.setrow input { width: 58px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); text-align: center; }
.exo { margin-top: 14px; }
.exo h3 { font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.exo select { min-height: 40px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 40px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); font-weight: 700; }

.vol-row { display: grid; grid-template-columns: 84px 1fr 26px 22px; gap: 8px; align-items: center; padding: 3px 0; font-size: .82rem; }
.vol-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.vol-zone { position: absolute; top: 0; bottom: 0; background: var(--band); outline: 1px solid var(--line-2); }
.vol-bar { position: absolute; top: 3px; bottom: 3px; left: 0; background: var(--c-muscu); border-radius: 0 4px 4px 0; }
.vol-n { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.vol-prev { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.table .nw { white-space: nowrap; }
