/* Styles communs : vitrine, application, pages légales, administration.
   Les couleurs viennent de /theme.css (une palette par marque). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, .chiffre, .marque { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; line-height: 1.2; margin: 0.6rem 0 0.8rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 0.6rem; }
p { margin: 0 0 0.9rem; }
a { color: var(--principale); }
[hidden], .cache { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0.7rem 1.2rem; border-radius: 14px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
  transition: transform 0.08s ease, background 0.15s ease;
}
.bouton:active { transform: scale(0.98); }
.bouton:disabled { opacity: 0.55; cursor: default; }
.bouton.principal { background: var(--principale); color: #fff; }
.bouton.secondaire { background: var(--surface); color: var(--principale); border-color: color-mix(in srgb, var(--principale) 35%, transparent); }
.bouton.discret { background: transparent; color: var(--texte); border-color: color-mix(in srgb, var(--texte) 18%, transparent); }
.bouton.danger { background: transparent; color: #a3312a; border-color: #e3b5b0; }
.bouton.large { display: flex; width: 100%; margin: 0.6rem 0; }
.bouton.petit { min-height: 38px; padding: 0.4rem 0.9rem; font-size: 0.92rem; }
.lien-discret { display: block; text-align: center; margin: 1rem 0; color: color-mix(in srgb, var(--texte) 70%, transparent); }
.lien-bouton { background: none; border: 0; padding: 0; font: inherit; color: var(--principale); text-decoration: underline; cursor: pointer; }

/* ---------- Application ---------- */
body.appli { min-height: 100dvh; }
#app { max-width: 540px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.chargement { padding: 3rem 1rem; text-align: center; opacity: 0.6; }

.entete {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.5rem) 1rem 0.5rem;
  background: color-mix(in srgb, var(--fond) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.marque { font-size: 1.15rem; color: var(--principale); }
.titre-page { font-size: 1rem; margin: 0; text-align: center; font-family: inherit; }
.entete-actions { display: flex; align-items: center; gap: 0.3rem; }
.bouton-aide {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.35rem 0.75rem; border-radius: 999px;
  background: var(--surface); color: #a3312a; border: 1.5px solid #ecc5c0; font-weight: 600; font-size: 0.9rem; text-decoration: none;
}
.bouton-icone { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; color: var(--texte); border-radius: 12px; }
.icone { display: inline-flex; width: 22px; height: 22px; }
.icone svg { width: 100%; height: 100%; }
.icone.grande { width: 52px; height: 52px; color: var(--principale); }

.contenu { flex: 1; padding: 0.5rem 1rem calc(env(safe-area-inset-bottom) + 6rem); }
.onglets {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 540px; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0.35rem 0.5rem calc(env(safe-area-inset-bottom) + 0.35rem);
  background: var(--surface); border-top: 1px solid color-mix(in srgb, var(--texte) 10%, transparent);
}
.onglet { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.35rem; font-size: 0.75rem; color: color-mix(in srgb, var(--texte) 60%, transparent); text-decoration: none; border-radius: 10px; }
.onglet[aria-current="page"] { color: var(--principale); background: var(--doux); font-weight: 600; }

.carte { display: block; background: var(--surface); border-radius: 18px; padding: 1.1rem 1.2rem; margin: 0.8rem 0; box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04); }
.carte h2 { margin-top: 0; }
.carte-lien { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 0.2rem; }
.surtitre { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: color-mix(in srgb, var(--texte) 60%, transparent); margin: 0.4rem 0 0; }
.aide-champ { font-size: 0.9rem; color: color-mix(in srgb, var(--texte) 68%, transparent); }
.centre { text-align: center; }
.vide { padding: 1.5rem 0; color: color-mix(in srgb, var(--texte) 65%, transparent); }
.erreur { color: #a3312a; min-height: 1.2em; margin: 0.3rem 0; }

/* Compteur */
.compteur { text-align: center; padding: 1.6rem 1rem; background: linear-gradient(160deg, var(--surface), var(--doux)); }
.compteur .chiffre { font-size: 4.2rem; line-height: 1; color: var(--principale); }
.compteur .chiffre small { font-size: 1.6rem; opacity: 0.6; }
.compteur.petit .chiffre { font-size: 2.6rem; }
.compteur .libelle { font-size: 1.05rem; margin: 0.4rem 0 0.2rem; }
.compteur .details { font-size: 0.88rem; opacity: 0.7; margin: 0; }
.felicitation { background: var(--surface); border-radius: 12px; padding: 0.5rem 0.8rem; margin: 0.6rem 0; color: var(--principale); font-weight: 600; }
.prochaine-etape { text-align: left; margin-top: 1rem; }

.bouton-envie {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 1.3rem 1rem; margin: 1rem 0; border-radius: 22px; text-decoration: none;
  background: var(--accent); color: #fff; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.bouton-envie strong { font-size: 1.3rem; }
.bouton-envie span { font-size: 0.92rem; opacity: 0.92; }
.stat-semaine { text-align: center; font-size: 0.92rem; opacity: 0.8; }
.raccourcis { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.8rem 0; }
.raccourcis .bouton { font-size: 0.92rem; min-height: 52px; }

/* Accueil, verrou */
.accueil { text-align: center; padding-top: 1.5rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--doux); color: var(--principale); font-family: Georgia, serif; object-fit: cover; }
.avatar.grand { width: 104px; height: 104px; font-size: 2.8rem; }
.avatar.petit { width: 44px; height: 44px; font-size: 1.3rem; flex: none; }
.etiquette-ia { display: inline-block; font-size: 0.8rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--doux); color: var(--principale); }
.intro { font-size: 1.05rem; }
.garanties { list-style: none; padding: 0; margin: 1.4rem 0; text-align: left; display: grid; gap: 0.7rem; }
.garanties li { display: grid; grid-template-columns: 26px 1fr; gap: 0.6rem; align-items: start; font-size: 0.95rem; }
.garanties .icone { color: var(--principale); margin-top: 0.15rem; }
.verrou { text-align: center; padding-top: 3rem; }
.oubli { margin-top: 2rem; text-align: left; font-size: 0.92rem; }
.oubli summary { cursor: pointer; color: color-mix(in srgb, var(--texte) 70%, transparent); text-align: center; }

/* Formulaires */
.formulaire { display: flex; flex-direction: column; gap: 0.35rem; margin: 1rem 0; }
label { font-weight: 600; font-size: 0.95rem; margin-top: 0.6rem; }
input[type="text"], input[type="email"], input[type="date"], input[type="password"], textarea, select {
  width: 100%; font: inherit; padding: 0.75rem 0.9rem; border-radius: 12px;
  border: 1.5px solid color-mix(in srgb, var(--texte) 18%, transparent); background: var(--surface); color: var(--texte);
}
textarea { resize: vertical; }
.champ-code { font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; }
fieldset { border: 0; padding: 0; margin: 1rem 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }
.pastilles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 1.2rem; }
.pastille {
  font: inherit; font-size: 0.95rem; padding: 0.55rem 0.95rem; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--texte); border: 1.5px solid color-mix(in srgb, var(--texte) 16%, transparent);
}
.pastille[aria-pressed="true"] { background: var(--principale); border-color: var(--principale); color: #fff; }
.progression { height: 6px; background: var(--doux); border-radius: 99px; overflow: hidden; margin: 0.6rem 0; }
.progression > div { height: 100%; background: var(--principale); border-radius: 99px; transition: width 0.25s linear; }
.cases { list-style: none; padding: 0; }
.cases li { display: flex; gap: 0.8rem; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid color-mix(in srgb, var(--texte) 8%, transparent); }
.cases input { width: 22px; height: 22px; accent-color: var(--principale); flex: none; }
.cases label { margin: 0; font-weight: 400; }

/* Offres */
.avantages { padding-left: 1.2rem; }
.avantages li { margin: 0.3rem 0; }
.offres { display: grid; gap: 0.7rem; margin: 1.2rem 0; }
.offre {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.2rem 1rem; text-align: left;
  font: inherit; color: inherit; padding: 1rem 1.1rem; border-radius: 16px; background: var(--surface); cursor: pointer;
  border: 2px solid color-mix(in srgb, var(--texte) 12%, transparent);
}
.offre[aria-pressed="true"] { border-color: var(--principale); box-shadow: 0 0 0 3px color-mix(in srgb, var(--principale) 18%, transparent); }
.offre .prix { font-weight: 600; }
.offre small { grid-column: 1 / -1; opacity: 0.7; }
.badge { position: absolute; top: -0.65rem; right: 1rem; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 99px; }
.code-createur { margin: 0.5rem 0 1rem; font-size: 0.92rem; }
.code-createur summary { cursor: pointer; }
.liens-legaux { font-size: 0.85rem; text-align: center; opacity: 0.8; }

/* Exercice */
.exercice { text-align: center; padding: 2.5rem 0.5rem 1rem; min-height: 50vh; display: flex; flex-direction: column; justify-content: center; }
.exercice-texte { font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 1.7rem; line-height: 1.3; min-height: 4.5em; display: flex; align-items: center; justify-content: center; }
.exercice-sous { font-size: 0.95rem; opacity: 0.7; min-height: 1.5em; }
.exercice-decompte { font-size: 1rem; opacity: 0.6; font-variant-numeric: tabular-nums; }
.controles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.controles .discret { grid-column: 1 / -1; }
.liste-choix { display: grid; gap: 0.6rem; margin: 0.8rem 0; }
.choix { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border-radius: 16px; background: var(--surface); color: inherit; text-decoration: none; }
.choix small { opacity: 0.65; text-align: right; }

/* Journal */
.ligne-titre { display: flex; justify-content: space-between; align-items: center; }
.jour { font-size: 1rem; text-transform: capitalize; margin: 1.4rem 0 0.4rem; opacity: 0.8; }
.entrees { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.entree { background: var(--surface); border-radius: 14px; padding: 0.8rem 1rem; }
.entree p { margin: 0.35rem 0 0; font-size: 0.95rem; }
.entree .note { font-style: italic; opacity: 0.85; }
.entree-tete { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.entree-actions { display: flex; gap: 1rem; margin-top: 0.5rem; font-size: 0.85rem; }
.badge-issue { padding: 0.1rem 0.55rem; border-radius: 99px; font-size: 0.8rem; font-weight: 600; background: var(--doux); }
.badge-issue.ok { background: color-mix(in srgb, var(--principale) 16%, transparent); color: var(--principale); }
.badge-issue.rechute { background: color-mix(in srgb, var(--accent) 18%, transparent); color: color-mix(in srgb, var(--accent) 70%, black); }
.intensite { margin-left: auto; opacity: 0.6; }
.barres .barre { display: grid; grid-template-columns: 9.5rem 1fr 2rem; gap: 0.6rem; align-items: center; margin: 0.45rem 0; font-size: 0.9rem; }
.barre-piste { height: 10px; background: var(--doux); border-radius: 99px; overflow: hidden; }
.barre-valeur { display: block; height: 100%; background: var(--principale); border-radius: 99px; }
.barre-nombre { text-align: right; font-variant-numeric: tabular-nums; opacity: 0.7; }
.synthese { background: var(--doux); border-radius: 14px; padding: 0.8rem 1rem; }

/* Programme */
.jours { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.4rem; }
.jour-ligne > a, .jour-ligne > span { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 0.6rem; align-items: center; padding: 0.75rem 0.9rem; border-radius: 14px; background: var(--surface); color: inherit; text-decoration: none; }
.jour-ligne .numero { width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--doux); font-weight: 600; font-size: 0.9rem; }
.jour-ligne.fait .numero { background: var(--principale); color: #fff; }
.jour-ligne.aujourdhui > a { box-shadow: inset 0 0 0 2px var(--principale); }
.jour-ligne.ferme { opacity: 0.45; }
.jour-etat { font-size: 0.8rem; color: var(--principale); font-weight: 600; }
.action { border-left: 4px solid var(--accent); }
.pagination { display: flex; justify-content: space-between; margin: 1.5rem 0; }

/* Photos */
.grille-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-top: 1rem; }
.grille-photos figure { margin: 0; background: var(--surface); border-radius: 12px; overflow: hidden; }
.grille-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.grille-photos figcaption { display: flex; justify-content: space-between; padding: 0.4rem 0.6rem; font-size: 0.8rem; }

/* Coach */
.page-coach { display: flex; flex-direction: column; padding-bottom: calc(env(safe-area-inset-bottom) + 10.5rem); }
.coach-entete { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0 0.8rem; border-bottom: 1px solid color-mix(in srgb, var(--texte) 8%, transparent); }
.coach-entete > div { flex: 1; display: flex; flex-direction: column; }
.coach-entete small { font-size: 0.78rem; opacity: 0.65; }
.fil { display: flex; flex-direction: column; gap: 0.55rem; padding: 1rem 0; }
.bulle { max-width: 86%; padding: 0.65rem 0.9rem; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle.moi { align-self: flex-end; background: var(--principale); color: #fff; border-bottom-right-radius: 6px; }
.bulle.coach { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; }
.bulle.attente { opacity: 0.6; font-style: italic; }
.suggestions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.saisie {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 4.4rem);
  width: 100%; max-width: 540px; display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.6rem 1rem; background: var(--fond);
}
.saisie textarea { flex: 1; border-radius: 18px; max-height: 8rem; }
.bouton-envoyer { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 0; background: var(--principale); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.bouton-envoyer:disabled { opacity: 0.5; }

/* Crise et aide */
.carte-crise { background: #fff6f4; border: 1.5px solid #ecc5c0; border-radius: 16px; padding: 1rem; color: #3a1f1c; }
.carte-crise.urgence { background: #fde8e5; border-color: #d98d84; }
.lignes { display: grid; gap: 0.55rem; margin: 0.8rem 0; }
.ligne-aide { display: grid; grid-template-columns: 26px 1fr; gap: 0.7rem; align-items: center; padding: 0.85rem 1rem; border-radius: 14px; background: var(--surface); color: inherit; text-decoration: none; border: 1.5px solid #ecc5c0; }
.ligne-aide .icone { color: #a3312a; }
.ligne-aide strong { display: block; font-size: 1.05rem; }
.ligne-aide small { display: block; font-size: 0.85rem; opacity: 0.75; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 5.5rem); transform: translate(-50%, 1rem);
  background: var(--texte); color: var(--fond); padding: 0.6rem 1rem; border-radius: 12px; font-size: 0.92rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 20; max-width: calc(100% - 2rem);
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Vitrine et pages simples ---------- */
.vitrine, .page-simple { max-width: 640px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.vitrine header { display: flex; justify-content: space-between; align-items: center; }
.vitrine h1 { font-size: 2.1rem; margin-top: 2rem; }
.vitrine .accroche { font-size: 1.15rem; }
.vitrine .persona { display: flex; gap: 1rem; align-items: center; background: var(--surface); border-radius: 18px; padding: 1rem; margin: 1.5rem 0; }
.vitrine .persona p { margin: 0; font-size: 0.95rem; }
.vitrine ul.promesses { padding-left: 1.2rem; }
.vitrine ul.promesses li { margin: 0.45rem 0; }
.vitrine form { background: var(--surface); padding: 1.2rem; border-radius: 18px; margin: 1.5rem 0; }
.consentement { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; font-size: 0.88rem; }
.consentement input { margin-top: 0.25rem; accent-color: var(--principale); }
.vitrine footer, .page-simple footer { margin-top: 3rem; font-size: 0.85rem; opacity: 0.75; }
.merci { background: var(--doux); padding: 1rem; border-radius: 14px; }
.page-simple h2 { font-size: 1.1rem; }
.a-completer { background: #fff3cd; padding: 0 0.2rem; }

/* Administration */
.admin { max-width: 900px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin th, .admin td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid color-mix(in srgb, var(--texte) 10%, transparent); vertical-align: top; }
.admin .tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; }
.admin .tuile { background: var(--surface); padding: 0.9rem; border-radius: 14px; }
.admin .tuile strong { display: block; font-size: 1.8rem; font-family: Georgia, serif; }
.admin pre { white-space: pre-wrap; background: var(--doux); padding: 0.6rem; border-radius: 8px; font-size: 0.88rem; }
.admin .relu { opacity: 0.5; }

@media (min-width: 600px) {
  .contenu { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
.choix.colonne { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
.choix.colonne small { text-align: left; }
.choix-persona { justify-content: flex-start; gap: 0.9rem; font: inherit; border: 2px solid transparent; cursor: pointer; text-align: left; }
.choix-persona > span { display: flex; flex-direction: column; }
.choix-persona small { text-align: left; }
.choix-persona[aria-pressed="true"] { border-color: var(--principale); }
.avatar.version-femme { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.avatar.version-homme { background: color-mix(in srgb, var(--principale) 18%, var(--surface)); }
