:root {
  --fond: #f6f7f5;
  --surface: #ffffff;
  --texte: #1c2526;
  --texte-doux: #55636a;
  --bordure: #d7dedc;
  --accent: #0f5c63;
  --accent-fort: #0a4348;
  --accent-clair: #e3f1f1;
  --sur-accent: #ffffff;
  --alerte: #a43a1c;
  --alerte-fond: #fcebe5;
  --colis: #f0c987;
  --colis-bord: #8a5a12;
  --rayon: 10px;
  --largeur: 62rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121819;
    --surface: #1b2324;
    --texte: #e8eeed;
    --texte-doux: #a3b1b3;
    --bordure: #33403f;
    --accent: #6fc7cd;
    --accent-fort: #9adfe3;
    --accent-clair: #1f3537;
    --sur-accent: #0b1f21;
    --alerte: #ffab8f;
    --alerte-fond: #3a211a;
    --colis: #b98f47;
    --colis-bord: #f3d9a8;
  }
}

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

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

.conteneur { max-width: var(--largeur); margin: 0 auto; padding: 0 1rem; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-fort); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.evitement { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }
.evitement:focus { left: 0; }

/* En-tête */
.entete { background: var(--surface); border-bottom: 1px solid var(--bordure); }
.entete-contenu { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.marque { font-weight: 700; font-size: 1.15rem; color: var(--texte); text-decoration: none; }
.menu { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; list-style: none; margin: 0; padding: 0; font-size: 0.95rem; }
.menu a { text-decoration: none; padding: 0.35rem 0; display: inline-block; color: var(--texte-doux); }
.menu a:hover, .menu a[aria-current="page"] { color: var(--accent); }
.menu a[aria-current="page"] { font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }

/* Titres et texte */
main { padding-top: 1.25rem; padding-bottom: 3rem; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2; margin: 0.5rem 0 0.75rem; text-wrap: balance; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 0 0 0.75rem; }
.chapo { font-size: 1.1rem; color: var(--texte-doux); max-width: 46rem; margin: 0 0 1.5rem; }
.fil { font-size: 0.875rem; color: var(--texte-doux); }
.fil a { color: inherit; }
.hero { padding: 1.5rem 0 0.5rem; }

.texte { max-width: 46rem; margin-top: 2.5rem; }
.texte p, .texte ul, .texte ol { margin: 0 0 1rem; }
.texte li { margin-bottom: 0.4rem; }
.formule {
  background: var(--accent-clair);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--rayon) var(--rayon) 0;
  padding: 0.75rem 1rem;
  font-weight: 600;
}
.note { font-size: 0.925rem; color: var(--texte-doux); }

/* Calculateur */
.outil { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (min-width: 56rem) { .outil { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.formulaire, .resultat {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 1.25rem;
}
@media (min-width: 56rem) { .resultat { position: sticky; top: 1rem; } }

fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 0.6rem; font-size: 1.05rem; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.champ { margin-bottom: 0.75rem; min-width: 0; }
.grille .champ { margin-bottom: 0; }
.champ label { display: block; font-size: 0.925rem; font-weight: 600; margin-bottom: 0.25rem; }
.facultatif { font-weight: 400; color: var(--texte-doux); }
.saisie { display: flex; align-items: stretch; border: 1px solid var(--bordure); border-radius: 8px; background: var(--fond); overflow: hidden; }
.saisie:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-clair); }
.saisie input { flex: 1; min-width: 0; border: 0; background: transparent; color: inherit; font: inherit; padding: 0.55rem 0.65rem; }
.saisie input:focus { outline: none; }
.saisie:has(input[aria-invalid="true"]) { border-color: var(--alerte); }
.unite { display: flex; align-items: center; padding: 0 0.65rem; color: var(--texte-doux); font-size: 0.9rem; border-left: 1px solid var(--bordure); white-space: nowrap; }
select { width: 100%; font: inherit; color: inherit; background: var(--fond); border: 1px solid var(--bordure); border-radius: 8px; padding: 0.55rem 0.65rem; }
.case label { display: flex; gap: 0.5rem; align-items: flex-start; font-weight: 400; margin: 0; }
.case input { width: 1.15rem; height: 1.15rem; margin-top: 0.25rem; accent-color: var(--accent); flex: none; }
.aide { font-size: 0.85rem; color: var(--texte-doux); margin: 0.25rem 0 0; }
.erreur { font-size: 0.875rem; color: var(--alerte); margin: 0.25rem 0 0; font-weight: 600; }

details.avance { margin-bottom: 1.25rem; border-top: 1px solid var(--bordure); padding-top: 0.75rem; }
details.avance summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-bottom: 0.5rem; }
details.avance .grille { margin-top: 0.75rem; }

.bouton {
  display: inline-block;
  background: var(--accent);
  color: var(--sur-accent);
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.bouton:hover { background: var(--accent-fort); color: var(--sur-accent); }

/* Résultats */
.resultat h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--texte-doux); }
.indicateurs { margin: 0; display: grid; gap: 0; }
.indicateur { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--bordure); }
.indicateur dt { color: var(--texte-doux); font-size: 0.95rem; }
.indicateur dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.indicateur.principal { flex-direction: column; align-items: flex-start; gap: 0; background: var(--accent-clair); border: 0; border-radius: var(--rayon); padding: 0.9rem 1rem; margin-bottom: 0.5rem; }
.indicateur.principal dd { font-size: 2rem; line-height: 1.2; color: var(--accent-fort); text-align: left; }
.resultat .note { margin: 0.9rem 0 0; }
.alerte { background: var(--alerte-fond); color: var(--alerte); border-radius: var(--rayon); padding: 0.8rem 1rem; margin: 0; font-weight: 600; }

.schema { margin: 1.1rem 0 0; }
.schema svg { display: block; width: 100%; max-height: 16rem; }
.schema-palette { fill: var(--fond); stroke: var(--texte-doux); stroke-width: 0.8; }
.schema-colis { fill: var(--colis); stroke: var(--colis-bord); stroke-width: 0.6; }
.schema figcaption { font-size: 0.85rem; color: var(--texte-doux); text-align: center; margin-top: 0.4rem; }

/* Tableaux */
.tableau-defilant { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { background: var(--accent-clair); font-size: 0.875rem; }
tbody th { font-weight: 600; }
td.fort { font-weight: 700; color: var(--accent-fort); }
.resultat .tableau-defilant { margin-top: 1rem; }

/* Cartes */
.cartes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.9rem; max-width: none; }
.texte:has(.cartes) { max-width: none; }
.cartes li { margin: 0; }
.carte { display: flex; flex-direction: column; gap: 0.3rem; height: 100%; background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 1rem 1.1rem; text-decoration: none; color: var(--texte); }
.carte:hover { border-color: var(--accent); color: var(--texte); }
.carte-titre { font-weight: 700; color: var(--accent); }
.carte-texte { font-size: 0.925rem; color: var(--texte-doux); }

/* FAQ */
.faq details { border-bottom: 1px solid var(--bordure); padding: 0.8rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details > div { margin-top: 0.6rem; }
.faq details p:last-child { margin-bottom: 0; }

/* Emplacements publicitaires : réservés, masqués tant qu'ils sont vides. */
.emplacement-pub { margin: 2rem 0; min-height: 6rem; }
.emplacement-pub[hidden] { display: none; }

/* Pied de page */
.pied { background: var(--surface); border-top: 1px solid var(--bordure); padding: 2rem 0 1.5rem; font-size: 0.925rem; }
.pied-contenu { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.5rem; }
.pied-titre { font-weight: 700; margin: 0 0 0.4rem; }
.pied ul { list-style: none; margin: 0; padding: 0; }
.pied li { margin-bottom: 0.3rem; }
.pied-note { color: var(--texte-doux); margin-top: 1.5rem; margin-bottom: 0; font-size: 0.85rem; }
