/* Carnet 70.3 — feuille de style unique. Mobile first, sans exception.
 * Direction artistique : app iOS moderne. Fond clair, cartes blanches très arrondies sans bordure,
 * grands chiffres, barre d'onglets flottante avec bouton « + » central, bandeau des jours, jauge circulaire.
 * Couleurs de l'identité IRONMAN France Nice : marine, bleu ciel, orange. Aucune police distante. */

:root {
  --navy:       #183058;
  --navy-deep:  #10213F;
  --navy-soft:  #E8ECF5;
  --sky:        #4FC3E8;
  --sky-soft:   #E1F4FB;
  --orange:     #F5A11E;
  --orange-deep:#E8891A;
  --orange-ink: #8A4E00;
  --orange-soft:#FEF1DC;
  --paper:      #F4F5F9;
  --card:       #FFFFFF;
  --ink:        #101C33;
  --slate:      #6B7A93;
  --line:       #E6E9F0;
  --ok:         #1F7A4D;
  --ok-soft:    #E3F2E9;
  --alerte:     #C8322B;
  --alerte-soft:#FBE9E7;
  --violet-soft:#EEEDFF;

  --sans: system-ui, -apple-system, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  --display: var(--sans);

  --radius: 22px;
  --radius-sm: 14px;
  --gutter: 18px;
  --tap: 44px;
  --pastille: 50px;
  --tabbar-h: 74px;
  --shadow: 0 1px 2px rgba(16, 28, 51, .04), 0 8px 24px rgba(16, 28, 51, .06);
  --shadow-lg: 0 12px 32px rgba(16, 28, 51, .14);
  --focus: 0 0 0 3px var(--paper), 0 0 0 6px var(--sky);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  -webkit-touch-callout: none;
}

img, svg, video { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0 0 .5rem;
  color: var(--ink);
}
h1 { font-size: clamp(1.7rem, 6.5vw, 2.2rem); }
h2 { font-size: clamp(1.35rem, 5.5vw, 1.7rem); }
h3 { font-size: 1.08rem; letter-spacing: -.01em; }
h4 { font-size: 1rem; font-weight: 700; margin: 0 0 .4rem; }

p { margin: 0 0 .75rem; }
ul, ol { margin: 0 0 .75rem; padding-left: 1.25rem; }
li { margin-bottom: .4rem; }
small, .muted { color: var(--slate); }
strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
a { color: var(--navy); }
code { font-size: .9em; background: var(--paper); padding: 1px 6px; border-radius: 6px; }

.prose { max-width: 34em; }
.prose p:last-child { margin-bottom: 0; }
.num { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.skip { position: absolute; left: -999px; top: 0; background: var(--navy); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- interactions */
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: 12px; }

input, select, textarea {
  font-size: 16px;                       /* sous 16 px, iOS zoome au focus */
  min-height: 48px;
  padding: .6rem .9rem;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--paper);
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--sky); background: #fff; box-shadow: 0 0 0 3px var(--sky-soft); }
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="date"], input[type="time"] { min-height: 48px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%236B7A93' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
label { display: block; font-size: .82rem; font-weight: 600; color: var(--slate); margin-bottom: .35rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; min-width: var(--tap);
  padding: .6rem 1.15rem;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--navy);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 80ms linear, transform 80ms linear, border-color 80ms linear;
}
.btn:active { background: var(--paper); transform: scale(.985); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-deep); }
.btn-terre { background: var(--sky); border-color: var(--sky); color: var(--navy); }
.btn-terre:active { background: #3AB2DA; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--navy); font-weight: 600; }
.btn-ghost:active { background: var(--navy-soft); }
.btn-danger { color: var(--alerte); }
.btn-block { width: 100%; }
.btn-sm { white-space: nowrap; min-height: 40px; padding: .3rem .7rem; font-size: .9rem; }
.btn-lg { min-height: 58px; font-size: 1.1rem; font-weight: 700; border-radius: 18px; }
.btn[disabled] { opacity: .4; cursor: default; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }
.btn-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); color: var(--navy);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow); cursor: pointer;
}
.icon-btn:active { background: var(--paper); }

/* ---------------------------------------------------------------- layout */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.wrap {
  width: 100%;
  padding-left:  calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
}

main.wrap {
  flex: 1;
  padding-top: 6px;
  padding-bottom: calc(var(--tabbar-h) + 30px + max(10px, calc(env(safe-area-inset-bottom) - 12px)));
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244, 245, 249, .86);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 66px; gap: 10px; }
.greet { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; background: var(--navy);
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: var(--shadow);
}
.avatar svg { width: 34px; height: 34px; }
.greet-text { min-width: 0; }
.greet-hi { font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greet-sub { color: var(--slate); font-size: .82rem; line-height: 1.2; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-logo { display: none; height: 34px; width: auto; }

.sync {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: var(--tap); padding: 0 .4rem;
  background: transparent; border: 0; color: var(--slate); font-size: .8rem; font-weight: 600;
}
.sync-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ok); background: var(--ok); }
.sync.pending .sync-dot { background: transparent; border-color: var(--orange); }
.sync.off .sync-dot { background: transparent; border-color: var(--slate); }
.sync.error .sync-dot { background: var(--alerte); border-color: var(--alerte); }
.sync-label { display: none; }

/* Barre d'onglets flottante, bouton + central */
.tabbar {
  position: fixed; z-index: 30;
  left: calc(14px + env(safe-area-inset-left)); right: calc(14px + env(safe-area-inset-right));
  /* Sur iPhone avec barre de gestes, on descend dans la zone sûre au lieu de flotter au-dessus. */
  bottom: max(10px, calc(env(safe-area-inset-bottom) - 12px));
  display: grid; grid-template-columns: 1fr 1fr 72px 1fr 1fr; align-items: center;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-radius: 30px;
  padding: 6px 6px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(230, 233, 240, .8);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 56px;
  border: 0; background: transparent; color: var(--slate);
  font-size: .66rem; font-weight: 700; letter-spacing: 0;
  padding: 4px 2px; border-radius: 22px;
}
.tab:active { background: var(--paper); }
.tab[aria-current="page"] { color: var(--navy); }
.tab-icon { display: block; line-height: 0; position: relative; }
.tab[aria-current="page"] .tab-icon::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: var(--orange);
}
.tab-plus { min-height: 56px; padding: 0; }
.plus-btn {
  width: 58px; height: 58px; border-radius: 50%; background: var(--orange); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(245, 161, 30, .45); margin-top: -18px;
  transition: transform 80ms linear;
}
.tab-plus:active .plus-btn { transform: scale(.94); background: var(--orange-deep); }

/* ---------------------------------------------------------------- cartes & sections */
.card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-eau { box-shadow: var(--shadow); }
.card-fer { background: var(--orange-soft); }
.card-terre { background: var(--sky-soft); }
.card-soft { background: var(--sky-soft); box-shadow: none; }
.card-sleep { background: linear-gradient(135deg, #EEEDFF, #F7F6FF); }
.card-bilan { background: linear-gradient(135deg, #FEF1DC, #FFF8EE); }
.card-day { padding: 20px; }
.card h2, .card h3 { margin-top: 0; }

.section-title {
  font-size: .95rem; font-weight: 700; letter-spacing: -.01em;
  color: var(--ink); margin: 22px 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.badge {
  display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: 0;
  padding: 5px 11px; border-radius: 999px; background: var(--paper); color: var(--slate);
}
.badge-eau { background: var(--navy-soft); color: var(--navy); }
.badge-fer { background: var(--orange-soft); color: var(--orange-ink); }
.badge-terre { background: var(--ok-soft); color: var(--ok); }
.badge-alerte { background: var(--alerte-soft); color: var(--alerte); }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ---------------------------------------------------------------- Accueil */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, #1F3F70 100%); color: #fff;
  border-radius: 26px; padding: 20px 18px 18px; margin: 8px 0 12px;
  box-shadow: 0 14px 34px rgba(24, 48, 88, .28);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.hero::before {
  content: ""; position: absolute; right: -60px; top: -80px; width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 195, 232, .35), rgba(79, 195, 232, 0) 70%);
}
.hero-main { position: relative; min-width: 0; }
.hero-kicker { font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--sky); }
.count { font-weight: 800; font-size: clamp(3.6rem, 19vw, 5.2rem); line-height: 1; letter-spacing: -.04em; color: #fff; font-variant-numeric: tabular-nums; }
.count-unit { font-size: clamp(1rem, 4.5vw, 1.3rem); color: rgba(255,255,255,.85); margin-left: .4rem; font-weight: 600; }
.hero-sub { color: rgba(255,255,255,.78); margin: 6px 0 0; font-size: .9rem; }
.hero-sub strong { color: #fff; }
.hero-bravo { margin: 10px 0 0; color: #fff; font-weight: 600; font-size: .9rem; }
.hero-bravo::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 8px; vertical-align: middle; }
.hero-ring { position: relative; flex: 0 0 auto; width: 104px; height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.hero-ring .ring { position: absolute; inset: 0; width: 104px; height: 104px; }
.ring-val { position: relative; font-weight: 800; font-size: 1.25rem; letter-spacing: -.03em; line-height: 1; }
.ring-val small { font-size: .7rem; font-weight: 700; margin-left: 1px; }
.ring-lbl { position: relative; font-size: .58rem; color: rgba(255,255,255,.75); font-weight: 600; line-height: 1; max-width: 62px; text-align: center; }

/* ---------------------------------------------------------------- Calendrier */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 1.2rem; text-transform: capitalize; }
.cal-nav { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); color: var(--navy); font-size: 1.2rem; font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.cal-dow { text-align: center; font-size: .66rem; font-weight: 700; color: var(--slate); padding: 4px 0; }
.cal-day {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  min-height: 58px; padding: 6px 2px 5px; border: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  color: var(--slate); cursor: pointer;
}
.cal-day.is-out { opacity: .35; box-shadow: none; background: transparent; }
.cal-day.is-past .cal-type { color: var(--slate); }
.cal-num { font-weight: 700; font-size: .95rem; color: var(--ink); line-height: 1.1; }
.cal-type { font-size: .66rem; font-weight: 800; color: var(--navy); }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.cal-dot.plan { background: var(--line); }
.cal-dot.faite { background: var(--ok); }
.cal-dot.partielle { background: var(--orange); }
.cal-dot.sautee { box-shadow: inset 0 0 0 1.5px var(--slate); }
.cal-day.is-today .cal-num { color: var(--orange-deep); }
.cal-day.is-sel { background: var(--navy); color: rgba(255,255,255,.8); }
.cal-day.is-sel .cal-num, .cal-day.is-sel .cal-type { color: #fff; }
.cal-day.is-sel .cal-dot.plan { background: rgba(255,255,255,.35); }
.cal-day.is-race { box-shadow: 0 0 0 2px var(--orange); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .74rem; color: var(--slate); font-weight: 600; margin-bottom: 12px; }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.segments { margin: 0 4px 14px; }
.segments-bar { position: relative; display: flex; height: 8px; border-radius: 999px; overflow: visible; background: var(--line); }
.seg { height: 100%; position: relative; }
.seg:first-child { border-radius: 999px 0 0 999px; }
.seg:last-child { border-radius: 0 999px 999px 0; }
.seg-1 { background: var(--navy); }
.seg-2 { background: var(--sky); }
.seg-3 { background: var(--orange); }
.seg.future { opacity: .3; }
.seg-marker { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--paper); }
.segments-legend { display: flex; justify-content: space-between; font-size: .7rem; font-weight: 600; color: var(--slate); margin-top: 6px; gap: 6px; }
.segments-legend span { flex: 1; text-align: center; }
.segments-legend span:first-child { text-align: left; }
.segments-legend span:last-child { text-align: right; }

/* Bandeau des jours */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.strip-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px 8px; border-radius: 18px; border: 0; background: var(--card);
  box-shadow: var(--shadow); color: var(--slate); min-height: 78px; cursor: pointer;
}
.strip-day:active { background: var(--paper); }
.strip-name { font-size: .66rem; font-weight: 600; }
.strip-num { font-size: 1.15rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.1; }
.strip-type { font-size: .68rem; font-weight: 700; color: var(--navy); }
.strip-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; margin-top: 2px; }
.strip-dot.plan { background: var(--line); }
.strip-dot.faite { background: var(--ok); }
.strip-dot.partielle { background: var(--orange); }
.strip-dot.sautee { background: transparent; box-shadow: inset 0 0 0 1.5px var(--slate); }
.strip-day.is-today .strip-num { color: var(--orange-deep); }
.strip-day.is-sel { background: var(--navy); color: rgba(255,255,255,.8); }
.strip-day.is-sel .strip-num, .strip-day.is-sel .strip-type { color: #fff; }
.strip-day.is-sel .strip-dot.plan { background: rgba(255,255,255,.35); }
.strip-day.is-sel.is-today .strip-num { color: var(--orange); }

.today-card .today-title { font-size: clamp(1.4rem, 6vw, 1.8rem); margin: 10px 0 2px; }
.today-detail { color: var(--slate); margin-bottom: 12px; }
.today-status { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ok); font-weight: 600; margin-bottom: 10px; }
.today-status.is-muted { color: var(--slate); }
.note-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.next-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer; padding: 14px 16px; font: inherit; color: inherit; border: 0; }
.next-card:active { background: var(--paper); }
.next-ico { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; background: var(--orange-soft); color: var(--orange-ink); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.next-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.next-kicker { font-size: .72rem; font-weight: 700; color: var(--orange-ink); text-transform: uppercase; letter-spacing: .04em; }
.next-title { font-weight: 700; color: var(--ink); line-height: 1.25; }
.next-sub { color: var(--slate); font-size: .85rem; }

/* Tuiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.tiles-2 { grid-template-columns: repeat(2, 1fr); }
.tile {
  background: var(--card); border: 0; border-radius: 20px; padding: 14px 14px 12px; text-align: left;
  box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.tiles:not(.tiles-2) .tile { text-align: center; align-items: center; padding: 12px 8px; }
.tile-btn { cursor: pointer; font: inherit; color: inherit; }
.tile-btn:active { background: var(--paper); }
.tile-ico { width: 34px; height: 34px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--navy); background: var(--navy-soft); flex: 0 0 auto; }
.ico-sleep { background: var(--violet-soft); color: #4B45B5; }
.ico-steps { background: var(--sky-soft); color: #0B7FA3; }
.ico-scale { background: var(--orange-soft); color: var(--orange-ink); }
.ico-ok { background: var(--ok-soft); color: var(--ok); }
.ico-warn { background: var(--alerte-soft); color: var(--alerte); }
.ico-strava { background: #FDE6DA; color: #FC4C02; font-weight: 800; }
.tile-num { display: block; font-weight: 800; font-size: clamp(1.35rem, 6vw, 1.8rem); line-height: 1; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile-num small { font-size: .85rem; font-weight: 600; color: var(--slate); letter-spacing: 0; }
.tile-lbl { display: block; font-size: .74rem; font-weight: 600; color: var(--slate); }
.tile-navy { background: var(--navy); }
.tile-navy .tile-num { color: #fff; }
.tile-navy .tile-lbl { color: var(--sky); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .btn { min-width: 56px; font-size: 1.4rem; padding: 0; border-radius: 16px; }
.stepper-value { flex: 1; text-align: center; font-weight: 800; font-size: 2.1rem; letter-spacing: -.03em; min-height: var(--tap); display: flex; align-items: center; justify-content: center; color: var(--ink); }
.scale { display: flex; gap: 4px; margin-top: 8px; }
.scale-step { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.scale-step.on { background: var(--ok); }
.scale-step.on.mid { background: var(--orange); }
.scale-step.on.high { background: var(--alerte); }

.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form > div { flex: 1; }
.inline-form .btn { flex: 0 0 auto; }
.hm { display: flex; align-items: center; gap: 6px; }
.hm input { text-align: center; padding-left: .4rem; padding-right: .4rem; }
.hm span { font-weight: 700; color: var(--slate); }

.banner { position: relative; padding-right: 56px; }
.banner .btn-close { position: absolute; top: 6px; right: 6px; }

/* Actions rapides */
.plus-list { display: grid; gap: 8px; }
.plus-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 60px; padding: 10px 14px; border: 0; border-radius: 18px; background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: 1rem; cursor: pointer;
}
.plus-item:active { background: var(--line); }
.plus-ico { width: 40px; height: 40px; border-radius: 14px; background: var(--card); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow); flex: 0 0 auto; }
.plus-item:first-child .plus-ico { background: var(--orange); color: #fff; }

/* ---------------------------------------------------------------- Séance */
.seance-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 4px; }
.elapsed { font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; color: var(--orange-ink); white-space: nowrap; background: var(--orange-soft); padding: 6px 12px; border-radius: 999px; }

.exo { padding: 16px; }
.exo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.exo-code { color: var(--orange-ink); background: var(--orange-soft); font-weight: 800; font-size: .74rem; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; display: inline-block; margin-bottom: 6px; }
.exo-name { font-size: 1.2rem; margin: 0; letter-spacing: -.02em; }
.exo-target { color: var(--slate); font-size: .92rem; margin: 2px 0 8px; }
.exo-goal { font-size: .88rem; font-weight: 600; color: var(--navy); background: var(--sky-soft); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; }
.exo-goal.is-up { background: var(--orange-soft); color: var(--orange-ink); }
.btn-help { white-space: nowrap; flex: 0 0 auto; font-size: .85rem; padding: .4rem .7rem; min-height: 40px; background: var(--navy-soft); border-radius: 999px; }
.btn-help span { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; align-items: center; justify-content: center; font-size: .8rem; font-weight: 800; }

.pastilles { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.pastille {
  width: var(--pastille); height: var(--pastille);
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--slate);
  font-size: 1.1rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer;
  transition: background-color 80ms linear, border-color 80ms linear, transform 80ms linear;
}
.pastille:active { transform: scale(.94); background: var(--paper); }
.pastille[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.pastille[aria-pressed="true"]:active { background: var(--navy-deep); }

.sets { margin-top: 8px; display: grid; gap: 6px; }
.set { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 8px; align-items: center; }
.set-idx { color: var(--slate); font-size: .78rem; font-weight: 800; }
.set input { text-align: center; padding-left: .4rem; padding-right: 2.2rem; }
.set-field { position: relative; }
.set-field span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: .72rem; font-weight: 700; color: var(--slate); pointer-events: none; }

.rpe { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 8px; }
.rpe .btn { padding: 0; font-weight: 700; border-radius: 14px; }
.rpe .btn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

details.fold { border: 0; border-radius: var(--radius); background: var(--card); margin-bottom: 12px; box-shadow: var(--shadow); }
details.fold > summary {
  list-style: none; cursor: pointer; min-height: 54px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; font-weight: 700; color: var(--ink);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "+"; font-size: 1.4rem; color: var(--orange); font-weight: 700; }
details.fold[open] > summary::after { content: "−"; }
details.fold > .fold-body { padding: 0 18px 16px; }

.timer {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar-h) + 14px + max(10px, calc(env(safe-area-inset-bottom) - 12px)));
  padding: 0 calc(14px + env(safe-area-inset-left)) 0 calc(14px + env(safe-area-inset-right));
}
.timer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--navy); color: #fff;
  border-radius: 22px; padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow-lg);
}
.timer-label { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--sky); font-weight: 700; }
.timer-value { font-weight: 800; font-size: 2rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; flex: 1; text-align: center; line-height: 1; }
.timer.done .timer-inner { background: var(--ok); }
.timer .btn-ghost { color: #fff; }

/* ---------------------------------------------------------------- Évolution */
.chart { display: block; width: 100%; height: auto; }
.ch-axis { stroke: var(--line); stroke-width: 1; }
.ch-lbl { font-family: var(--sans); font-size: 10px; fill: var(--slate); }
.ch-val { font-family: var(--sans); font-weight: 700; font-size: 11px; fill: var(--navy); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .78rem; font-weight: 600; color: var(--slate); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.card-alerte-soft { box-shadow: var(--shadow); }

.feed { display: grid; gap: 10px; }
.act { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.act-head { display: flex; align-items: center; gap: 12px; }
.act-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .95rem; }
.act-titles { flex: 1; min-width: 0; }
.act-title { font-weight: 700; color: var(--ink); font-size: 1.02rem; line-height: 1.2; letter-spacing: -.01em; }
.act-date { color: var(--slate); font-size: .8rem; }
.src-strava { color: #FC4C02; font-weight: 700; }
.act-head .btn { padding: .4rem .7rem; min-height: 40px; font-size: .85rem; border-radius: 999px; }
.act-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.act-num { display: block; font-weight: 800; font-size: 1.3rem; line-height: 1; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.act-lbl { display: block; font-size: .68rem; font-weight: 600; color: var(--slate); margin-top: 3px; }
.act-note { margin: 10px 0 0; color: var(--slate); font-size: .92rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .span2 { grid-column: 1 / -1; }

.note { background: var(--card); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); }
.note-date { font-size: .74rem; font-weight: 700; color: var(--slate); margin-bottom: 2px; }
.note p { margin: 0; white-space: pre-wrap; }

/* ---------------------------------------------------------------- Aliments */
.ali-tools { display: grid; grid-template-columns: 1fr 110px; gap: 10px; margin-bottom: 10px; }
.ali-head, .ali-row { display: grid; grid-template-columns: minmax(0, 1fr) 46px 46px 40px 40px 36px; gap: 4px; align-items: center; }
.ali-head { font-size: .68rem; font-weight: 700; color: var(--slate); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px 6px; }
.ali-head span:not(:first-child) { text-align: right; }
.ali-list { display: grid; gap: 6px; }
.ali-row { background: var(--card); border-radius: 14px; padding: 10px 6px 10px 12px; box-shadow: var(--shadow); }
.ali-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ali-name strong { font-size: .95rem; letter-spacing: -.01em; }
.ali-name small { color: var(--slate); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ali-num { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--ink); }
.ali-prot { font-weight: 800; color: var(--navy); }
.ali-add { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--orange-soft); color: var(--orange-ink); font-weight: 800; font-size: 1.1rem; cursor: pointer; justify-self: end; }
.ali-add.is-on { background: var(--ok-soft); color: var(--ok); }
.ali-add:active { transform: scale(.94); }

/* ---------------------------------------------------------------- Réglages */
.notif-list { display: grid; gap: 4px; }
.notif-row { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.notif-row:last-child { border-bottom: 0; }
.notif-time { min-height: 40px; padding: .3rem .5rem; text-align: center; font-weight: 600; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; color: var(--ink); font-size: 1rem; font-weight: 400; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background-color 120ms linear; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 120ms linear; }
.switch input:checked + .switch-ui { background: var(--ok); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--focus); }
.switch-text { display: flex; flex-direction: column; line-height: 1.25; }

.checks { display: grid; gap: 2px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 0; cursor: pointer; color: var(--ink); font-weight: 400; font-size: 1rem; margin: 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--line); background: var(--card); position: relative; transition: background-color 80ms linear, border-color 80ms linear; }
.check-box::after { content: ""; position: absolute; left: 8px; top: 3px; width: 6px; height: 12px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); opacity: 0; }
.check input:checked + .check-box { background: var(--ok); border-color: var(--ok); }
.check input:checked + .check-box::after { opacity: 1; }
.check input:focus-visible + .check-box { box-shadow: var(--focus); }
.check-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.check-text small { color: var(--slate); font-size: .78rem; }
.check input:checked ~ .check-text strong { color: var(--slate); text-decoration: line-through; text-decoration-color: var(--line); }
.switch-text small { color: var(--slate); font-size: .78rem; }

/* ---------------------------------------------------------------- Bibliothèque */
.search { margin-bottom: 10px; }
.search input { background: var(--card); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 0; background: var(--card); color: var(--slate); box-shadow: var(--shadow);
  font-weight: 600; font-size: .9rem;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }

.list { display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  min-height: 64px; padding: 12px 16px;
  background: var(--card); border: 0; border-radius: 18px; box-shadow: var(--shadow);
}
.item:active { background: var(--paper); }
.item-title { font-weight: 700; display: block; color: var(--ink); letter-spacing: -.01em; }
.item-sub { color: var(--slate); font-size: .84rem; display: block; }
.item-chevron { color: var(--orange); flex: 0 0 auto; font-size: 1.4rem; line-height: 1; }

.back { margin: 0 0 8px -8px; }

.kv { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0 0 12px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; text-align: right; font-weight: 700; }

/* Tableaux : jamais de défilement horizontal de la page */
.table-stack { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.table-stack thead { display: none; }
.table-stack tr { display: block; border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; background: var(--paper); }
.table-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; }
.table-stack td::before { content: attr(data-label); color: var(--slate); flex: 0 0 auto; }
.table-stack td:first-child { font-weight: 700; color: var(--ink); }
.table-stack tr.total { background: var(--sky-soft); }

.table-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; border-radius: 12px;
  background: linear-gradient(to right, var(--card) 30%, rgba(255,255,255,0)), linear-gradient(to left, var(--card) 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(16,28,51,.15), rgba(0,0,0,0)), linear-gradient(to left, rgba(16,28,51,.15), rgba(0,0,0,0));
  background-position: left, right, left, right; background-repeat: no-repeat; background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll; }
.table-scroll table { width: 100%; min-width: 480px; border-collapse: collapse; }
.table-scroll th, .table-scroll td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); }

/* ---------------------------------------------------------------- divers */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 20px + max(10px, calc(env(safe-area-inset-bottom) - 12px)));
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; z-index: 40;
  max-width: calc(100% - 32px); font-size: .92rem; font-weight: 600; box-shadow: var(--shadow-lg);
}

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(16, 28, 51, .45); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; max-height: 88dvh;
  background: var(--card); border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -10px 40px rgba(16,28,51,.25);
  animation: sheet-up 220ms cubic-bezier(.2,.8,.2,1);
}
.sheet-panel::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px 8px 18px; }
.sheet-title { margin: 0; font-size: 1.25rem; }
.sheet-body { overflow-y: auto; padding: 6px 18px 24px; -webkit-overflow-scrolling: touch; max-width: none; }
.sheet-body h3 { margin-top: 1.1rem; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--orange-ink); }
.sheet-body h3:first-child { margin-top: 0; }

.warning { box-shadow: none; background: var(--orange-soft); color: var(--ink); }
.callout { background: var(--sky-soft); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.schema { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto 12px; background: var(--paper); border-radius: 18px; padding: 10px; }
.schema-sm { max-width: 320px; }
.callout p:last-child { margin-bottom: 0; }

.welcome { padding-top: 8px; }
.welcome-logo { display: block; width: min(300px, 70%); margin: 16px auto 20px; }

/* ---------------------------------------------------------------- points de rupture, en min-width uniquement */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .btn-grid { grid-template-columns: repeat(3, 1fr); }
  .sync-label { display: inline; }
  .brand-logo { display: block; }
  .tiles-2 { grid-template-columns: repeat(4, 1fr); }
  .table-stack thead { display: table-header-group; }
  .table-stack tr { display: table-row; border: 0; padding: 0; margin: 0; background: transparent; }
  .table-stack td, .table-stack th { display: table-cell; padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
  .table-stack td::before { content: none; }
  .table-stack th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); }
  .kv { grid-template-columns: 1fr 1fr; }
  .set { grid-template-columns: 44px 1fr 1fr; max-width: 420px; }
  .sheet-panel { left: 50%; right: auto; width: min(640px, 100%); transform: translateX(-50%); }
  @keyframes sheet-up { from { transform: translate(-50%, 40px); opacity: .5; } to { transform: translate(-50%, 0); opacity: 1; } }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); }
}

@media (min-width: 900px) {
  .wrap { max-width: 720px; margin-left: auto; margin-right: auto; }
  .tabbar {
    position: sticky; top: 0; bottom: auto; order: -1; transform: none; left: auto; width: auto;
    grid-template-columns: repeat(2, minmax(0, 150px)) 72px repeat(2, minmax(0, 150px));
    justify-content: center; gap: 8px; margin: 10px auto 0; max-width: 720px;
    padding: 6px 10px; border-radius: 999px;
  }
  .tab { flex-direction: row; gap: 8px; font-size: .9rem; padding: 6px 12px; min-height: 48px; }
  .tab[aria-current="page"] .tab-icon::after { display: none; }
  .tab[aria-current="page"] { background: var(--navy-soft); }
  .plus-btn { width: 48px; height: 48px; margin-top: 0; }
  .topbar { position: static; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; padding-top: 12px; }
  main.wrap { padding-bottom: 48px; }
  .timer { bottom: 16px; }
  .timer-inner { max-width: 720px; margin: 0 auto; }
  .toast { bottom: 24px; }
}

@media (min-width: 1200px) {
  .wrap { max-width: 860px; }
  .timer-inner { max-width: 860px; }
}

/* Séance en paysage : liste à gauche, pastilles à droite */
@media (orientation: landscape) and (min-width: 600px) {
  .exo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr; gap: 8px 20px; align-items: start; }
  .exo .exo-head { grid-column: 1; grid-row: 1; }
  .exo .exo-target { grid-column: 1; grid-row: 2; }
  .exo .pastilles { grid-column: 2; grid-row: 1; margin-top: 0; }
  .exo .sets { grid-column: 2; grid-row: 2 / span 2; }
}

/* ---------------------------------------------------------------- accessibilité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn:active, .pastille:active, .tab-plus:active .plus-btn { transform: none; }
}

@media (hover: hover) {
  .btn:hover { border-color: var(--slate); }
  .btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
  .btn-terre:hover { background: #3AB2DA; border-color: #3AB2DA; }
  .item:hover, .tile-btn:hover, .strip-day:hover { box-shadow: 0 10px 28px rgba(16, 28, 51, .12); }
}

@media print { .tabbar, .topbar, .timer, .toast { display: none; } }
