:root {
  --bleu-travail: #12306e;
  --bleu-nuit: #0a1f4d;
  --jaune: #ffcf1a;
  --blanc: #ffffff;
  --acier: #e6eaf1;
  --gris: #4b5a73;
  --rouge: #b3121f;
  --vert-pac: #0b6b3a;
  --focus: #ff8a00;
  /* Montants : Atkinson barre ses zéros, qu'on lirait « Ø » (diamètre) sur un chantier */
  --chiffres: "Lexend", "Atkinson Hyperlegible", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--acier);
  color: var(--bleu-nuit);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

[hidden] { display: none !important; }

h1, p, ol { margin: 0; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:active { transform: translateY(2px); }

:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 3px;
}

/* ===== Écran de code ===== */
.ecran-code {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: var(--bleu-travail);
  color: var(--blanc);
}

.carte-code { width: 100%; max-width: 420px; }

.marque {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--jaune);
  margin-bottom: 2rem;
}

.carte-code label {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .5rem;
}

.carte-code input {
  width: 100%;
  min-height: 80px;
  font: inherit;
  font-size: 1.7rem;
  padding: .6rem .8rem;
  margin-bottom: 1rem;
  text-align: center;
  letter-spacing: .12em;
  color: var(--bleu-nuit);
  background: var(--blanc);
  border: 5px solid var(--blanc);
  border-radius: 16px;
}

.carte-code input:focus { outline: none; border-color: var(--jaune); }

.btn-entrer {
  width: 100%;
  min-height: 88px;
  font-size: 1.8rem;
  font-weight: 700;
  background: var(--jaune);
  color: var(--bleu-nuit);
  border: none;
  border-radius: 16px;
}

.erreur {
  margin-top: 1rem;
  padding: .8rem 1rem;
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--rouge);
  border-radius: 12px;
}

/* ===== Panneau du haut : la question, puis la marge ===== */
main { max-width: 560px; margin: 0 auto; }

.panneau {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.1rem 1.2rem;
  background: var(--bleu-travail);
  color: var(--blanc);
  border-radius: 0 0 24px 24px;
}

.mode-pac .panneau { background: var(--vert-pac); }

.question {
  font-size: clamp(2.2rem, 11vw, 2.8rem);
  line-height: 1.08;
  font-weight: 700;
  padding: .4rem 0 .3rem;
}

.res-titre { font-size: 1.4rem; font-weight: 700; }

.res-marge {
  font-family: var(--chiffres);
  font-size: clamp(3.8rem, 21vw, 5.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
  color: var(--jaune);
  transform-origin: left center;
}

.res-marge.change { animation: tampon .3s ease-out; }

@keyframes tampon {
  from { transform: scale(.92); opacity: .4; }
  to   { transform: none; opacity: 1; }
}

/* ===== Corps ===== */
.corps {
  padding: 1.2rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

/* Premier écran : 3 énormes boutons */
.premier-choix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
}

.gros-choix {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  background: var(--blanc);
  color: var(--bleu-nuit);
  border: 5px solid var(--bleu-nuit);
  border-radius: 20px;
}

.gros-choix .chiffre { font-size: 4.4rem; font-weight: 700; line-height: 1; }
.gros-choix .unite { font-size: 1.2rem; font-weight: 700; }

/* Une ligne par jour : « Jour N » + 1 / 2 / 3 (+ croix) */
.liste-jours { list-style: none; padding: 0; }

.jour {
  display: grid;
  grid-template-columns: 4.2rem 1fr 2.6rem;
  align-items: center;
  gap: .5rem;
  padding: .45rem 0;
}

.jour + .jour { border-top: 2px solid #c3cbd8; }

.jour-nom { font-size: 1.35rem; font-weight: 700; line-height: 1.05; }

.choix-techs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
}

.choix-techs button {
  min-height: 76px;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  background: var(--blanc);
  color: var(--bleu-nuit);
  border: 4px solid var(--bleu-nuit);
  border-radius: 16px;
}

.choix-techs button[aria-pressed="true"] {
  background: var(--bleu-nuit);
  color: var(--jaune);
}

/* Jour ajouté mais pas encore choisi : cadre jaune pour attirer l'œil */
.jour.a-choisir .choix-techs button { border-color: var(--bleu-travail); box-shadow: 0 0 0 4px var(--jaune); }

.btn-croix {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font-size: 1.9rem;
  line-height: 1;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--gris);
}

/* En mode PAC, les jours passent au second plan */
.mode-pac .liste-jours { opacity: .35; }

/* « Et un autre jour ? » */
.btn-ajouter {
  display: block;
  width: 100%;
  min-height: 84px;
  margin-top: .9rem;
  font-size: 1.6rem;
  font-weight: 700;
  background: transparent;
  color: var(--bleu-nuit);
  border: 4px dashed var(--bleu-nuit);
  border-radius: 16px;
}

/* PAC : un seul gros bouton */
.btn-pac {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  width: 100%;
  min-height: 96px;
  margin-top: 2.2rem;
  padding: .6rem 1.2rem;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
  background: var(--blanc);
  color: var(--vert-pac);
  border: 5px solid var(--vert-pac);
  border-radius: 20px;
}

.pac-prix { font-family: var(--chiffres); white-space: nowrap; }

.btn-pac[aria-pressed="true"] { background: var(--vert-pac); color: var(--blanc); }

/* Rappel Enzo */
.rappel {
  margin-top: 1.4rem;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
}

.btn-lien {
  display: block;
  min-height: 48px;
  margin: 1.4rem auto 0;
  padding: .4rem 1rem;
  background: none;
  border: none;
  color: var(--gris);
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .res-marge.change { animation: none; }
  button:active { transform: none; }
}

@media (max-width: 360px) {
  html { font-size: 17px; }
}
