:root {
  --bg: #000000;
  --bg2: #0b0b0b;
  --card: #121212;
  --card2: #1c1c1c;
  --line: #262626;
  --text: #ffffff;
  --muted: #9b9b9b;
  --accent: #6cace3;
  --accent2: #8ec3ee;
  --on-accent: #000000;
  --title: "Kanit", "Montserrat", sans-serif;
  --ok: #3ccf7a;
  --warn: #ffb020;
  --bad: #ff4d5e;
  --r: 14px;
  --tabs: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent2); }
button, input, select, textarea { font: inherit; color: inherit; }
.splash { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- Shell ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(0, 0, 0, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand img { height: 34px; width: auto; display: block; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pill.demo { background: rgba(255, 176, 32, .15); color: var(--warn); }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--tabs) + env(safe-area-inset-bottom) + 24px); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(0, 0, 0, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabs a svg { width: 23px; height: 23px; }
[hidden] { display: none !important; }
.tabs a.on { color: var(--accent); }
.badge {
  position: absolute; top: 7px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Typo / layout ---------- */
h1 { font-family: var(--title); font-style: italic; font-weight: 800; font-size: 27px; margin: 4px 0 14px; letter-spacing: -.2px; text-transform: uppercase; line-height: 1.15; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; margin-bottom: 8px; }
.back svg { width: 18px; height: 18px; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; border: 1px dashed var(--line); border-radius: var(--r); }
.err { background: rgba(255, 77, 94, .1); border: 1px solid rgba(255, 77, 94, .4); color: #ffb3bb; padding: 12px; border-radius: var(--r); }
pre.content { white-space: pre-wrap; font-family: inherit; margin: 0; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card + .card { margin-top: 10px; }
a.card, .card.link { display: block; color: inherit; text-decoration: none; cursor: pointer; }
a.card:active, .card.link:active { background: var(--card2); }
.card.bar { border-left: 4px solid var(--c, var(--accent)); }
.kind { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--c); }
.kind::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip-ok { color: var(--ok); font-weight: 700; font-size: 13px; }
.chip-todo { color: var(--warn); font-weight: 700; font-size: 13px; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--card2); color: var(--muted); }
.tag.draft { background: rgba(255, 176, 32, .15); color: var(--warn); }

/* ---------- Forms ---------- */
label.f { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 44px; height: 40px; border: none; background: none; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 11px; padding: 11px 16px; font-weight: 700; cursor: pointer;
  background: var(--card2); color: var(--text); text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: rgba(255, 77, 94, .15); color: var(--bad); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px; }
.btn:disabled { opacity: .5; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--bg2); color: var(--muted); padding: 7px 13px; border-radius: 99px; font-weight: 700; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* ---------- Planning ---------- */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.weeknav b { font-size: 15px; }
.day { margin-bottom: 14px; }
.day-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.day-h .d { font-weight: 800; text-transform: capitalize; }
.day-h .d.today { color: var(--accent); }
.day .none { color: var(--muted); font-size: 13px; padding: 8px 2px; }
.sess-kinds { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; }

/* ---------- Athlète : bande semaine ---------- */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.strip button {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 8px 0 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.strip .wd { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.strip .dn { font-size: 17px; font-weight: 800; }
.strip .pt { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.strip .has .pt { background: var(--accent); }
.strip .done .pt { background: var(--ok); }
.strip .on { background: var(--accent); border-color: var(--accent); }
.strip .on .wd, .strip .on .dn { color: var(--on-accent); }
.strip .on .pt { background: var(--on-accent); }
.strip .td .dn { text-decoration: underline; text-underline-offset: 3px; }
.blk { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.blk:first-of-type { border-top: 0; }
.blk .t { font-weight: 700; }
.blk svg { width: 18px; height: 18px; color: var(--muted); flex: none; }

/* ---------- Résultats / vidéos ---------- */
video { width: 100%; max-height: 70vh; border-radius: 12px; background: #000; margin-top: 10px; }
.score { font-size: 22px; font-weight: 800; }
.kv { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; }
.kv div { font-size: 13px; color: var(--muted); }
.kv b { color: var(--text); font-size: 15px; }
.pct { color: var(--accent2); font-weight: 700; }
.board { width: 100%; border-collapse: collapse; }
.board td { padding: 8px 4px; border-top: 1px solid var(--line); }
.board tr.me td { color: var(--accent2); font-weight: 700; }
.board td.n { width: 28px; color: var(--muted); font-weight: 800; }
.board td.s { text-align: right; font-weight: 800; }

/* ---------- Avatars / commentaires / chat ---------- */
.av {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.av.lg { width: 52px; height: 52px; font-size: 18px; }
.cmt { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.cmt:first-child { border-top: 0; }
.cmt .who { font-weight: 700; font-size: 13px; }
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.bub { max-width: 80%; padding: 9px 13px; border-radius: 16px; background: var(--card2); white-space: pre-wrap; word-wrap: break-word; }
.bub.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.bub.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.bub .tm { display: block; font-size: 10px; opacity: .7; margin-top: 3px; }
.composer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); z-index: 9;
  background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px;
}
.composer form { max-width: 728px; margin: 0 auto; display: flex; gap: 8px; }
.composer input { flex: 1; }

/* ---------- Éditeur ---------- */
.eblock { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r); padding: 12px; margin-top: 12px; }
.eblock .tools { display: flex; gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label.f { margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sticky-save { position: sticky; bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 10px); margin-top: 16px; z-index: 5; }

/* ---------- Records ---------- */
.rec { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.rec:first-child { border-top: 0; }
.rec .kg { font-size: 20px; font-weight: 800; }
.pcts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.pcts div { background: var(--bg2); border-radius: 10px; padding: 8px; text-align: center; }
.pcts small { display: block; color: var(--muted); font-weight: 700; }
.pcts b { font-size: 16px; }

/* ---------- Chrono ---------- */
.timer { text-align: center; padding: 24px 10px; }
.timer .big { font-family: var(--title); font-style: italic; font-size: clamp(64px, 22vw, 120px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; line-height: 1; }
.timer .phase { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; color: var(--muted); }
.timer .phase.work { color: var(--accent); }
.timer .phase.rest { color: var(--ok); }
.timer .sub { color: var(--muted); margin-top: 10px; font-weight: 700; }

/* ---------- Auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 20px 40px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth .logo img { width: 100%; max-width: 320px; height: auto; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }

@media (min-width: 700px) {
  .pcts { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- Note du coach ---------- */
.cnote { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: rgba(108, 172, 227, .1); border-left: 3px solid var(--accent); white-space: pre-wrap; font-size: 14px; }
.cnote-h { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); margin-bottom: 2px; }

/* ---------- Records dépliables ---------- */
.rlift { padding: 0; }
.rlift-h { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; background: none; border: 0; cursor: pointer; text-align: left; }
.rlift-h .kg { font-size: 20px; font-weight: 800; }
.rlift-h svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.rlift.open { border-color: var(--accent); }
.rlift > :not(.rlift-h) { margin-left: 14px; margin-right: 14px; }
.rlift > :last-child:not(.rlift-h) { margin-bottom: 14px; }
.chart { width: 100%; height: auto; display: block; margin-top: 10px; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-ax { fill: var(--muted); font-size: 10px; font-weight: 600; }
.ch-area { fill: rgba(108, 172, 227, .14); }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.ch-dot.last { fill: var(--accent); }
.ch-val { fill: var(--text); font-size: 11px; font-weight: 800; }

/* iPhone (appli installée) : une page plus courte que l'écran décale la barre du bas.
   On force chaque page à remplir au moins tout l'écran. */
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; min-height: 100lvh; }
main { min-height: 100vh; min-height: 100lvh; }
