/* =====================================================================
   KLEYO — feuille de style
   Pour changer l'apparence de tout le site, modifie les réglages ci-dessous.
   ===================================================================== */
:root {
  /* Couleurs */
  --bg: #0F0E0C;          /* fond */
  --surface: #1A1814;     /* cartes */
  --surface-2: #221F1A;   /* fonds secondaires */
  --line: #2E2A23;        /* traits et bordures */
  --text: #F2EDE4;        /* texte principal */
  --muted: #A8A092;       /* texte secondaire */
  --gold: #D4A84B;        /* couleur principale */
  --gold-hover: #E8C470;
  --bronze: #C08A5B;      /* rang Recrue, médailles communes */
  --silver: #C9CCD3;      /* rang Hoplite, médailles rares */
  --gold-pale: #F2DDA4;   /* légendaire */
  --danger: #EA8C70;      /* erreurs, éliminés */

  /* Polices */
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Formes */
  --radius: 14px;
  --radius-lg: 20px;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; margin: 0; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.has-nav { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

a { color: var(--gold); }
a:hover { color: var(--gold-hover); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

/* ===== En-tête ===== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand img { width: 30px; height: auto; display: block; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.16em; }
.link-quiet { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.link-quiet:hover { color: var(--text); }
.link-button { font: inherit; font-size: 0.95rem; background: none; border: 0; cursor: pointer; padding: 0; min-height: 44px; }

/* ===== Boutons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  background: var(--gold);
  color: var(--bg);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.btn:hover { background: var(--gold-hover); color: var(--bg); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-block { display: flex; width: 100%; }
.btn-outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.btn-outline:hover { background: var(--surface); color: var(--text); }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.btn[hidden] { display: none; }

/* ===== Titres de section ===== */
.app { max-width: 640px; margin: 0 auto; padding: 8px 20px 48px; display: grid; gap: 32px; }
.app[hidden] { display: none; }
.section-title, .app-section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.app-section > h2 { margin-bottom: 12px; }
.app-section { scroll-margin-top: 16px; }
.eyebrow { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }

/* ===== Médaillon (emblème) ===== */
.medallion {
  --ring: var(--bronze);
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 4px solid var(--ring);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.medallion::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 2px dotted var(--ring);
  opacity: 0.8;
}
.medallion img { width: 74%; height: auto; display: block; margin-left: 4%; }
.medallion.is-silver { --ring: var(--silver); }
.medallion.is-gold { --ring: var(--gold); }
.medallion.large { width: 140px; height: 140px; border-width: 5px; }

/* ===== Profil en tête de page ===== */
.hero-profile { display: flex; align-items: center; gap: 18px; text-decoration: none; color: var(--text); }
.hero-profile .who { display: grid; gap: 4px; }
.hero-profile .name { font-size: 1.4rem; font-weight: 800; }
.hero-profile .sub { font-size: 0.9rem; color: var(--muted); }

/* ===== Carte série (flamme) ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.flame-card { display: grid; gap: 18px; scroll-margin-top: 20px; }
.flame-head { display: flex; align-items: center; gap: 16px; }
.flame-head img { width: 76px; height: auto; flex-shrink: 0; }
.flame-head .count { display: block; font-size: 4rem; line-height: 0.9; font-weight: 800; font-stretch: 75%; }
.flame-head .label { color: var(--muted); font-size: 0.9rem; }
.flame-week { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.week-status { color: var(--text); font-size: 0.95rem; }

.today-cells { display: flex; gap: 6px; flex-shrink: 0; }
.today-cells .cell { width: 26px; height: 26px; border-radius: 6px; }

.cell { aspect-ratio: 1; border-radius: 3px; background: var(--line); }
.cell.done { background: var(--gold); }
.cell.todo { background: transparent; box-shadow: inset 0 0 0 2px var(--gold); }

/* Historique 12 semaines */
.weeks { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; }
.week { display: flex; flex-direction: column-reverse; gap: 5px; }
.week.missed .cell.done { background: var(--muted); }

/* ===== Champs ===== */
.field { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.field[hidden] { display: none; }
.field input, .field select {
  font: inherit;
  font-weight: 400;
  font-size: 1rem; /* 16px minimum : évite le zoom automatique sur iPhone */
  padding: 13px 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.field select { max-width: 160px; }
.field input::placeholder { color: #6E675C; }
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 168, 75, 0.2); }
.field input:disabled { opacity: 0.6; }

.message { font-size: 0.95rem; }
.message:empty { display: none; }
.message.is-error { color: var(--danger); }
.message.is-info { color: var(--text); background: var(--surface-2); padding: 12px 14px; border-radius: 12px; }

/* ===== Listes (séances, défis, membres, fil) ===== */
.seance-list, .defi-list, .member-list, .feed { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.seance-list li, .member-list li, .feed li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.seance-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.seance-list li.empty, .defi-list li.empty { color: var(--muted); padding: 14px 0; }
.seance-day { display: block; font-weight: 700; }
.seance-day::first-letter { text-transform: uppercase; }
.seance-note { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.defi-list { border-top: 0; display: grid; gap: 10px; }
.defi-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
}
.defi-list li a:hover { border-color: var(--gold); }
.defi-name { font-weight: 700; font-size: 1.05rem; }
.defi-type { color: var(--gold); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }

.member-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.member-name { display: block; font-weight: 700; }
.member-status { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.member-status.is-out { color: var(--danger); }
.mini-cells { display: flex; gap: 4px; flex-shrink: 0; }
.mini-cells .cell { width: 14px; height: 14px; }

.feed li { display: grid; gap: 2px; }
.feed-text { color: var(--muted); }
.feed-text strong { color: var(--text); font-weight: 700; }
.feed-note { font-size: 0.95rem; }
.feed-when { color: var(--muted); font-size: 0.8rem; }

/* ===== Page défi ===== */
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.back-link:hover { color: var(--text); }
.defi-title { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; line-height: 1.15; letter-spacing: 0.03em; }
.defi-meta { margin-top: 8px; color: var(--muted); }
.gage { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--danger); border-radius: 16px; }
.gage[hidden] { display: none; }
.gage-label { color: var(--danger); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.gage-text { font-weight: 700; font-size: 1.05rem; }
.defi-score .streak-head { display: flex; align-items: flex-end; gap: 12px; }
.defi-score .streak-count { font-size: 4.5rem; line-height: 0.85; font-weight: 800; font-stretch: 75%; color: var(--gold); }
.defi-score .streak-label { color: var(--muted); padding-bottom: 4px; }
.defi-score .week-status { margin-top: 14px; }

.invite-link { padding: 12px 14px; background: var(--surface-2); border-radius: 12px; color: var(--muted); font-size: 0.9rem; word-break: break-all; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.danger-zone { padding-top: 20px; border-top: 1px solid var(--line); }
.link-danger { color: var(--danger); }

fieldset.choice-group { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
fieldset.choice-group legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; padding: 0; color: var(--muted); }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400; }
.choice input { margin-top: 4px; accent-color: var(--gold); }
.choice:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.choice-title { display: block; font-weight: 700; color: var(--text); }
.choice-desc { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
#view-create[hidden], #view-defi[hidden] { display: none; }
.auth-form { display: grid; gap: 18px; }

/* ===== Barre de navigation ===== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1;
  max-width: 76px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--gold); }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .tab-main {
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  margin-top: -30px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  justify-content: center;
  box-shadow: 0 0 0 6px var(--bg);
}
.tabbar .tab-main svg { width: 28px; height: 28px; }

/* ===== Encart d'installation ===== */
.install { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.install[hidden] { display: none; }
.install-title { display: block; font-weight: 700; }
.install-text { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.install-actions { display: flex; align-items: center; gap: 14px; }

/* ===== Accueil public ===== */
.welcome {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}
.welcome .bg-laurel { position: absolute; left: 50%; top: 60px; width: 560px; max-width: none; transform: translateX(-50%); opacity: 0.035; pointer-events: none; }
.welcome > * { position: relative; }
.emblem { position: relative; width: 150px; height: 150px; margin-top: 40px; }
.emblem .laurel { position: absolute; left: -33px; top: -18px; width: 216px; max-width: none; }
.emblem .medallion { width: 150px; height: 150px; border-width: 6px; }
.welcome h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.8rem, 13vw, 3.6rem); letter-spacing: 0.14em; line-height: 1; margin-top: 8px; }
.tagline { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.42em; color: var(--gold); }
.welcome .lead { color: var(--muted); max-width: 300px; font-size: 1.05rem; }
.promises { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.promises div { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 6px; font-size: 0.85rem; font-weight: 600; }
.promises div + div { border-left: 1px solid var(--line); }
.promises img { width: 36px; height: 36px; }
.welcome .actions { margin-top: auto; width: 100%; display: grid; gap: 12px; }

/* ===== Connexion ===== */
.auth { max-width: 420px; margin: 0 auto; padding: 24px 20px 64px; }
.auth-title { font-family: var(--font-display); font-weight: 700; font-size: 2rem; letter-spacing: 0.04em; line-height: 1.1; }
.app-title { font-family: var(--font-display); font-weight: 700; font-size: 2rem; letter-spacing: 0.04em; line-height: 1.1; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 28px 0; padding: 4px; background: var(--surface); border-radius: var(--radius); }
.tab { font: inherit; font-size: 0.95rem; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.tab.is-active { background: var(--surface-2); color: var(--gold); font-weight: 700; box-shadow: inset 0 0 0 1px var(--line); }
.invite-hint { margin-top: 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--gold); border-radius: 12px; font-size: 0.95rem; }
.invite-hint[hidden] { display: none; }
.legal-note { font-size: 0.85rem; color: var(--muted); }
.legal-note[hidden] { display: none; }
.legal-note a { color: var(--text); }

/* ===== Profil ===== */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.profile-head .name { font-size: 1.6rem; font-weight: 800; }

/* ===== Pages légales ===== */
.legal { max-width: 680px; margin: 0 auto; padding: 32px 20px 96px; }
.legal-date { margin-top: 10px; color: var(--muted); font-size: 0.95rem; }
.legal h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: 0.04em; margin-top: 40px; margin-bottom: 10px; }
.legal p, .legal li { max-width: 65ch; color: var(--text); }
.legal p { margin-top: 12px; }
.legal ul { margin-top: 12px; padding-left: 20px; display: grid; gap: 8px; }

/* ===== Pied de page ===== */
.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-link { color: var(--muted); text-decoration: none; }
.footer-link:hover { color: var(--text); }

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

#view-create .auth-form { margin-top: 24px; }

/* ===== Rangs : métaux du médaillon ===== */
.medallion.is-bronze { --ring: var(--bronze); }
.medallion.is-pale { --ring: var(--gold-pale); }
.medallion.has-laurel::before {
  content: "";
  position: absolute;
  left: -24%;
  top: -14%;
  width: 148%;
  height: 128%;
  background: url(/laurier.svg) center / contain no-repeat;
  pointer-events: none;
}
.rank-label { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ring, var(--bronze)); }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 4px; transition: width 0.6s ease; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; color: var(--muted); }
.progress-meta strong { color: var(--gold); }
.hero-profile .who { flex-grow: 1; }

/* ===== Échelle des rangs (profil) ===== */
.ranks { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.ranks li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ranks .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; }
.ranks li.done .dot { background: var(--metal); border-color: var(--metal); }
.ranks li.now .dot { border: 4px solid var(--metal); }
.ranks .rank-name { flex-grow: 1; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.ranks li.now .rank-name { color: var(--text); }
.ranks .rank-min { font-size: 0.85rem; color: var(--muted); }
.ranks .you { font-family: var(--font); font-size: 0.75rem; font-weight: 800; color: var(--gold); letter-spacing: 0; }

/* ===== Écrans de récompense ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 14, 12, 0.985);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay-inner { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.overlay-inner .torch { width: 120px; height: auto; animation: rise 0.6s ease both; }
.big-gain { font-size: 4.5rem; line-height: 0.9; font-weight: 800; font-stretch: 75%; color: var(--gold); animation: pop 0.5s 0.15s ease both; }
.gain-label { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.2em; margin-top: -8px; }
.overlay-inner p { color: var(--muted); }
.overlay-inner p strong { color: var(--text); }
.gain-list { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; gap: 8px; }
.gain-list li { display: flex; justify-content: space-between; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-weight: 600; }
.gain-list li span:last-child { color: var(--gold); font-weight: 800; }
.overlay-actions { width: 100%; display: flex; gap: 10px; }
.overlay-actions .btn { flex: 1; }
.rank-title { font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; letter-spacing: 0.12em; color: var(--gold); }
.overlay-inner .medallion { animation: rise 0.7s ease both; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .big-gain, .overlay-inner .torch, .overlay-inner .medallion { animation: none; }
}

/* ===== Médailles ===== */
.medal-svg { display: block; flex-shrink: 0; }
.medal-svg.is-locked { filter: grayscale(1) brightness(0.45); }
.medal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 22px; column-gap: 10px; }
.medal { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.medal-lock {
  position: absolute;
  top: 46px;
  left: calc(50% + 14px);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.medal-name { font-size: 0.8rem; font-weight: 700; line-height: 1.25; }
.medal.is-locked .medal-name { color: var(--muted); }
.medal-cond { font-size: 0.72rem; line-height: 1.3; color: var(--muted); }
.medal-rarity { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

.next-medal { display: flex; align-items: center; gap: 16px; }
.next-medal .body { flex-grow: 1; display: grid; gap: 6px; }
.next-medal .title { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.03em; }
.next-medal .cond { font-size: 0.9rem; color: var(--muted); }
.medal-count { font-size: 0.9rem; color: var(--muted); }
.medal-count strong { color: var(--gold); }

/* ===== Page Défis ===== */
.join-row { display: flex; gap: 10px; }
.join-row .field { flex-grow: 1; }
.join-row .btn { align-self: flex-end; }
.defi-members { font-size: 0.85rem; color: var(--muted); display: block; margin-top: 2px; }
.defi-list li a .left { display: grid; gap: 2px; }

/* ===== Épreuves ===== */
.rarity-tag { display: inline-block; padding: 2px 9px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.ep-list { display: grid; gap: 12px; }
.ep-card { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none; }
.ep-card.is-done { border-color: var(--gold); }
.ep-card .body { flex-grow: 1; display: grid; gap: 6px; min-width: 0; }
.ep-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ep-card .reward { font-size: 0.8rem; font-weight: 800; color: var(--gold); white-space: nowrap; }
.ep-card .title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.03em; }
.ep-card .cond { font-size: 0.85rem; color: var(--muted); }
.ep-card .state { font-size: 0.8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ep-card.is-done .state { color: var(--gold); }
.ep-row { display: flex; align-items: center; gap: 10px; }
.ep-row .progress { flex-grow: 1; height: 6px; }
.ep-intro { color: var(--muted); margin-top: 8px; }
.ep-next { color: var(--muted); font-size: 0.9rem; }
.ep-next strong { color: var(--text); }

/* ===== Type de séance ===== */
.seance-type { margin: 0; }
.run-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.run-fields[hidden] { display: none; }
.field { min-width: 0; }
.field input { width: 100%; min-width: 0; }
.run-fields .field span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-km { font-weight: 800; color: var(--gold); white-space: nowrap; }
#c-seances-opts[hidden], #c-km-opts[hidden] { display: none; }
.field input[type="radio"], .choice input { width: auto; flex-shrink: 0; }
#view-defi { display: grid; gap: 24px; }
#view-defi[hidden] { display: none; }
#view-defi .gage, #view-defi .defi-score { margin-top: 0; }
#view-defi .defi-meta { margin-top: -14px; }

/* ===== Discussion ===== */
body.chat-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.chat-head .titles { display: grid; min-width: 0; }
.chat-head .t1 { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .t2 { font-size: 0.8rem; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); border-radius: 12px; cursor: pointer; text-decoration: none; }
.icon-btn:hover { color: var(--text); background: var(--surface); }
.chat-scroll { flex-grow: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-list { list-style: none; margin: 0 auto; padding: 16px 14px 8px; max-width: 640px; display: flex; flex-direction: column; gap: 4px; }
.chat-day { align-self: center; margin: 14px 0 8px; padding: 4px 12px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.chat-empty { align-self: center; text-align: center; color: var(--muted); max-width: 280px; margin-top: 30vh; }
.msg { max-width: 80%; align-self: flex-start; display: grid; gap: 2px; }
.msg.mine { align-self: flex-end; }
.msg-author { font-size: 0.75rem; font-weight: 800; color: var(--gold); margin: 8px 0 0 12px; }
.msg-bubble {
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  padding: 9px 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.msg.mine .msg-bubble { background: #3A2F17; border-color: #5A4722; border-radius: 18px 18px 6px 18px; }
.msg-time { font-size: 0.68rem; color: var(--muted); margin: 0 10px; }
.msg.mine .msg-time { text-align: right; }
.msg-actions { display: flex; gap: 8px; margin: 4px 6px 6px; }
.msg.mine .msg-actions { justify-content: flex-end; }
.msg-actions button { font: inherit; font-size: 0.8rem; font-weight: 700; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.msg-actions .danger { color: var(--danger); }
.msg-actions[hidden] { display: none; }
.chat-form {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.chat-form textarea {
  flex-grow: 1;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 11px 16px;
  resize: none;
  max-height: 120px;
}
.chat-form textarea:focus { outline: none; border-color: var(--gold); }
.send-btn { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; border: 0; background: var(--gold); color: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.chat-error { max-width: 640px; margin: 0 auto; padding: 0 14px; color: var(--danger); font-size: 0.85rem; }
.chat-error:empty { display: none; }

/* Carte « Discussion » sur la page du défi */
.chat-link { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none; }
.chat-link:hover { border-color: var(--gold); }
.chat-link .body { flex-grow: 1; display: grid; gap: 2px; min-width: 0; }
.chat-link .t1 { font-weight: 700; }
.chat-link .t2 { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--gold); color: var(--bg); font-size: 0.8rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.badge[hidden] { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.seance-type { grid-template-columns: repeat(3, 1fr); }
#sec-route[hidden], #sec-roues[hidden], #ep-teaser[hidden] { display: none; }
.sport-tabs { margin: 0; }
.sport-tabs[hidden] { display: none; }
.sport-tabs .tab[hidden] { display: none; }

/* ===== Phalange ===== */
.phalanx-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.phalanx-head .medal-svg { width: 104px; height: 104px; }
.phalanx-name { font-family: var(--font-display); font-weight: 700; font-size: 1.8rem; letter-spacing: 0.06em; line-height: 1.1; }
.phalanx-motto { color: var(--gold); font-style: italic; }
.phalanx-meta { color: var(--muted); font-size: 0.9rem; }
.phalanx-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.phalanx-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 2px; text-align: center; }
.phalanx-stats strong { font-size: 1.5rem; font-weight: 800; font-stretch: 80%; color: var(--gold); }
.phalanx-stats span { font-size: 0.75rem; color: var(--muted); }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rank-row .pos { width: 26px; font-family: var(--font-display); font-weight: 700; color: var(--muted); text-align: center; }
.rank-row .pos.top { color: var(--gold); }
.rank-row .who { flex-grow: 1; display: grid; gap: 2px; min-width: 0; }
.rank-row .who .n { font-weight: 700; }
.rank-row .who .s { font-size: 0.8rem; color: var(--muted); }
.rank-row .flame { display: flex; align-items: center; gap: 4px; font-weight: 800; color: var(--gold); white-space: nowrap; }
.rank-row .flame img { width: 16px; height: auto; }
.rank-row .kick { font: inherit; font-size: 0.8rem; color: var(--danger); background: none; border: 0; cursor: pointer; min-height: 36px; }
.emblem-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.emblem-picker button { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; cursor: pointer; display: flex; justify-content: center; }
.emblem-picker button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.emblem-picker .medal-svg { width: 100%; height: auto; max-width: 56px; }
#view-phalanx[hidden], #view-new[hidden] { display: none; }
#view-phalanx, #view-new { display: grid; gap: 28px; }
.phalanx-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none; }
.phalanx-card:hover { border-color: var(--gold); }
.phalanx-card .body { flex-grow: 1; display: grid; gap: 2px; min-width: 0; }
.phalanx-card .n { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.04em; }
.phalanx-card .s { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phalanx-list { display: grid; gap: 10px; }
.chat-system { align-self: center; max-width: 90%; margin: 10px 0; padding: 6px 14px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); font-size: 0.8rem; font-weight: 700; text-align: center; }
.medallion .avatar-svg { width: 74%; height: 74%; display: block; }
.avatar-picker { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.avatar-picker .avatar-svg { width: 100%; height: auto; aspect-ratio: 1; display: block; }
@media (max-width: 420px) { .avatar-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.rank-row { position: relative; }
.rank-link { flex-grow: 1; display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); text-decoration: none; }
.rank-link:hover .n { color: var(--gold); }
.more-btn { font: inherit; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); background: none; border: 0; min-width: 44px; min-height: 44px; border-radius: 10px; cursor: pointer; }
.more-btn:hover { background: var(--surface); color: var(--text); }
.row-menu { position: absolute; right: 0; top: 52px; z-index: 5; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.row-menu[hidden] { display: none; }
.row-menu button { font: inherit; font-size: 0.9rem; font-weight: 700; color: var(--danger); background: none; border: 0; padding: 10px 14px; min-height: 44px; cursor: pointer; border-radius: 8px; white-space: nowrap; }
.row-menu button:hover { background: var(--surface); }
#st-km-row[hidden] { display: none; }
.medal-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 8px; }
.medal-strip .medal-name { font-size: 0.7rem; }

/* ===== Duels ===== */
.duel-card { display: grid; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none; }
a.duel-card:hover { border-color: var(--gold); }
.duel-card.is-pending { border-style: dashed; border-color: var(--gold); }
.duel-card.is-done { border-color: #5A4722; }
.duel-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.duel-time { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.duel-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em; }
.duel-sub { font-size: 0.85rem; color: var(--muted); }
.duel-row { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 10px; }
.duel-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duel-row .progress { height: 8px; }
.duel-row.is-winner .duel-name, .duel-row.is-winner .duel-score { color: var(--gold); }
.duel-score { font-size: 0.85rem; font-weight: 800; white-space: nowrap; }
.duel-reward { font-size: 0.85rem; font-weight: 800; color: var(--gold); }
.duel-list { display: grid; gap: 10px; }
.duel-actions { display: flex; gap: 10px; }
.duel-actions .btn { flex: 1; }
.challenge-form { display: grid; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--gold); border-radius: 16px; }
.challenge-form[hidden] { display: none; }
.duel-list[hidden], #sec-duels[hidden] { display: none; }
#objectif-field[hidden] { display: none; }
.record-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.record-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.record-list li.empty { color: var(--muted); display: block; }
.record-val { font-size: 1.15rem; font-weight: 800; font-stretch: 85%; color: var(--gold); white-space: nowrap; }
#perf-form[hidden], #sec-records[hidden] { display: none; }
.field input[type="file"] { padding: 10px; font-size: 0.9rem; }
.field input[type="date"] { color-scheme: dark; }
.field select { width: 100%; }
.duel-row.perf { grid-template-columns: 70px 1fr auto; }
.duel-row.perf .duel-score { font-size: 1rem; color: var(--text); }
.duel-row.perf.is-winner .duel-score { color: var(--gold); }
.proof-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.proof-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.proof-list .who { display: grid; gap: 2px; }
.proof-list .who strong { font-size: 0.95rem; }
.proof-list .who span { font-size: 0.8rem; color: var(--muted); }
.proof-btn { font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--gold); background: none; border: 1px solid var(--gold); border-radius: 10px; padding: 8px 12px; min-height: 40px; cursor: pointer; white-space: nowrap; }
.proof-img { width: 100%; border-radius: 14px; border: 1px solid var(--line); }
.format-tabs { grid-template-columns: 1fr 1fr; }
#exercice-field[hidden], #perf-field[hidden], #photo-field[hidden], #metrique-field[hidden] { display: none; }
#sec-tentatives[hidden], #poster[hidden], #contester[hidden], #proof-view[hidden] { display: none; }
#contester { justify-self: center; }

/* ===== Actions en attente ===== */
.tabbar a { position: relative; }
.tab-badge { position: absolute; top: -2px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: var(--bg); font-size: 0.65rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.alert-duel { display: grid; gap: 10px; padding: 16px; border-radius: 16px; background: #2A2213; border: 1px solid var(--gold); box-shadow: 0 0 0 3px rgba(212, 168, 75, 0.12); }
.alert-duel .t { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em; }
.alert-duel .s { font-size: 0.85rem; color: var(--muted); }
.alert-duel .actions { display: flex; gap: 10px; }
.alert-duel .actions .btn { flex: 1; min-height: 46px; }
#alertes[hidden], #sec-actions[hidden] { display: none; }
#alertes { display: grid; gap: 10px; }

/* ===== Titres ===== */
.titre { font-family: var(--font-display); font-style: italic; font-weight: 600; color: var(--gold); letter-spacing: 0.03em; }
.titre:empty { display: none; }
.hero-profile .titre { font-size: 0.85rem; }
.rank-row .titre { font-size: 0.75rem; margin-left: 6px; }
.title-list { display: grid; gap: 8px; }
.title-opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); cursor: pointer; }
.title-opt[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.title-opt .n { font-family: var(--font-display); font-weight: 700; font-style: italic; color: var(--gold); }
.title-opt .c { font-size: 0.8rem; color: var(--muted); }
.title-opt:disabled { cursor: default; opacity: 0.5; }
.title-opt:disabled .n { color: var(--muted); }
#c-commun-opts[hidden] { display: none; }
