/**
 * Mise en page de l'application Missiforge.
 * Tokens live in tokens.css (loaded first via <link>). This file is layout
 * and component styling only; it never redeclares design tokens.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { min-height: 100vh; overflow-x: hidden; text-rendering: optimizeLegibility; }

/* ============ HEADER ============ */
/* `body > header` et PAS `header` : les pages posent leurs propres
   <header class="feuillet-head"> dans le contenu (compte, boutique, mail,
   onboarding). Un sélecteur d'élément nu les rendait `position: fixed` en
   haut de page — le titre du feuillet recouvrait la barre de navigation, donc
   la marque (seul lien vers l'accueil) devenait incliquable. */
body > header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem clamp(1.2rem, 4vw, 3rem);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgb(245 246 248 / 0.88);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.015em;
}
.brand span { color: var(--accent); margin: 0 0.2rem; }
.brand-mark { display: inline-block; vertical-align: -0.3em; margin-right: 0.45rem; }

nav ul {
  display: flex;
  flex-wrap: wrap;              /* sinon les dernières entrées (solde, compte)
                                   passent hors écran et sont rognées par
                                   body{overflow-x:hidden} sur mobile */
  justify-content: flex-end;
  row-gap: 0.35rem;
  gap: clamp(0.8rem, 2.2vw, 2.2rem);
  list-style: none;
}
nav a {
  padding: 0.3rem 0;
  color: var(--ink-mute);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color var(--dur-fast);
}
nav a:hover { color: var(--ink); }
nav a.is-active { color: var(--ink); font-weight: 600; }

.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.card:hover {
  border-color: var(--line-strong);
  background: var(--card-hover);
}

/* ============ SECTION MAIL ============ */
.mail {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(7rem, 12vh, 10rem) clamp(1.2rem, 4vw, 3rem) var(--sp-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

/* Stack fields vertically inside left panel */
.field-col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.field-col label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-weight: 500;
}

.stat {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.15rem;
  padding: var(--sp-sm) var(--sp-md);
  border-left: 1px solid var(--line-soft);
}
.stat:first-child { border-left: none; }

.panel {
  padding: var(--sp-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
}
@media (max-width: 640px) {
  .panel { padding: var(--sp-md); }}
.panel-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--sp-md);
  letter-spacing: -0.015em;
}

.field-row {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
  align-items: flex-end;
}
.field-row label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-weight: 500;
}
.panel select,
.panel textarea,
.panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  max-width: 100%;
}
.field-row select,
.field-row input:not([type="checkbox"]):not([type="number"]) { min-width: 9rem; }
.field-row input[type="number"] { min-width: 5rem; }
.field-row label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.55rem;
}
.field-row input[type="checkbox"] { accent-color: var(--accent); }

.actions {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-top: var(--sp-md);
  flex-wrap: wrap;
}
.btn-primary,
.btn-secondary {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
/* Lien habillé en bouton (bandeau upsell, retour d'achat). */
a.btn-primary,
a.btn-secondary { display: inline-block; text-decoration: none; }
a.btn-primary:hover { color: var(--surface); }
.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { color: var(--ink); border-color: var(--ink-soft); }
.btn-primary:disabled,
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.hint {
  font-size: var(--text-xs);
  color: var(--ink-dim);
  max-width: 28rem;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--ink-mute);
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line-strong);
  font-weight: 600;
}
td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
}
td .muted { color: var(--ink-dim); }

.console {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--ink-soft);
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-md);
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
}

/* ============ FOCUS / A11Y ============ */
a:focus-visible,
.card:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ MAIL SHELL ============ */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

   /* doit l'emporter sur display:flex */

.feuillet-head { border-bottom: 1px solid var(--line-soft); padding-bottom: var(--sp-md); }

.feuillet-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.015em;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .dash { max-width: 820px; }
}
@media (max-width: 768px) {
  body > header { padding: 0.85rem 1.2rem; }

  /* === Mail responsive === */
  html { overflow-x: hidden; }

  .feuillet-title { font-size: var(--text-2xl); }}
@media (max-width: 480px) {

  nav ul { gap: 0.8rem; }}

/* ============ VUE COMPACTE — tableau contacts ============ */
/* Colonnes masquées (1-indexé) : 3 Prestige, 4 Secteur, 5 Service,
   10 Catégorie poste, 11 Fiche, 12 LinkedIn, 15 Trouvé le. Restent :
   sélection, Entreprise, Équipe, Ville, Contact, Poste, Email, Statut,
   Actions. */
 td):nth-child(3), td):nth-child(4), td):nth-child(5), td):nth-child(10), td):nth-child(11), td):nth-child(12), td):nth-child(15) {
  display: none;
}

/* ============ NAV LOGOUT ============ */
.nav-logout-form { display: inline; }
.nav-logout {
  background: none;
  border: none;
  padding: 0.3rem 0;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast);
}
.nav-logout:hover { color: var(--accent); }

/* ============ PAGE COMPTE ============ */
.account-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(6rem, 10vh, 8rem) clamp(1.2rem, 4vw, 3rem) var(--sp-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}
.account-shell .panel { box-shadow: var(--shadow-soft); }
.danger-zone { border-color: var(--danger) !important; }
.danger-zone .panel-title { color: var(--danger-strong); }

/* Pastille d'information (bonus d'inscription, visite en invité). */
.badge-warn {
  display: inline-block;
  align-self: flex-start;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--warn-soft);
  border: 1px solid var(--line);
  color: var(--warn);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Boutons en pilule, 44 px minimum (à combiner avec .btn-primary/-secondary). */
.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.4rem;
  border-radius: 999px;
  font-size: 1rem;
}
.btn-block { display: flex; width: 100%; }
.btn-danger {
  font-family: var(--font-body);
  font-weight: 600;
  background: transparent;
  color: var(--danger-strong);
  border: 1.5px solid var(--danger);
  cursor: pointer;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }

/* Cartes de la page Compte (pas .panel : ses règles d'input en 14 px
   écraseraient les champs à 16 px ci-dessous). */
.account-shell { gap: var(--sp-md); }
.acc-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding: var(--sp-lg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.acc-card .panel-title { margin-bottom: 0; }
.acc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--sp-xs) var(--sp-md); }
.acc-meta { color: var(--ink-mute); overflow-wrap: anywhere; }
.acc-help { color: var(--ink-soft); font-size: 0.95rem; }

.acc-balance { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-md); }
.acc-balance-label { font-family: var(--font-body); font-size: 0.95rem; font-weight: 500; color: var(--ink-mute); }
.acc-balance-value {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 1.8rem + 2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.acc-balance-sub { color: var(--ink-soft); }

.acc-moves { border-top: 1px solid var(--line); padding-top: var(--sp-sm); }
.acc-moves h3 { font-family: var(--font-body); font-size: 0.95rem; font-weight: 700; color: var(--ink); margin-bottom: 0.3rem; }
.acc-moves ul { list-style: none; }
.acc-moves li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-sm);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.acc-move-delta { color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-move-delta.is-credit { color: var(--ok); font-weight: 500; }
.acc-history { margin-top: 0.2rem; }
.acc-history > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-strong);
  text-decoration: underline;
  cursor: pointer;
  list-style: none;
}
.acc-history[open] > * + * { margin-top: var(--sp-sm); }
.acc-stats { display: flex; flex-wrap: wrap; gap: var(--sp-sm) var(--sp-lg); }
.acc-stats dt { font-size: var(--text-sm); color: var(--ink-mute); }
.acc-stats dd { margin: 0; font-weight: 600; color: var(--ink); }

/* État d'envoi : un seul encadré, couleur ET icône ET texte. */
.acc-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-lg);
}
.acc-status > svg { flex: none; }
.acc-status--ok { background: var(--ok-soft); }
.acc-status--ok > svg, .acc-status--ok .acc-status-text span { color: var(--ok); }
.acc-status--warn { background: var(--warn-soft); }
.acc-status--warn > svg, .acc-status--warn .acc-status-text span { color: var(--warn-strong); }
.acc-status-text { flex: 1 1 220px; display: flex; flex-direction: column; gap: 0.1rem; overflow-wrap: anywhere; }
.acc-status-text strong { color: var(--ink); }
.acc-status-text span { font-size: 0.95rem; }
.acc-status-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.25rem; color: var(--accent-strong); }

/* Formulaires du compte : champs empilés, 16 px, 48 px de haut. */
.acc-form { display: flex; flex-direction: column; gap: 0.4rem; }
.acc-form label { font-weight: 500; color: var(--ink); margin-top: var(--sp-xs); }
.acc-form input[type="email"],
.acc-form input[type="text"],
.acc-form input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
}
.acc-form .pw-field input[type] { border: 0; background: transparent; min-height: 45px; }
.acc-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); margin-top: var(--sp-xs); }
.acc-msg { font-size: 0.95rem; color: var(--ink-soft); }
.acc-msg:empty { display: none; }

/* Invité : une seule carte d'appel à l'inscription. */
.account-shell--guest { max-width: 30rem; }
.guest-card { gap: var(--sp-md); box-shadow: var(--shadow-raised); }
.guest-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 1.3rem + 1.5vw, 1.9rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.check-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; color: var(--ink-soft); }
.check-list li { display: flex; gap: 0.6rem; align-items: flex-start; }
.check-list svg { flex: none; color: var(--ok); }
.acc-link-center { align-self: center; display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.5rem; color: var(--accent-strong); }
.acc-guest-note { text-align: center; font-size: var(--text-sm); color: var(--ink-mute); }

@media (max-width: 640px) {
  .acc-card { padding: var(--sp-md); }
}

/* ============ PIED DE PAGE LÉGAL (base.html, toutes les pages) ============ */
.site-footer {
  max-width: 1080px;
  margin: var(--sp-lg) auto 0;
  padding: var(--sp-sm) clamp(1rem, 4vw, 3rem) calc(var(--sp-sm) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--ink-mute);
}
.site-footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 var(--sp-md); }
.site-footer-nav { display: flex; flex-wrap: wrap; gap: 0 var(--sp-md); }
/* `nav a` (en-tête) s'applique aussi ici : on ne garde que la taille. */
.site-footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  color: var(--ink-mute);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.site-footer-nav a:hover { color: var(--ink); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: none; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* Badge de solde (en-tête) : lecture rapide du nombre de tokens restants.
   Chiffres tabulaires pour que la largeur ne saute pas quand le solde
   change (100 -> 99), et une teinte d'alerte à zéro — c'est l'état où
   l'utilisateur doit agir. */
.token-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3ch;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  color: inherit;
}
.token-badge:hover { border-color: var(--accent); }
.token-badge[data-empty="1"] { color: var(--ink-mute); }

/* Appel à l'inscription : le seul chemin vers l'achat pour un visiteur en
   session invité. Traité comme une action, pas comme un lien de navigation. */
.nav-cta {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  font-weight: 600;
  background: var(--accent);
  color: var(--surface);
  text-decoration: none;
}
.nav-cta:hover { opacity: 0.9; }

/* ============ AUTH (login / signup / forgot / reset) ============ */
/* Ces pages n'avaient aucune feuille dédiée : le <h1> passait SOUS la barre
   de navigation (body > header est `position: fixed`) et le formulaire
   tombait en HTML nu, pleine largeur, sans rien du design system. Le panneau
   ci-dessous est un feuillet centré — même carte que .panel, même typo que
   .feuillet-title — avec la marge haute qui dégage l'en-tête. */
.auth-panel {
  width: min(30rem, calc(100% - 2.4rem));
  margin: clamp(6.5rem, 14vh, 9.5rem) auto var(--sp-2xl);
  padding: var(--sp-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.auth-panel > h1 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.auth-lede {
  margin-top: var(--sp-sm);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}
/* Les liens-boutons gardent leur couleur : `.auth-panel a` (0,1,1) battait
   `.btn-primary` (0,1,0) et rendait « Commencer mes candidatures » bleu foncé
   sur fond bleu après le paiement. */
.auth-panel a:not(.btn-primary):not(.btn-secondary):not(.auth-tab) { color: var(--accent-strong); }

/* Messages (erreur, confirmation, inscription limitée). Le filet de gauche
   porte l'état : la couleur seule ne suffirait pas en vision daltonienne, le
   role=alert/status du template porte l'information pour le lecteur d'écran. */
.auth-flash {
  margin-top: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--ink-dim);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}
.auth-flash--error { border-left-color: var(--danger); background: var(--danger-soft); }
.auth-flash--ok { border-left-color: var(--ok); background: var(--ok-soft); }

.auth-form { margin-top: var(--sp-md); }
.auth-form label {
  display: block;
  margin-top: var(--sp-md);
  margin-bottom: 0.35rem;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  font-weight: 500;
}
/* 16 px minimum : en dessous, iOS zoome la page à chaque saisie. 48 px de
   haut : cible tactile confortable. */
.auth-form input[type="email"],
.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.auth-form input:hover { border-color: var(--line-strong); }
.auth-form input::placeholder { color: var(--ink-dim); }
.auth-hint {
  margin: 0.35rem 0 0;
  font-size: var(--text-sm);
  color: var(--ink-mute);
}
/* Case CGU : une phrase, pas une étiquette de champ. */
/* `.auth-form .auth-check` et pas `.auth-check` seul : `.auth-form label`
   (0,1,1) l'emportait et remettait l'étiquette en bloc. */
.auth-form .auth-check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: var(--sp-md) 0 0;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  cursor: pointer;
}
.auth-check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.auth-form button[type="submit"] {
  width: 100%;
  min-height: 52px;
  margin-top: var(--sp-lg);
  padding: 0 1.4rem;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--surface);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.auth-form button[type="submit"]:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
/* Connexion : bouton encre (la maquette réserve le corail à l'inscription). */
.auth-form button.auth-submit--ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.auth-form button.auth-submit--ink:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.auth-divider {
  margin-top: var(--sp-lg);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-mute);
}
/* Liens secondaires des cartes d'auth : 44 px de haut au doigt. */
.auth-divider a,
.auth-forgot a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.auth-forgot { margin-top: 0.2rem; text-align: right; font-size: 0.95rem; }
.auth-foot { margin-top: var(--sp-md); font-size: var(--text-sm); color: var(--ink-mute); }
.auth-lede .auth-bonus { color: var(--warn); }

/* Onglets-liens « Créer un compte / Se connecter » en tête de carte. Ce sont
   deux pages distinctes : l'onglet courant porte aria-current="page". */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--sp-md);
  border-radius: 999px;
  background: var(--bg-sunken);
}
.auth-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 0.6rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }

/* Champs facultatifs repliés de l'inscription. */
.auth-more { margin-top: var(--sp-md); }
.auth-more > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
}
.auth-more > summary::before { content: "+"; width: 1ch; font-weight: 700; color: var(--accent-strong); }
.auth-more[open] > summary::before { content: "−"; }
.auth-more > label:first-of-type { margin-top: var(--sp-xs); }

/* Champ mot de passe + bouton œil (macro _auth.html, script base.html). Le
   cadre est porté par le conteneur ; l'input à l'intérieur n'en a plus. Placé
   APRÈS `.auth-form input[...]` : même spécificité, l'ordre tranche. */
.pw-field {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
}
.pw-field:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-field input[type] {
  flex: 1;
  min-width: 0;
  min-height: 45px;
  border: 0;
  background: transparent;
  outline: none;
}
.pw-field input[type]:focus-visible { outline: none; }
.pw-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 45px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.pw-toggle:hover, .pw-toggle.is-shown { color: var(--accent-strong); }

@media (max-width: 640px) {
  .auth-panel { width: calc(100% - 2rem); padding: var(--sp-md); margin-top: 5rem; }
}
/* Marque « facultatif » collée à l'étiquette : sans elle, un champ vide au
   milieu du formulaire se lit comme un champ oublié. */
.auth-optional {
  margin-left: 0.4rem;
  font-size: var(--text-xs);
  color: var(--ink-dim);
}

summary::-webkit-details-marker { display: none; }

/* Panneau replié : la ligne de titre seule, sans la marge prévue pour le contenu. */
details.panel { padding-block: var(--sp-md); }
details.panel:not([open]) > summary.panel-title { margin-bottom: 0; }
details.panel > summary.panel-title { font-size: var(--text-lg); }
a.btn-primary, a.btn-secondary { text-decoration: none; display: inline-block; }

/* ============ TÉLÉPHONE ============ */
/* Bouton « Menu » de l'en-tête : n'existe que sur petit écran. */
.nav-toggle { display: none; }
/* Étapes de page dans le menu : seulement dans le panneau ouvert du téléphone
   (sur grand écran, le rail les montre déjà). */
.nav-stage { display: none; }
.brand { white-space: nowrap; }

@media (max-width: 640px) {
  /* — En-tête sur UNE ligne : marque, solde / inscription, Menu. Le reste
     des liens s'ouvre en panneau sous la barre. — */
  body > header {
    gap: 0.6rem;
    padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
  }
  body > header nav { margin-left: auto; }
  nav ul { flex-wrap: nowrap; align-items: center; gap: 0.5rem; }
  nav li:not(.nav-keep) { display: none; }
  .nav-cta { white-space: nowrap; }
  /* Solde à zéro : rien à montrer dans la barre, il reste dans le menu
     (et dans la Boîte). Libère la place pour « Créer mon compte ». */
  body > header:not(.nav-open) li:has(> .token-badge[data-empty="1"]) { display: none; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0 0.8rem;
    font: 600 var(--text-sm) var(--font-body);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    order: 3;
  }
  body > header.nav-open nav ul {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.4rem 1rem 0.8rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line-soft);
    box-shadow: var(--shadow-soft);
  }
  body > header.nav-open nav li { display: block; }
  body > header.nav-open nav li > a,
  body > header.nav-open .nav-logout {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.9rem;
    font-size: var(--text-base);
    border-bottom: 1px solid var(--line-soft);
  }
  body > header.nav-open nav li:last-child > a,
  body > header.nav-open nav li:last-child .nav-logout { border-bottom: none; }
  body > header.nav-open .nav-cta { justify-content: center; margin-top: 0.5rem; }
  body > header.nav-open .nav-stage a.is-active { color: var(--accent-strong); font-weight: 600; }

  body > header.nav-open .token-badge { width: auto; justify-content: flex-start; }
  .nav-logout-form { display: block; }

  /* Moins de vide sous l'en-tête fixe, sur toutes les pages. */
   .mail, .account-shell { padding-top: 5rem; }

  .feuillet-head { padding-bottom: var(--sp-xs); }
  .feuillet-title { font-size: var(--text-xl); }
  .stat { padding: 0.5rem 0.75rem; }

  /* — Formulaires : champs pleine largeur, 16 px (en dessous, iOS zoome la
     page à chaque saisie), cibles tactiles ≥ 44 px. — */
  .panel select,
  .panel textarea,
  .panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
    font-size: 16px;
    min-height: 2.75rem;
  }
  .field-col label > :is(input, select, textarea),
  .field-row label > :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
    width: 100% !important;   /* écrase les width inline (ex. 14rem) */
    min-width: 0;
  }
  /* Empile les rangées de champs ; une rangée de cases seules (ex. prestige
     S/A/B/C) reste en ligne. */
  .field-row:has(> label:not(.check)) { flex-direction: column; align-items: stretch; gap: var(--sp-sm); }
  .field-row label.check { padding-bottom: 0; }
  input[type="file"] { max-width: 100%; }

  .btn-primary, .btn-secondary { min-height: 2.75rem; }
  .actions { gap: var(--sp-sm); }
  .hint { max-width: none; }
  /* Volet replié = simple ligne de sommaire : sans ça, huit volets fermés
     occupent un écran et demi. Reste au-dessus des 44 px tactiles. */
  details.panel:not([open]) { padding-block: var(--sp-sm); }
  details.panel > summary.panel-title { min-height: 2.75rem; }}
