:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1c2530;
  --text-muted: #5b6570;
  --rain: #2f6fb3;
  --warn-bg: #fbe7b5;
  --radius: 18px;
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 12px 24px -8px rgba(16, 24, 40, 0.18), 0 28px 48px -20px rgba(16, 24, 40, 0.25);
  /* Fin contour dessiné en ombre intérieure : il ne change aucune dimension */
  --hairline: rgba(16, 24, 40, 0.05);
  --bord: rgba(16, 24, 40, 0.18);
  --erreur: #b3261e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1c222b;
    --text: #f2f4f7;
    --text-muted: #9aa4b1;
    --rain: #8ab8ff;
    --warn-bg: #4a3c17;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px -6px rgba(0, 0, 0, 0.55);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45), 0 14px 28px -10px rgba(0, 0, 0, 0.6), 0 30px 56px -24px rgba(0, 0, 0, 0.7);
    --hairline: rgba(255, 255, 255, 0.06);
    --bord: rgba(255, 255, 255, 0.2);
    --erreur: #ffb4ab;
  }
}

* { box-sizing: border-box; }

/* Un onglet masqué le reste, quel que soit l'affichage que lui donnent ses propres styles */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Réserve la place de la barre fixe : le bas de la page ne passe jamais dessous */
  padding-bottom: 4rem;
}

.message-portail {
  margin: 0;
  padding: 70px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Barre d'onglets : fixe en bas de l'écran, elle reste visible quand la page défile */
.barre-onglets {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--hairline), 0 -6px 16px -8px rgba(16, 24, 40, 0.2);
}

.onglet {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 4px 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.onglet-icone {
  font-size: 1.4rem;
  line-height: 1.2;
}

.onglet:not(.active) .onglet-icone {
  filter: grayscale(1);
  opacity: 0.7;
}

/* Un trait en haut et le texte en gras : le service ouvert se voit d'un coup d'œil */
.onglet.active {
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 3px 0 var(--text);
}

.onglet:focus-visible {
  outline: 2px solid var(--rain);
  outline-offset: -2px;
}

/* Clavier ouvert sur un téléphone (voir portail.js) : la barre s'efface pour ne cacher ni le champ ni « Valider » */
@media (pointer: coarse) {
  body.saisie .barre-onglets {
    display: none;
  }
}

/* Page de connexion : la seule page publique, sans barre d'onglets */
.page-connexion {
  padding-bottom: 0;
}

.connexion {
  max-width: 380px;
  margin: 0 auto;
  padding: 64px 20px 40px;
  text-align: center;
}

.connexion-icone {
  font-size: 3.2rem;
  line-height: 1;
}

.connexion h1 {
  margin: 10px 0 26px;
  font-size: 1.7rem;
}

.connexion form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 20px 16px;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--hairline);
}

.connexion label {
  font-weight: 600;
}

/* 16 px au moins dans le champ : en dessous, l'iPhone agrandit la page quand on le touche */
.connexion input,
.connexion button {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 1.05rem;
  border-radius: 12px;
}

.connexion input {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--bord);
}

.connexion button {
  font-weight: 700;
  color: var(--bg);
  background: var(--text);
  border: 0;
  cursor: pointer;
}

.connexion button:disabled {
  opacity: 0.55;
}

.connexion input:focus-visible,
.connexion button:focus-visible {
  outline: 2px solid var(--rain);
  outline-offset: 2px;
}

.connexion-erreur {
  min-height: 1.4em;
  margin: 0;
  color: var(--erreur);
  font-weight: 600;
}
