/* MY FIT 365 — mobile d'abord, puis ordinateur (≥ 900 px).
   Thème sombre par défaut ; thème clair si le téléphone ou l'ordinateur est réglé en clair. */
:root {
  --bg: #10151c;
  --card: #181f29;
  --card-2: #202833;
  --border: #2c3644;
  --text: #e8edf3;
  --muted: #9aa7b8;
  --accent: #67d8aa;
  --accent-text: #67d8aa;
  --on-accent: #0b1a13;
  --cardio: #528bcb;
  --strength: #d6a04c;
  --mobility: #a78bfa;
  --alert: #ef4444;
  --warn: #f59e0b;
  --rest: #556273;
  --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f6f9; --card: #ffffff; --card-2: #eef2f6; --border: #d8dfe7; --text: #10151c; --muted: #546274;
    --accent-text: #137a55; --cardio: #2f6aa8; --strength: #9a6a1c; --mobility: #6d4fd6; --alert: #c81e1e; --warn: #b45309;
    --rest: #9aa5b3;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent-text); }
.icon { flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: .02em; }
.brand b { color: var(--accent-text); }
.topnav { display: none; gap: 4px; margin-left: 16px; }
.settings-link { margin-left: auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--muted); }
.settings-link.active, .settings-link:hover { color: var(--accent-text); background: var(--card-2); }
.nav-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav-link.active { color: var(--accent-text); }

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.bottomnav .nav-link { flex-direction: column; justify-content: center; gap: 3px; min-height: 62px; font-size: .72rem; }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .topnav .nav-link { padding: 10px 12px; border-radius: 12px; }
  .topnav .nav-link:hover { background: var(--card-2); }
  .topnav .nav-link.active { background: color-mix(in srgb, var(--accent) 15%, transparent); }
  .bottomnav { display: none; }
}

/* ---------- Mise en page ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 100px; }
@media (min-width: 900px) { main { padding: 28px 24px 48px; } }
h1 { font-size: 1.6rem; margin: 4px 0 2px; letter-spacing: -.01em; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 18px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; }
  .grid-2-even { grid-template-columns: 1fr 1fr; align-items: start; }
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Éléments ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-danger { color: var(--alert); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--card-2); color: var(--muted); }
.badge-accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); }
.badge-mobility { background: color-mix(in srgb, var(--mobility) 16%, transparent); color: var(--mobility); }
.badge-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge-alert { background: color-mix(in srgb, var(--alert) 16%, transparent); color: var(--alert); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 10px;
  min-height: 44px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; min-height: 44px; }
label.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--card-2); border-radius: 12px; padding: 10px 12px; }
.stat .label { font-size: .78rem; color: var(--muted); }
.stat .value { font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat .hint { font-size: .75rem; color: var(--muted); }

.progress { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- Séance ---------- */
.session-title { font-size: 1.25rem; font-weight: 750; margin: 0 0 10px; }
.blocks { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.blocks li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--card-2); border-left: 4px solid var(--rest); }
.blocks li.cardio { border-left-color: var(--cardio); }
.blocks li.routine { border-left-color: var(--strength); }
.blocks li.mobility, .blocks li.warmup { border-left-color: var(--mobility); }
.blocks li.leisure { border-left-color: var(--accent); }
.blocks .min { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.notes { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: .88rem; }
.status-done { color: var(--accent-text); font-weight: 700; }

.item { background: var(--card-2); border-radius: 12px; padding: 12px; border-left: 4px solid var(--strength); }
.item.cardio { border-left-color: var(--cardio); }
.item.info { border-left-color: var(--mobility); }
.item.is-done { opacity: .75; }
.item-head { display: flex; align-items: flex-start; gap: 10px; }
.item-head .name { font-weight: 700; }
.item-head .rx { font-size: .88rem; color: var(--muted); }
.item-head input[type=checkbox] { width: 26px; height: 26px; min-height: 0; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.item .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
@media (min-width: 600px) { .item .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.item .last { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.optional-tag { font-size: .72rem; color: var(--muted); border: 1px dashed var(--border); border-radius: 99px; padding: 1px 7px; margin-left: 6px; }
.block-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }

.actions-bar {
  position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 10px; margin: 16px -4px 0; border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 96%, transparent); border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
@media (min-width: 900px) { .actions-bar { bottom: 12px; grid-template-columns: repeat(4, 1fr); } }

.level { border-radius: 12px; padding: 12px; font-size: .92rem; }
.level.green { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.level.orange { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.level.red { background: color-mix(in srgb, var(--alert) 16%, transparent); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; min-height: 0; padding: 0; accent-color: var(--accent); background: none; border: 0; }
.range-row output { min-width: 2.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.row-link { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 0; color: var(--text); text-decoration: none; }
.row-link .dot { width: 6px; align-self: stretch; border-radius: 99px; flex-shrink: 0; }
.row-link .when { width: 72px; flex-shrink: 0; color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.row-link .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.row-link .tag { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ---------- Calendrier ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 1.1rem; text-transform: capitalize; letter-spacing: 0; color: var(--text); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal button {
  position: relative; min-height: 54px; padding: 4px; border-radius: 10px; border: 2px solid transparent;
  background: var(--card-2); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column;
}
.cal button.out { opacity: .35; }
.cal button:disabled { opacity: .15; cursor: default; }
.cal button.selected { border-color: var(--accent); }
.cal button .num { font-size: .8rem; font-weight: 650; }
.cal button.today .num { color: var(--on-accent); background: var(--accent); border-radius: 99px; width: 22px; height: 22px; display: grid; place-items: center; }
.cal button .bar { margin-top: auto; height: 5px; border-radius: 99px; }
.cal button .mark { position: absolute; top: 3px; right: 5px; font-size: .8rem; font-weight: 800; }
.mark.done { color: var(--accent-text); }
.mark.missed { color: var(--alert); }
.mark.shift { color: var(--warn); }
@media (min-width: 900px) { .cal button { min-height: 72px; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 6px; border-radius: 99px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.phases { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.phases button { flex-shrink: 0; min-height: 38px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: none; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; }
.phases button.active { border-color: var(--accent); color: var(--accent-text); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---------- Graphique ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .target { stroke: var(--muted); stroke-dasharray: 5 5; fill: none; stroke-width: 1.5; }
.chart .real { stroke: var(--accent); fill: none; stroke-width: 2.5; }
.chart .avg { stroke: var(--cardio); fill: none; stroke-width: 2; }
.chart .point { fill: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; padding: 6px 12px; min-height: 36px; cursor: pointer; }
.seg button.active { background: var(--card-2); color: var(--text); font-weight: 700; }

/* ---------- Divers ---------- */
.empty { text-align: center; color: var(--muted); padding: 24px 12px; border: 1px dashed var(--border); border-radius: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.update-banner { position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top)); z-index: 40; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 650; }
.update-banner button { border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; }
.update-reload { margin-left: auto; background: var(--on-accent); color: var(--accent); }
.update-dismiss { background: transparent; color: inherit; font-size: 1.2rem; }
details > summary { cursor: pointer; font-weight: 650; min-height: 40px; display: flex; align-items: center; }
.exercise-card { scroll-margin-top: 80px; }
.exercise-card:target { border-color: var(--accent); }
