:root {
  --bg: #0a0707;
  --card: #170f0f;
  --card-2: #211615;
  --track: #2a1d1c;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --ink: #f3efe9;
  --ink-2: #d6cfca;
  --dim: #aca39d;
  --faint: #8f8580;
  --mute: #5c524e;
  --red: #8b0a00;
  --red-text: #d64a35;
  --red-soft: rgba(139, 10, 0, .2);
  --red-line: rgba(190, 40, 20, .55);
  --on-red: #fff;            /* texte sur la couleur principale */
  --on-red-soft: rgba(255, 255, 255, .16);
  --hi: var(--red);          /* moments forts : record, série */
  --kicker: var(--red-text);
  --badge-bg: rgba(139, 10, 0, .35);
  --badge-ink: #ff8f7d;
  --cream: #f3efe9;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --tabbar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red-text); }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app { max-width: 520px; margin: 0 auto; min-height: 100%; position: relative; }
.view { padding: calc(20px + var(--safe-t)) 20px calc(var(--tabbar-h) + var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 16px; outline: none; }
.view.no-tabbar { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- typo ---------- */
.kicker { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--kicker); }
.kicker.dim { color: var(--dim); }
.h1 { margin: 2px 0 0; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 30px; line-height: 1.05; letter-spacing: -.01em; text-transform: uppercase; }
.h2 { margin: 0; font-family: var(--display); font-weight: 900; font-style: italic; font-size: 22px; line-height: 1.1; text-transform: uppercase; }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sub { font-size: 13px; color: var(--dim); margin-top: 4px; }
.num { font-family: var(--display); font-weight: 900; font-variant-numeric: tabular-nums; }
.muted { color: var(--dim); }
.small { font-size: 12px; }

/* ---------- layout ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grow { flex: 1; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { height: 54px; width: auto; mix-blend-mode: screen; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.card.tight { padding: 12px 14px; border-radius: 16px; }
.card.accent { background: var(--red-soft); border-color: var(--red-line); }
.card.cream { background: var(--cream); color: #0a0707; border: 0; }
.card.dashed { background: transparent; border: 1px dashed var(--line-2); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; width: 100%; text-align: left; }
.item.accent { background: var(--red-soft); border-color: var(--red-line); }
.item.done { opacity: .65; }
.item .t { font-weight: 700; font-size: 14.5px; }
.item .s { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 14px; border: 0; background: var(--red); color: var(--on-red); font-weight: 800; font-size: 13.5px; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; -webkit-tap-highlight-color: transparent; transition: transform .12s ease, filter .12s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { background: var(--track); color: var(--faint); }
.btn.block { width: 100%; }
.btn.light { background: var(--cream); color: #0a0707; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); text-transform: none; letter-spacing: 0; font-weight: 700; }
.btn.outline { background: transparent; border: 1.5px solid currentColor; color: inherit; text-transform: none; letter-spacing: 0; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 12.5px; border-radius: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; flex: none; text-decoration: none; }
.icon-btn.red { background: var(--red); border-color: var(--red); color: var(--on-red); }
.link { background: none; border: 0; padding: 0; color: var(--red-text); font-weight: 700; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }

/* ---------- form ---------- */
.field { display: block; }
.field > span { display: block; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-size: 16px; }
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid var(--red-text); outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- chips / segments ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; }
.chip.on { background: var(--red); border-color: var(--red); color: var(--on-red); }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.segment button { min-height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--dim); font-weight: 700; font-size: 12.5px; }
.segment button.on { background: var(--red); color: var(--on-red); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.tabs a, .tabs button { padding: 0 0 10px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); background: none; border: 0; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs .on { color: var(--ink); border-bottom-color: var(--red); }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--red-text); }
.bar.ink > i { background: var(--ink); }
.bar.gray > i { background: var(--faint); }
.macro { font-size: 12px; }
.macro .row { gap: 6px; justify-content: space-between; margin-bottom: 4px; }
.ring { position: relative; flex: none; }
.ring .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }

/* ---------- check box ---------- */
.check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--mute); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.check.on { background: var(--red); border-color: var(--red); }
.habit { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: 13px; font-weight: 600; text-align: left; min-height: 48px; }
.habit.on { background: var(--red-soft); border-color: var(--red-line); }

/* ---------- hero ---------- */
.hero { position: relative; border-radius: 20px; overflow: hidden; border: 1px solid var(--red-line); min-height: 176px; display: flex; }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; filter: grayscale(1); }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,7,7,.96) 0%, rgba(10,7,7,.78) 55%, rgba(10,7,7,.25) 100%); }
.hero .in { position: relative; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; width: 100%; }

/* ---------- video ---------- */
.video { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 16 / 10; border: 1px solid var(--line); }
.video video, .video img { width: 100%; height: 100%; object-fit: cover; }
.video .placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(10,7,7,.55); text-align: center; padding: 16px; font-size: 13px; color: var(--ink-2); }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; flex: none; background: var(--track); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .play { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--red); display: flex; align-items: center; justify-content: center; }

/* ---------- sets table ---------- */
.sets-head, .set-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 6px; align-items: center; }
.sets-head { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 2px 4px; }
.set-row { padding: 5px 2px; border-radius: 10px; }
.set-row.done { background: var(--red-soft); }
.set-row .n { text-align: center; font-weight: 800; }
.set-row .prev { font-size: 12.5px; color: var(--dim); }
.set-row input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); text-align: center; font-weight: 800; font-size: 16px; }
.set-ok { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--mute); background: transparent; display: flex; align-items: center; justify-content: center; }
.set-ok.on { background: var(--red); border-color: var(--red); }

/* ---------- rest timer ---------- */
.rest { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--safe-b)); width: min(480px, calc(100% - 32px)); z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--cream); color: #0a0707; box-shadow: 0 18px 40px -12px rgba(0,0,0,.7); }
.rest .time { font-family: var(--display); font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; }
.rest .bar { flex: 1; background: #d9d1c9; }
.rest .bar > i { background: var(--red); }

/* ---------- club ---------- */
.post { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.post .head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: var(--track); display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink); }
.avatar.red { background: var(--red); color: var(--on-red); }
.post .text { padding: 0 14px 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.post .media img { width: 100%; max-height: 420px; object-fit: cover; }
.post .duo { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.post .duo img { height: 180px; width: 100%; object-fit: cover; }
.post .actions { display: flex; gap: 18px; padding: 8px 14px 12px; }
.post .actions button { background: none; border: 0; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; min-height: 36px; padding: 0; }
.post .actions button.on svg { fill: var(--red); stroke: var(--red); }
.badge { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 4px 8px; border-radius: 8px; background: var(--badge-bg); color: var(--badge-ink); }
.record { margin: 0 14px 12px; padding: 14px 16px; border-radius: 14px; background: var(--cream); color: #0a0707; display: flex; align-items: center; justify-content: space-between; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 6px 4px var(--safe-b); background: rgba(13, 9, 9, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: flex-start; z-index: 20; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 52px; padding-top: 6px; color: var(--faint); text-decoration: none; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; -webkit-tap-highlight-color: transparent; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--ink); }
.tab.on svg { color: var(--red-text); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: #120c0b; border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease; }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--mute); margin: 0 auto 4px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: calc(16px + var(--safe-t)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--cream); color: #0a0707; font-weight: 700; font-size: 13.5px; padding: 12px 16px; border-radius: 14px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.6); transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--dim); font-size: 13px; padding: 20px 12px; }
.photo-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 0; border-radius: 12px; background: var(--card); border: 0; color: var(--ink); }
.day span { font-size: 10.5px; color: var(--dim); }
.day b { font-size: 14px; }
.day i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day i.done { background: var(--red-text); }
.day i.plan { background: var(--mute); }
.day.today { background: var(--red); color: var(--on-red); }
.day.today span { color: var(--on-red); }
.day.today i.plan, .day.today i.done { background: var(--on-red); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- inscription ---------- */
.ob-hero { position: relative; margin: calc(-20px - var(--safe-t)) -20px calc(-24px - var(--safe-b)); min-height: 100vh; min-height: 100dvh; display: flex; background: #000; }
.ob-in { position: relative; width: 100%; padding: calc(36px + var(--safe-t)) 24px calc(28px + var(--safe-b)); display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.ob-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.ob-logo { width: 300px; max-width: 82%; }
.ob-phrase { width: 230px; max-width: 64%; }
.ob-code { text-align: center; font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: .18em; text-transform: uppercase; }
.ob-step { padding-top: 8px; }

/* ---------- barre du haut : logo centré ---------- */
.appbar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin-bottom: -2px; }
.appbar-logo { grid-column: 2; justify-self: center; display: block; }
.appbar .brand { height: 50px; }
.appbar-me { width: 40px; height: 40px; text-decoration: none; justify-self: end; }

/* ---------- icônes sur la couleur principale ---------- */
.check.on, .set-ok.on, .thumb .play { color: var(--on-red); }
.hi { color: var(--hi); }

/* ---------- thèmes noir et blanc ---------- */
/* mono : tout en noir et blanc, le blanc sert de couleur d'action */
html[data-theme="mono"], html[data-theme="mono-red"] {
  --bg: #000;
  --card: #111;
  --card-2: #1a1a1a;
  --track: #262626;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --ink: #f5f5f5;
  --ink-2: #d4d4d4;
  --dim: #a3a3a3;
  --faint: #8a8a8a;
  --mute: #525252;
  --red: #f5f5f5;
  --red-text: #f5f5f5;
  --red-soft: rgba(255, 255, 255, .07);
  --red-line: rgba(255, 255, 255, .5);
  --on-red: #000;
  --on-red-soft: rgba(0, 0, 0, .08);
  --cream: #f5f5f5;
  --hi: #f5f5f5;
  --kicker: #a3a3a3;
  --badge-bg: rgba(255, 255, 255, .12);
  --badge-ink: #f5f5f5;
}
/* mono-red : pareil, avec une touche de rouge pour les moments forts */
html[data-theme="mono-red"] {
  --hi: #c81900;
  --badge-bg: #c81900;
  --badge-ink: #fff;
}
html[data-theme="mono"] .hero .shade, html[data-theme="mono-red"] .hero .shade { background: linear-gradient(90deg, rgba(0,0,0,.95) 0%, rgba(0,0,0,.75) 55%, rgba(0,0,0,.2) 100%); }

/* éléments posés sur une carte claire (défi du jour, minuteur, record) */
:root { --light-accent: var(--red); --light-btn: var(--red); --light-btn-ink: #fff; }
html[data-theme="mono"] { --light-accent: #000; --light-btn: #000; --light-btn-ink: #f5f5f5; }
html[data-theme="mono-red"] { --light-accent: #c81900; --light-btn: #000; --light-btn-ink: #f5f5f5; }
.btn.on-light { background: var(--light-btn); color: var(--light-btn-ink); }
.rest .bar > i { background: var(--light-btn); }

/* ---------- pacte ---------- */
.pact { border-radius: 20px; padding: 20px; background: var(--card); border: 1px solid var(--red-line); display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.pact p { margin: 0; }
.pact b { color: var(--ink); }
.pact-red { color: var(--red-text); font-weight: 800; }
.pact-big { font-family: var(--display); font-weight: 900; font-style: italic; font-size: 21px; line-height: 1.2; color: var(--ink); text-transform: uppercase; }
.sign-pad { display: block; width: 100%; height: 150px; border-radius: 16px; border: 1.5px dashed var(--line-2); background: var(--card) linear-gradient(transparent 108px, var(--line-2) 108px, var(--line-2) 109px, transparent 109px); touch-action: none; cursor: crosshair; }
.pact-sign-img { width: 200px; height: auto; opacity: .9; margin-top: 4px; }
.pact-home { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }


/* espace coach */
.appbar-coach { width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red-text); text-decoration: none; }
.post .del { margin-left: auto; background: none; border: 0; color: var(--dim); padding: 6px; display: inline-flex; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--track); border-top-color: var(--red-text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
