/* NiniFit — deux ambiances pilotées par [data-person] sur <html> */

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

/* Thomas : sombre, bleu électrique, typo condensée */
:root, [data-person="thomas"] {
  color-scheme: dark;
  --bg: #0a0e14;
  --glow: radial-gradient(110% 50% at 100% 0%, rgb(61 139 255 / .20), transparent 65%);
  --header: rgb(10 14 20 / .85);
  --tabbar: rgb(14 19 27 / .92);
  --surface: #121822;
  --surface-2: #1a2230;
  --border: #253043;
  --grid: #222c3b;
  --text: #eef3fa;
  --muted: #8b98ab;
  --accent: #3d8bff;
  --accent-2: #22c7f0;
  --on-accent: #06101f;
  --brand-accent: #3d8bff;
  --pill-bg: var(--accent);
  --pill-text: var(--on-accent);
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #ff6b6b;
  --haut: #60a5fa;
  --bas: #2dd4bf;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-btn: 10px;
  --shadow: 0 0 0 1px rgb(61 139 255 / .55), 0 12px 32px -14px rgb(61 139 255 / .6);
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display-case: uppercase;
  --display-spacing: .03em;
}

/* Johanna : rose & lilas, tout en rondeurs */
[data-person="johanna"] {
  color-scheme: light;
  --bg: #fff5f9;
  --glow: radial-gradient(70% 35% at 0% 0%, rgb(255 143 184 / .30), transparent 70%),
          radial-gradient(60% 35% at 100% 25%, rgb(190 150 255 / .25), transparent 70%);
  --header: linear-gradient(120deg, #f0609a, #a77bf3);
  --tabbar: rgb(255 255 255 / .94);
  --surface: #ffffff;
  --surface-2: #fff0f6;
  --border: #ffd9e8;
  --grid: #f7e4ed;
  --text: #4f2c46;
  --muted: #94627f;
  --accent: #ec4f8b;
  --accent-2: #a46ff2;
  --on-accent: #ffffff;
  --brand-accent: #ffffff;
  --pill-bg: #ffe1ee;
  --pill-text: #c22f6b;
  --good: #1f8f62;
  --warn: #c76a00;
  --danger: #d03535;
  --haut: #d63a75;
  --bas: #8452f0;
  --radius: 26px;
  --radius-sm: 18px;
  --radius-btn: 999px;
  --shadow: 0 0 0 2px #ffb3d1, 0 14px 30px -14px rgb(236 79 139 / .55);
  --font-display: 'Fredoka', 'Avenir Next', sans-serif;
  --font-body: 'Fredoka', 'Avenir Next', -apple-system, sans-serif;
  --display-case: none;
  --display-spacing: 0;
}

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--glow) no-repeat, var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font-body);
  -webkit-tap-highlight-color: transparent;
  transition: background-color .3s, color .3s;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

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

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px;
  background: var(--header);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgb(255 255 255 / .06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #fff;
  font: 700 22px/1 var(--font-display);
  text-transform: var(--display-case);
  letter-spacing: var(--display-spacing);
}
.brand b { color: var(--brand-accent); }

.sync { width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: #6b7280; transition: background .3s; }
.sync[data-state="ok"] { background: #34d399; }
.sync[data-state="saving"] { background: #fbbf24; animation: pulse 1s ease-in-out infinite; }
.sync[data-state="offline"] { background: #9ca3af; }
@keyframes pulse { 50% { opacity: .35; } }

.switch { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: rgb(255 255 255 / .08); }
.switch button {
  appearance: none;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgb(255 255 255 / .75);
  font: 600 15px var(--font-body);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
[data-person="johanna"] .switch { background: rgb(255 255 255 / .22); }
[data-person="johanna"] .switch button { color: #fff; }
[data-person="johanna"] .switch button[aria-pressed="true"] { background: #fff; color: var(--accent); }

/* ——— Barre d'onglets ——— */

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--tabbar);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 50px;
  padding: 6px 2px 2px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font: 600 11px var(--font-body);
  text-decoration: none;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
[data-person="johanna"] .tab[aria-current="page"] { background: var(--surface-2); }

/* ——— Mise en page ——— */

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 96px);
}

h1 {
  margin: 0;
  font: 700 34px/1.08 var(--font-display);
  text-transform: var(--display-case);
  letter-spacing: var(--display-spacing);
}
h2 {
  margin: 0;
  font: 600 22px/1.1 var(--font-display);
  text-transform: var(--display-case);
  letter-spacing: var(--display-spacing);
}
h3 {
  margin: 6px 0 0;
  font: 600 16px var(--font-body);
}
.sub { margin: 8px 0 0; color: var(--muted); }

.page-head { padding: 24px 4px 4px; }
.page-head + * { margin-top: 18px; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font: 600 13px var(--font-body);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.pill {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  font: 600 12px/1.2 var(--font-body);
  letter-spacing: .04em;
  white-space: nowrap;
  vertical-align: middle;
}
[data-person="thomas"] .pill { text-transform: uppercase; letter-spacing: .08em; }

.card {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.card > .sub { margin: 0; }

/* ——— Accueil : semaine ——— */

.hero { position: relative; isolation: isolate; overflow: hidden; padding: 26px 4px 6px; }

[data-person="thomas"] .hero::after {
  content: 'TRAIN';
  position: absolute;
  top: 2px;
  right: -8px;
  z-index: -1;
  color: transparent;
  font: 700 112px/1 var(--font-display);
  -webkit-text-stroke: 1px rgb(61 139 255 / .16);
  pointer-events: none;
}
/* Johanna : deux bulles douces en fond plutôt que des pictos */
[data-person="johanna"] .hero::before,
[data-person="johanna"] .hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
[data-person="johanna"] .hero::before { top: -30px; right: -40px; width: 170px; height: 170px; background: radial-gradient(circle, rgb(255 150 190 / .35), transparent 70%); }
[data-person="johanna"] .hero::after { top: 40px; right: 60px; width: 90px; height: 90px; background: radial-gradient(circle, rgb(180 140 255 / .30), transparent 70%); }

.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 20px; padding: 2px; }
.strip a {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font: 600 15px var(--font-display);
  text-decoration: none;
}
.strip a.has { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
.strip a.is-today { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-person="johanna"] .strip a { border-radius: 50%; }

.days { display: grid; gap: 12px; margin-top: 16px; }

.day {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.day.is-today { border-color: transparent; box-shadow: var(--shadow); }

.day-head { display: flex; align-items: center; gap: 14px; }
.day-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  font: 700 20px var(--font-display);
}
.is-today .day-badge { background: var(--pill-bg); color: var(--pill-text); }
[data-person="johanna"] .day-badge { border-radius: 50%; }
.day-title { flex: 1; min-width: 0; }
.day-title h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.day-title p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.done-chip { color: var(--good); font-weight: 600; }

.day-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.day-list li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.ex-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-sets { color: var(--muted); font: 500 14px var(--font-body); white-space: nowrap; }

.tag {
  flex: none;
  width: 44px;
  padding: 3px 0;
  border-radius: 6px;
  font: 700 11px var(--font-body);
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
}
.tag-haut { color: var(--haut); background: color-mix(in srgb, var(--haut) 15%, transparent); }
.tag-bas { color: var(--bas); background: color-mix(in srgb, var(--bas) 15%, transparent); }
[data-person="johanna"] .tag { border-radius: 999px; }

/* Bandeaux (séance en cours, cycle) */
.wo-banner, .cycle-banner { display: flex; align-items: center; gap: 12px; }
.wo-banner strong, .cycle-banner strong { display: block; font-size: 16px; }
.wo-banner small, .cycle-banner small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.cycle-banner .icon { color: var(--muted); }
.wo-banner { border-color: transparent; box-shadow: var(--shadow); }
.live-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); animation: pulse 1.4s ease-in-out infinite; }

/* ——— Boutons ——— */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-btn);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  font: 600 17px var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s, filter .2s, opacity .2s;
}
[data-person="thomas"] .btn { font: 600 17px var(--font-display); letter-spacing: .06em; text-transform: uppercase; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--border); }
.btn-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.btn-big { width: 100%; min-height: 58px; margin-top: 12px; font-size: 19px !important; }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; }

.link {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 15px var(--font-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.icon-btn.danger, .link.danger { color: var(--danger); }
.link.danger { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }

@media (hover: hover) {
  .btn:hover:not(:disabled) { filter: brightness(1.08); }
  .icon-btn:hover { background: var(--surface-2); }
}

/* ——— Formulaires ——— */

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { color: var(--muted); font: 600 12px var(--font-body); letter-spacing: .1em; text-transform: uppercase; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row.three { grid-template-columns: 1fr 1fr 1.1fr; }
.form { display: grid; gap: 14px; }
.inline-form { display: grid; grid-template-columns: 1.3fr 1fr; align-items: end; gap: 10px; }
.inline-form > .field:only-of-type, .inline-form > .btn { grid-column: 1 / -1; }

.input, select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: 500 17px var(--font-body);
}
.input:focus, select:focus { border-color: var(--accent); outline: none; }
input[type="date"].input { padding: 0 10px; }
select { padding-right: 36px; cursor: pointer; }
select:disabled { opacity: .5; cursor: not-allowed; }

.select { position: relative; display: block; }
.select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.unit-input { position: relative; display: block; }
.unit-input .input { padding-right: 42px; }
.unit-input > span { position: absolute; top: 50%; right: 12px; color: var(--muted); font-size: 14px; transform: translateY(-50%); pointer-events: none; }

details.add-block { border-top: 1px solid var(--border); padding-top: 12px; }
details.add-block summary { color: var(--accent); font-weight: 600; cursor: pointer; list-style: none; }
details.add-block summary::-webkit-details-marker { display: none; }
details.add-block summary::before { content: '+ '; }
details.add-block[open] summary { margin-bottom: 14px; }

/* ——— Vue jour ——— */

.day-view { padding-top: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--accent); font-weight: 600; text-decoration: none; }
.day-view h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 2px; }

.slots { display: grid; gap: 10px; margin-top: 20px; }
.slot { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.slot.is-open { border-color: transparent; box-shadow: var(--shadow); }
.slot-row { display: flex; align-items: center; padding-right: 8px; }
.slot-row .slot-head { flex: 1; min-width: 0; padding-right: 6px; }
.slot-head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 66px;
  padding: 12px 16px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.slot-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font: 700 18px var(--font-display);
}
[data-person="johanna"] .slot-num { border-radius: 50%; }
.slot.is-set .slot-num { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
.slot-title { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; font-size: 17px; }
.slot-title small { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 14px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.chev { flex: none; width: 10px; height: 10px; margin-right: 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; }
.is-open .chev { transform: rotate(45deg); }

.slot-body { display: grid; gap: 16px; padding: 4px 16px 16px; }
.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.zones button {
  min-height: 50px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: 600 15px var(--font-body);
  cursor: pointer;
}
.zones button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.slot-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.slot-actions .btn { padding: 0 30px; }

.add {
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  border: 2px dashed color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  font: 600 18px var(--font-display);
  letter-spacing: .04em;
  text-transform: var(--display-case);
  cursor: pointer;
}
.add:active { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Exemple de mouvement : les deux photos alternent */
.demo { display: grid; gap: 8px; margin: 0; }
.demo-frames { position: relative; overflow: hidden; aspect-ratio: 3 / 2; border-radius: var(--radius-sm); background: #fff; }
.demo-frames img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.demo.is-big .demo-frames { aspect-ratio: 2 / 1; }
.demo-frames img + img { animation: swap 2.4s steps(1) infinite; }
@keyframes swap { 50% { opacity: 0; } }
.demo figcaption a { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: none; }
/* ——— Séance en cours ——— */

.wo { display: grid; gap: 14px; padding-top: 10px; }
.wo > .card { margin: 0; }
.wo-top { display: flex; align-items: center; justify-content: space-between; }
.wo-total { color: var(--muted); font-size: 14px; }
.wo-total b { color: var(--text); font: 600 16px var(--font-body); font-variant-numeric: tabular-nums; }
.wo .eyebrow { margin: 4px 0 -8px; }
.wo-name { font-size: 30px; }

.steps { display: flex; gap: 6px; }
.steps .step { flex: 1; height: 6px; padding: 0; border: 0; border-radius: 99px; background: var(--border); cursor: pointer; }
.steps .step.is-done { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.steps .step.is-current { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.wo-presc { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px; }
.presc {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-height: 56px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  align-content: center;
  flex-wrap: wrap;
  line-height: 56px;
}
.presc b { color: var(--text); font: 700 24px var(--font-display); }
.presc.kg { line-height: normal; align-items: center; }
.presc.kg .input { width: 64px; min-height: 40px; padding: 0 6px; text-align: center; font: 700 20px var(--font-display); }

.chrono { justify-items: center; text-align: center; }
.chrono-time { font: 700 56px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.chrono.is-running .chrono-time { color: var(--accent); }
.chrono-btns { display: flex; align-items: center; gap: 10px; }
.chrono-btns .btn { min-width: 210px; }

.sets { display: flex; flex-wrap: wrap; gap: 10px; }
.set {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: 700 20px var(--font-display);
  cursor: pointer;
  transition: transform .12s;
}
[data-person="johanna"] .set { border-radius: 50%; }
.set:active { transform: scale(.94); }
.set.is-done { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
.set .icon { width: 26px; height: 26px; stroke-width: 3; }
.set-done { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--good); font-weight: 600; }
.sets + p { margin: 0; }

.wo-nav { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.wo .link { justify-self: center; }

/* ——— Chiffres ——— */

.hero-figure { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hero-figure strong { font: 700 52px/1 var(--font-body); letter-spacing: -.02em; }
.hero-figure span { color: var(--muted); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stat strong { font-size: 18px; font-weight: 600; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.delta.up { color: var(--good); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.tile { display: grid; gap: 2px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tile strong { font-size: 20px; font-weight: 600; }
.tile small { color: var(--muted); font-size: 12px; }

.rows { display: grid; margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 15px; }
.rows li:first-child { border-top: 0; }
.rows small { display: block; color: var(--muted); font-size: 13px; }

/* ——— Graphiques ——— */

.chart { position: relative; margin: 0 -4px; touch-action: pan-y; }
.chart:focus-visible { outline-offset: 4px; border-radius: var(--radius-sm); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 500 10.5px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--accent); opacity: .10; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font: 600 12px var(--font-body); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .goal { stroke: var(--muted); stroke-width: 1; }
.chart .bar path { fill: var(--accent); opacity: .45; transition: opacity .15s; }
.chart .bar.is-current path { opacity: 1; }
.chart .bar.is-hover path { opacity: .85; }
.chart .bar .hit { fill: transparent; }
.chart-tip {
  position: absolute;
  z-index: 2;
  display: grid;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 20px -8px rgb(0 0 0 / .35);
  font-size: 12px;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.chart-tip strong { font-size: 14px; }
.chart-tip span { color: var(--muted); }

/* ——— Corps ——— */

.measure-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.measure {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.measure strong { font-size: 16px; font-weight: 600; }
.measure small { color: var(--muted); font-size: 12px; }
.measure.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }

/* ——— Alimentation ——— */

.date-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.date-nav strong { font-weight: 600; }

.meter-block { display: grid; gap: 6px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 14px; }
.meter-head strong { color: var(--text); font-size: 18px; }
.meter { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.is-over span { background: var(--warn); }

.quick { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: 500 14px var(--font-body);
  cursor: pointer;
}
.chip small { color: var(--muted); font-size: 12px; }

/* ——— Cycle ——— */

.phase-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--phase); box-shadow: 0 0 0 4px color-mix(in srgb, var(--phase) 22%, transparent); }
.phase-chip {
  flex: none;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--phase) 14%, var(--surface));
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.phase-chip::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--phase); vertical-align: 1px; }
.phase-tip { margin: 12px 0 0; padding: 12px 14px; border-left: 4px solid var(--phase); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--phase) 10%, var(--surface)); font-size: 14px; }
.card > .phase-tip { margin: 0; }
.phase-tip strong { display: block; margin-bottom: 2px; }

.cycle-now { grid-template-columns: 140px 1fr; align-items: center; }
.ring { width: 140px; height: 140px; }
.ring-arcs circle { fill: none; stroke-width: 12; transform: rotate(-90deg); transform-origin: 70px 70px; }
.ring-marker { fill: var(--surface); stroke: var(--text); stroke-width: 3; }
.ring-day { fill: var(--text); font: 700 30px var(--font-display); text-anchor: middle; dominant-baseline: middle; }
.ring-sub { fill: var(--muted); font: 500 12px var(--font-body); text-anchor: middle; }
.phase-name { margin: 0; font: 600 22px var(--font-display); }
.phase-name::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; background: var(--phase); }

.cal-head, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head span { color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font: 500 14px var(--font-body);
  cursor: pointer;
}
.cal-day[style] { background: color-mix(in srgb, var(--phase) 24%, var(--surface)); }
.cal-day.ph-regles { background: var(--phase); color: #fff; font-weight: 600; }
.cal-day.is-predicted { opacity: .55; }
.cal-day.is-today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.cal-day.is-selected:not(.is-today) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--muted); }
.cal-day.is-start::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.cal-detail { margin: 0; font-size: 14px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; background: var(--phase); }

/* ——— Code d'accès ——— */

.lock { display: grid; gap: 8px; max-width: 320px; margin: 12vh auto 0; text-align: center; }
.lock .form { margin-top: 18px; }
.code-input { text-align: center; font-size: 28px; letter-spacing: .4em; }
.lock-error { margin: 0; color: var(--danger); font-weight: 600; }

/* ——— Toast ——— */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  z-index: 20;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  transform: translateX(-50%);
  animation: toast 2.6s ease forwards;
  pointer-events: none;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  10%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; }
}

@media (max-width: 360px) {
  .field-row.three, .tiles { grid-template-columns: 1fr 1fr; }
  .cycle-now { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
