:root {
  color-scheme: light dark;
  --fond: #eef2f5;
  --surface: #ffffff;
  --encre: #14212b;
  --discret: #4a5a66;
  --accent: #1c5d86;
  --ligne: #c9d3da;
  --trait-marque: #ffffff;
  --sur-accent: #ffffff;
  --alerte-fond: #fbeaea;
  --alerte-encre: #8a1f1f;
  --alerte-ligne: #e3b4b4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1a22;
    --surface: #172631;
    --encre: #e6edf2;
    --discret: #a3b3bf;
    --accent: #82bde3;
    --ligne: #2c3e4b;
    --trait-marque: #0f1a22;
    --sur-accent: #0f1a22;
    --alerte-fond: #3a1d20;
    --alerte-encre: #f3c4c4;
    --alerte-ligne: #6b3237;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--encre);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 3rem 16px 4rem;
}

header { margin-bottom: 2.25rem; }

.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.barre form { margin: 0; }
.marque-lien { display: block; border-radius: 0.6rem; }
.marque-lien:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.marque {
  display: block;
  width: 3rem;
  height: 3rem;
}
.marque-fond { fill: var(--accent); }
.marque-trait { fill: var(--trait-marque); }

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.intro {
  margin: 0;
  max-width: 34rem;
  color: var(--discret);
  font-size: 1.0625rem;
}

.services {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ligne);
}

.services li { border-bottom: 1px solid var(--ligne); }

.services a {
  display: grid;
  gap: 0.15rem;
  min-height: 44px;
  padding: 1rem 16px 1rem 13px; /* 13 px + 3 px de bordure : texte aligne sur le titre */
  margin: 0 -16px;
  border-left: 3px solid transparent;
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
}

.services a:hover {
  background: var(--surface);
  border-left-color: var(--accent);
}

.services a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  background: var(--surface);
}

.nom {
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--accent);
}

.services a:hover .nom { text-decoration: underline; text-underline-offset: 0.2em; }

.phrase { color: var(--encre); }

.adresse {
  color: var(--discret);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

@media (min-width: 40rem) {
  main { padding-top: 5rem; }
  .services a {
    grid-template-columns: 9.5rem 1fr;
    column-gap: 1.5rem;
    align-items: baseline;
  }
  .nom { grid-row: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  .services a { transition: none; }
}

/* Boutons et liens d'action */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--sur-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.bouton:hover { filter: brightness(1.08); }
.bouton:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.bouton-second { background: transparent; color: var(--accent); }
.bouton-second:hover { background: var(--surface); filter: none; }

.lien {
  min-height: 44px;
  padding: 0.6rem 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.lien:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.alerte {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--alerte-ligne);
  border-left-width: 4px;
  border-radius: 0.4rem;
  background: var(--alerte-fond);
  color: var(--alerte-encre);
}

/* Connexion */
.connexion { max-width: 26rem; }
.connexion h1 { font-size: clamp(1.6rem, 5vw, 2rem); }
.connexion .intro { margin-bottom: 1.5rem; }
.formulaire { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
.champ { display: grid; gap: 0.35rem; }
.champ label { font-weight: 600; }
.champ input {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--ligne);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--encre);
  font: inherit;
  font-size: max(1rem, 16px); /* 16 px : pas de zoom force sur mobile */
}
.champ input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.choix-facteur { display: grid; gap: 0.75rem; }
.actions-formulaire { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; }
.actions-formulaire a { color: var(--accent); }
.actions-formulaire a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cle-totp code, .codes-secours code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.cle-totp { padding: 0.75rem 1rem; border: 1px solid var(--ligne); border-radius: 0.4rem; background: var(--surface); }
.codes-secours { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.4rem 1rem; padding-left: 1.25rem; }

/* Pages d'erreur */
.erreur h1 { margin-bottom: 0.75rem; }
.erreur a { color: var(--accent); }
.erreur a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.erreur p { margin: 0 0 1rem; }
.retour { display: inline-block; min-height: 44px; padding: 0.6rem 0; }
