/* FitBot web app — mobile first, thème sombre */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #f2f3f5;
  --muted: #9aa3b2;
  --accent: #ff6b35;
  --accent-2: #ff4500;
  --gold: #ffd700;
  --green: #57f287;
  --red: #ed4245;
  --blue: #5865f2;
  --purple: #a855f7;
  --radius: 18px;
  --radius-s: 12px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── Splash ── */
.splash { flex: 1; display: grid; place-content: center; text-align: center; gap: 8px; }
.splash-logo { font-size: 56px; animation: pulse 1.2s ease-in-out infinite; }
.splash-text { font-weight: 800; font-size: 22px; letter-spacing: .5px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .85 } 50% { transform: scale(1.12); opacity: 1 } }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20; padding: calc(var(--sat) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .brand { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.topbar .brand small { font-weight: 600; color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); object-fit: cover; border: 1px solid var(--border); }
.avatar.lg { width: 72px; height: 72px; }

/* ── Content ── */
.view { flex: 1; padding: 6px 16px calc(var(--tabbar) + var(--sab) + 24px); animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }
.view h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: -.3px; }
.view h2 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.accent { background: linear-gradient(145deg, #2a1a12, #171a21 60%); border-color: #4a2c1e; }
.card.gold { background: linear-gradient(145deg, #2a2412, #171a21 60%); border-color: #4a4020; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 12px 6px; background: var(--surface-2); border-radius: var(--radius-s); }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }

/* Streak hero */
.streak-hero { text-align: center; padding: 22px 16px 18px; }
.streak-hero .flame { font-size: 44px; line-height: 1; filter: drop-shadow(0 0 18px rgba(255,107,53,.45)); }
.streak-hero .num { font-size: 64px; font-weight: 900; line-height: 1; letter-spacing: -2px; margin-top: 6px; }
.streak-hero .lbl { color: var(--muted); font-weight: 600; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.chip.ok { color: var(--green); border-color: rgba(87,242,135,.35); background: rgba(87,242,135,.08); }
.chip.warn { color: var(--accent); border-color: rgba(255,107,53,.4); background: rgba(255,107,53,.1); }
.chip.rest { color: var(--muted); }
.chip.gold { color: var(--gold); border-color: rgba(255,215,0,.4); background: rgba(255,215,0,.08); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 99px; transition: width .6s ease; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 15px 18px; border-radius: 16px; border: 0; font-weight: 800; font-size: 16px; cursor: pointer;
  background: var(--surface-2); color: var(--text); transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 10px 28px -10px rgba(255,107,53,.7); }
.btn.discord { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.danger { color: var(--red); background: rgba(237,66,69,.1); border: 1px solid rgba(237,66,69,.3); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn .spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* Forms */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 84px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Photo picker */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo, .photo-add { aspect-ratio: 1; border-radius: 14px; overflow: hidden; position: relative; background: var(--surface-2); border: 1px dashed var(--border); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .rm { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-weight: 800; }
.photo-add { display: grid; place-content: center; text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.photo-add span { font-size: 26px; display: block; }

/* Segmented */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px; }
.item.me { border-color: rgba(255,107,53,.5); background: linear-gradient(90deg, rgba(255,107,53,.08), var(--surface)); }
.item .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; font-weight: 800; flex: none; }
.item .r small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.rank { width: 28px; text-align: center; font-weight: 800; color: var(--muted); flex: none; }
.rank.top { font-size: 20px; }

/* Heatmap */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); }
.heat i.l1 { background: #5a2a14; } .heat i.l2 { background: #a3431f; } .heat i.l3 { background: var(--accent); }

/* Achievements */
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ach { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px; }
.ach.locked { opacity: .45; filter: grayscale(.6); }
.ach .ic { font-size: 26px; }
.ach .n { font-weight: 800; margin-top: 4px; font-size: 14px; }
.ach .d { font-size: 12px; color: var(--muted); }
.ach .rar { font-size: 10px; font-weight: 800; letter-spacing: .5px; margin-top: 6px; }
.rar.COMMUN { color: #99aab5 } .rar.RARE { color: #3498db } .rar.ÉPIQUE { color: var(--purple) } .rar.LÉGENDAIRE { color: var(--gold) }
.ach.RARE { border-color: rgba(52,152,219,.35) } .ach.ÉPIQUE { border-color: rgba(168,85,247,.4) } .ach.LÉGENDAIRE { border-color: rgba(255,215,0,.45) }

/* Result */
.result { text-align: center; padding: 26px 16px; }
.result .big { font-size: 60px; }
.result h1 { margin: 6px 0 4px; }
.result .motiv { font-size: 17px; margin: 10px 0 16px; color: #ffd9c9; }
.unlock { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; text-align: left; margin-top: 8px; }
.unlock .ic { font-size: 26px; }

/* Rest days */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button { padding: 12px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 800; color: var(--muted); }
.days button.on { background: rgba(255,107,53,.15); border-color: var(--accent); color: var(--accent); }

/* Coach */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 15px; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; white-space: pre-wrap; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar) + var(--sab)); padding-bottom: var(--sab);
  display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 700; }
.tabbar a .i { font-size: 21px; line-height: 1; }
.tabbar a.on { color: var(--accent); }
.tabbar a.cta .i { width: 46px; height: 46px; border-radius: 50%; display: grid; place-content: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; margin-top: -18px; box-shadow: 0 8px 22px -6px rgba(255,107,53,.8); font-size: 24px; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 40px 24px calc(24px + var(--sab)); text-align: center; gap: 14px; }
.login .logo { font-size: 72px; filter: drop-shadow(0 0 24px rgba(255,107,53,.5)); }
.login h1 { font-size: 34px; margin: 0; letter-spacing: -1px; }
.login p { color: var(--muted); margin: 0 0 12px; }
.login .note { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* Misc */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar) + var(--sab) + 14px); z-index: 50; background: #262b36; border: 1px solid var(--border); color: var(--text); padding: 12px 14px; border-radius: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: fade .2s ease-out; }
.toast.err { border-color: rgba(237,66,69,.5); background: #2c1a1b; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), #262b36, var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; min-height: 60px; }
@keyframes sk { to { background-position: -200% 0 } }
.install { border: 1px dashed var(--border); border-radius: var(--radius-s); padding: 12px 14px; font-size: 13px; color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 12px; } .mt-l { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.badge { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }

/* ── Écrans ajoutés : boutique, duels, nutrition, stats ── */
.shop-item { display: flex; gap: 12px; align-items: center; }
.shop-item .ic { font-size: 30px; width: 44px; text-align: center; }
.shop-item .body { flex: 1; min-width: 0; }
.shop-item .price { font-weight: 800; white-space: nowrap; }
.owned { color: var(--green); font-size: 12px; font-weight: 700; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 99px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .col i { width: 100%; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .col small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.kv:first-child { border-top: 0; }
.kv b { text-align: right; }
.select { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pill-row button { flex: none; }
.duel-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.duel-vs .score { font-size: 30px; font-weight: 900; }
.duel-vs .vs { color: var(--muted); font-weight: 800; }
.meal { padding: 10px 0; border-top: 1px solid var(--border); }
.meal:first-child { border-top: 0; }
.meal .t { font-weight: 700; }
.meal .m { font-size: 12px; color: var(--muted); }
.ex { padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ex:first-child { border-top: 0; }
.ex small { color: var(--muted); display: block; }
.shortcuts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shortcuts a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); color: var(--text); font-weight: 700; font-size: 13px; }
.shortcuts a .i { font-size: 24px; }
.mini-avatar { width: 22px; height: 22px; border-radius: 50%; vertical-align: middle; object-fit: cover; }

/* ── Objectifs, défis, récap, photos, profil public ── */
.goal { padding: 10px 0; border-top: 1px solid var(--border); }
.goal:first-child { border-top: 0; }
.goal .row { align-items: baseline; }
.goal .done { color: var(--green); font-weight: 800; font-size: 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface-2); display: block; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 12px; }
.lightbox .cap { color: var(--muted); font-size: 13px; margin-top: 10px; text-align: center; }
.week { display: flex; gap: 6px; }
.week div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.week i { display: block; height: 34px; border-radius: 8px; background: var(--surface-2); margin-bottom: 4px; }
.week i.on { background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.week i.on2 { background: linear-gradient(180deg, var(--gold), var(--accent)); }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
.ex label { display: flex; gap: 10px; align-items: center; }
.ex input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.ex .load { width: 74px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; text-align: center; margin-left: auto; }
.ex.done label { text-decoration: line-through; color: var(--muted); }
.public { max-width: 520px; margin: 0 auto; padding: 24px 16px 40px; text-align: center; }
.public .avatar.xl { width: 96px; height: 96px; margin: 0 auto; }
.chip.copy { cursor: pointer; }
.item .del { background: transparent; border: 0; color: var(--muted); font-size: 18px; padding: 6px; flex: none; }

/* ── Poids, fil, hors ligne, progression des succès ── */
.ach .prog { margin-top: 6px; }
.ach .prog .progress { margin-top: 3px; height: 5px; }
.ach .prog small { font-size: 10px; color: var(--muted); font-weight: 700; }
.wchart { width: 100%; height: 150px; display: block; }
.wchart path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.wchart .area { fill: rgba(255,107,53,.12); stroke: none; }
.wchart circle { fill: var(--accent); }
.wchart text { fill: var(--muted); font-size: 10px; }
.wchart line { stroke: var(--border); stroke-width: 1; }
.feed-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px; margin-top: 10px; }
.feed-item .head { display: flex; gap: 10px; align-items: center; }
.feed-item .head .who { flex: 1; min-width: 0; }
.feed-item .head .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .head .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-item .meta { margin-top: 8px; font-size: 14px; }
.feed-item .cmt { margin-top: 6px; font-size: 13px; color: var(--muted); }
.feed-item img.pic { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 10px; background: var(--surface-2); }
.feed-item .gg { margin-top: 10px; display: flex; justify-content: flex-end; }
.feed-item .gg button.on { border-color: var(--accent); color: var(--accent); background: rgba(255,107,53,.12); }
.offline-banner { background: rgba(255,215,0,.1); border: 1px solid rgba(255,215,0,.35); border-radius: var(--radius-s); padding: 12px; margin-top: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 14px; }

/* ── Premier lancement, parrainage, admin ── */
.welcome { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; padding: 28px 18px 24px; max-width: 520px; margin: 0 auto; }
.welcome .dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 26px; }
.welcome .dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--surface-2); }
.welcome .dots i.on { width: 22px; background: var(--accent); }
.welcome .big { font-size: 56px; text-align: center; }
.welcome h1 { text-align: center; margin: 10px 0 6px; }
.welcome .sub { text-align: center; }
.welcome .grow { flex: 1; }
.welcome .foot { display: grid; gap: 10px; margin-top: 22px; }
.ref-banner { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: rgba(255,215,0,.08); border: 1px solid rgba(255,215,0,.35); display: flex; gap: 10px; align-items: center; text-align: left; font-size: 14px; }
.ref-banner img { width: 34px; height: 34px; border-radius: 50%; }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.admin-grid .stat .v { font-size: 22px; }
.bars.stack .col i.app { background: linear-gradient(180deg, var(--gold), #c9a200); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
