/* ==========================================================================
   TiDevis — feuille de style commune (site et outil)
   Identité : papier, encre et jaune chantier. Une seule police (Archivo,
   largeur variable) : titres élargis comme une signalétique de chantier,
   texte en largeur normale. Pas de dégradé, pas d'effet de verre.
   Sommaire : 1. Couleurs et mesures  2. Bases  3. Composants  4. Site
   ========================================================================== */

/* ---------- Police ---------- */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-tidevis.woff2") format("woff2-variations"),
       url("../fonts/archivo-tidevis.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 100% 125%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Polices de repli ajustées sur les mesures d'Archivo : si la police arrive après le premier
   affichage (premier passage, réseau lent), le texte garde presque la même largeur et la page ne saute pas. */
@font-face { font-family: "Archivo repli Roboto"; src: local("Roboto"), local("Roboto-Regular"); font-weight: 100 549; size-adjust: 100%; ascent-override: 87.8%; descent-override: 21%; line-gap-override: 0%; }
@font-face { font-family: "Archivo repli Roboto"; src: local("Roboto Bold"), local("Roboto-Bold"); font-weight: 550 900; size-adjust: 99%; ascent-override: 88.7%; descent-override: 21.2%; line-gap-override: 0%; }
@font-face { font-family: "Archivo repli Helvetica"; src: local("Helvetica Neue"), local("HelveticaNeue"); font-weight: 100 549; size-adjust: 96.5%; ascent-override: 91%; descent-override: 21.8%; line-gap-override: 0%; }
@font-face { font-family: "Archivo repli Helvetica"; src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"); font-weight: 550 900; size-adjust: 95.5%; ascent-override: 91.9%; descent-override: 22%; line-gap-override: 0%; }
@font-face { font-family: "Archivo repli"; src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("LiberationSans"); font-weight: 100 549; size-adjust: 97.9%; ascent-override: 89.7%; descent-override: 21.5%; line-gap-override: 0%; }
@font-face { font-family: "Archivo repli"; src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("LiberationSans-Bold"); font-weight: 550 900; size-adjust: 97.1%; ascent-override: 90.4%; descent-override: 21.6%; line-gap-override: 0%; }

/* ==========================================================================
   1. Couleurs et mesures
   ========================================================================== */
:root {
  color-scheme: light;
  --fond: #F6F4EE;           /* papier */
  --fond-2: #EEEBE3;         /* bandes et zones calmes */
  --surface: #FFFFFF;
  --surface-2: #FAF8F4;
  --surface-3: #F3F0E9;
  --encre: #16181D;
  --encre-2: #474C57;
  --encre-3: #5C6270;
  --trait: #E4DFD4;
  --trait-doux: #EEEAE1;
  --trait-fort: #8E8778;     /* bord des champs (contraste 3:1) */
  --jaune: #FFC21A;          /* jaune chantier */
  --jaune-vif: #FFB300;
  --jaune-bord: #E0A400;
  --jaune-pale: #FFF2C2;
  --jaune-texte: #6E5100;
  --sur-jaune: #16181D;
  --vert: #136C43;
  --vert-pale: #E2F2E8;
  --rouge: #B3261E;
  --rouge-pale: #FCE9E7;
  --orange: #A84508;
  --orange-pale: #FFEEDD;
  --bande: #16181D;          /* bandes sombres */
  --sur-bande: #F6F4EE;
  --sur-bande-2: #B9BCC4;
  --trait-bande: #33363E;
  --grille: rgba(22, 24, 29, 0.055);
  --voile: rgba(22, 24, 29, 0.45);
  --ombre-1: 0 1px 2px rgba(22, 24, 29, 0.06);
  --ombre-2: 0 1px 2px rgba(22, 24, 29, 0.05), 0 8px 24px rgba(22, 24, 29, 0.07);
  --ombre-3: 0 2px 8px rgba(22, 24, 29, 0.08), 0 24px 56px rgba(22, 24, 29, 0.16);
  --anneau: 0 0 0 3px rgba(255, 194, 26, 0.6);
  --rayures: repeating-linear-gradient(-45deg, var(--jaune) 0 6px, var(--encre) 6px 12px);

  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-4: 24px;

  --police: "Archivo", "Archivo repli Roboto", "Archivo repli Helvetica", "Archivo repli", ui-sans-serif, system-ui, sans-serif;
  --large: 116%;             /* largeur des titres */
  --mi-large: 108%;
  --conteneur: 1180px;
  --gouttiere: 20px;
  --entete-h: 64px;
  --transition: 160ms cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #101115;
    --fond-2: #15171C;
    --surface: #18191E;
    --surface-2: #1C1E24;
    --surface-3: #22252C;
    --encre: #F3F1EA;
    --encre-2: #C4C7CE;
    --encre-3: #9EA2AC;
    --trait: #2A2D35;
    --trait-doux: #23262D;
    --trait-fort: #6B7180;
    --jaune: #FFC83D;
    --jaune-vif: #FFD466;
    --jaune-bord: #FFC83D;
    --jaune-pale: #2E2611;
    --jaune-texte: #FFD978;
    --sur-jaune: #16181D;
    --vert: #6FD3A2;
    --vert-pale: #12291E;
    --rouge: #FF8F85;
    --rouge-pale: #331716;
    --orange: #FFB574;
    --orange-pale: #33210F;
    --bande: #0A0B0E;
    --sur-bande: #F3F1EA;
    --sur-bande-2: #A7ABB4;
    --trait-bande: #26292F;
    --grille: rgba(243, 241, 234, 0.05);
    --voile: rgba(0, 0, 0, 0.6);
    --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ombre-2: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
    --ombre-3: 0 2px 8px rgba(0, 0, 0, 0.4), 0 24px 56px rgba(0, 0, 0, 0.5);
    --anneau: 0 0 0 3px rgba(255, 200, 61, 0.45);
    --rayures: repeating-linear-gradient(-45deg, var(--jaune) 0 6px, #2B2E36 6px 12px);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #101115;
  --fond-2: #15171C;
  --surface: #18191E;
  --surface-2: #1C1E24;
  --surface-3: #22252C;
  --encre: #F3F1EA;
  --encre-2: #C4C7CE;
  --encre-3: #9EA2AC;
  --trait: #2A2D35;
  --trait-doux: #23262D;
  --trait-fort: #6B7180;
  --jaune: #FFC83D;
  --jaune-vif: #FFD466;
  --jaune-bord: #FFC83D;
  --jaune-pale: #2E2611;
  --jaune-texte: #FFD978;
  --sur-jaune: #16181D;
  --vert: #6FD3A2;
  --vert-pale: #12291E;
  --rouge: #FF8F85;
  --rouge-pale: #331716;
  --orange: #FFB574;
  --orange-pale: #33210F;
  --bande: #0A0B0E;
  --sur-bande: #F3F1EA;
  --sur-bande-2: #A7ABB4;
  --trait-bande: #26292F;
  --grille: rgba(243, 241, 234, 0.05);
  --voile: rgba(0, 0, 0, 0.6);
  --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --ombre-2: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
  --ombre-3: 0 2px 8px rgba(0, 0, 0, 0.4), 0 24px 56px rgba(0, 0, 0, 0.5);
  --anneau: 0 0 0 3px rgba(255, 200, 61, 0.45);
  --rayures: repeating-linear-gradient(-45deg, var(--jaune) 0 6px, #2B2E36 6px 12px);
}

/* ==========================================================================
   2. Bases
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--entete-h) + 16px); }
html.theme-transition, html.theme-transition * { transition: background-color 240ms ease, border-color 240ms ease, color 240ms ease !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--police);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--encre);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
svg { flex-shrink: 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 750; letter-spacing: -0.012em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
@media (hover: hover) { a:hover { text-decoration-thickness: 2px; } }
strong, b { font-weight: 700; }
sup { line-height: 0; }
hr { border: 0; border-top: 1px solid var(--trait); margin: 24px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-3); padding: 0.1em 0.35em; border-radius: 5px; }
[hidden] { display: none !important; }
::selection { background: var(--jaune); color: var(--sur-jaune); }
input, textarea { caret-color: var(--encre); }
html { scrollbar-color: var(--trait-fort) var(--fond); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--encre); color: var(--fond); padding: 10px 16px; border-radius: var(--r-1);
  font-weight: 600; text-decoration: none; transition: top var(--transition);
}
.skip-link:focus { top: 12px; }

.conteneur, .container { width: 100%; max-width: var(--conteneur); margin-inline: auto; padding-inline: var(--gouttiere); }
.chiffres { font-variant-numeric: tabular-nums; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-plein { fill: currentColor; stroke: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Transitions de page (fondu + léger zoom) ----------
   Navigateurs compatibles uniquement (View Transitions). Ailleurs : changement direct, sans effet.
   Dans l'outil, le changement d'onglet passe par document.startViewTransition (voir app.js). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: tdv-page-sortie 160ms ease both; }
::view-transition-new(root) { animation: tdv-page-entree 260ms cubic-bezier(.2, .7, .2, 1) both; }
@keyframes tdv-page-sortie { to { opacity: 0; transform: scale(0.994); } }
@keyframes tdv-page-entree { from { opacity: 0; transform: scale(1.01); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ==========================================================================
   3. Composants
   ========================================================================== */

/* ---------- Logo ---------- */
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--encre);
  font-weight: 800; font-stretch: var(--large); font-size: 1.25rem; letter-spacing: -0.02em; line-height: 1;
}
@media (hover: hover) { .logo:hover { text-decoration: none; } }
.logo-marque { width: 32px; height: 32px; border-radius: 8px; }
.logo-marque .fond-marque { fill: var(--jaune); }
.logo-marque .trace-marque { fill: #16181D; }

/* ---------- Boutons ---------- */
.btn {
  --btn-fond: var(--surface);
  --btn-texte: var(--encre);
  --btn-bord: var(--trait-fort);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid var(--btn-bord); border-radius: var(--r-2);
  background: var(--btn-fond); color: var(--btn-texte);
  font-weight: 650; font-size: 1rem; line-height: 1.2; text-align: center; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 90ms ease;
}
@media (hover: hover) { .btn:hover { text-decoration: none; background: var(--surface-3); } }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.btn .ic { width: 20px; height: 20px; }
/* Très petits écrans : un libellé long passe à la ligne plutôt que de déborder */
@media (max-width: 359px) { .btn { white-space: normal; padding-block: 8px; } }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primaire, .btn-primary {
  --btn-fond: var(--jaune); --btn-texte: var(--sur-jaune); --btn-bord: var(--jaune-bord);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(22, 24, 29, 0.14);
}
@media (hover: hover) { .btn-primaire:hover, .btn-primary:hover { background: var(--jaune-vif); } }
.btn-encre { --btn-fond: var(--encre); --btn-texte: var(--fond); --btn-bord: var(--encre); }
@media (hover: hover) { .btn-encre:hover { background: var(--encre-2); border-color: var(--encre-2); } }
.btn-secondaire, .btn-secondary { --btn-fond: var(--surface); }
.btn-discret, .btn-ghost, .btn-quiet { --btn-fond: transparent; --btn-bord: transparent; }
@media (hover: hover) { .btn-discret:hover, .btn-ghost:hover, .btn-quiet:hover { background: var(--surface-3); } }
.btn-danger { --btn-fond: var(--rouge); --btn-texte: #FFFFFF; --btn-bord: var(--rouge); }
@media (hover: hover) { .btn-danger:hover { background: var(--rouge); filter: brightness(0.92); } }
:root[data-theme="dark"] .btn-danger { --btn-texte: #1A0B0A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { --btn-texte: #1A0B0A; } }
.btn-texte-danger { color: var(--rouge) !important; }
.btn-petit, .btn-small { min-height: 40px; padding: 0 14px; font-size: 0.9375rem; border-radius: 10px; }
.btn-grand { min-height: 56px; padding: 0 26px; font-size: 1.0625rem; border-radius: 14px; }
.btn-bloc { display: flex; width: 100%; }
.btn-icone {
  min-height: 44px; width: 44px; padding: 0; border-radius: 12px;
  --btn-fond: transparent; --btn-bord: transparent;
}
@media (hover: hover) { .btn-icone:hover { background: var(--surface-3); } }
.btn-icone .ic { width: 22px; height: 22px; }

.lien-bouton {
  display: inline; padding: 0; border: 0; background: none; color: inherit;
  font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; cursor: pointer;
}
@media (hover: hover) { .lien-bouton:hover { text-decoration-thickness: 2px; } }

/* ---------- Champs ---------- */
.field, .champ { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .champ > label, .label, legend {
  font-weight: 600; font-size: 0.9375rem; color: var(--encre); line-height: 1.3;
}
legend { padding: 0; margin-bottom: 8px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.req { color: var(--rouge); }
.hint, .aide {
  font-size: 0.875rem; line-height: 1.45; color: var(--encre-3);
}
input[type="text"], input[type="email"], input[type="tel"], input[type="search"], input[type="password"],
input[type="number"], input[type="date"], input[type="url"], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--trait-fort); border-radius: var(--r-2);
  background: var(--surface); color: var(--encre);
  font-size: 1rem; line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; min-height: 96px; }
select {
  padding-right: 42px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235C6270' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px;
}
input::placeholder, textarea::placeholder { color: var(--encre-3); opacity: 0.85; }
@media (hover: hover) { input:hover, select:hover, textarea:hover { border-color: var(--encre-3); } }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--encre); box-shadow: var(--anneau); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--encre-3); cursor: not-allowed; }
input[type="date"] { min-height: 48px; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.6; cursor: pointer; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); } }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
input[aria-invalid="true"], input.is-invalide, select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--rouge); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rouge) 18%, transparent);
}
input.is-valide {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23136C43' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px;
}
:root[data-theme="dark"] input.is-valide { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236FD3A2' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input.is-valide { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236FD3A2' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); } }
.champ-message, .champ-erreur {
  display: flex; gap: 6px; align-items: flex-start;
  font-size: 0.875rem; line-height: 1.4; color: var(--rouge); font-weight: 550;
}
.champ-message::before, .champ-erreur::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 1px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.4v.1'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.4v.1'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Cases à cocher et boutons radio */
.check {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  font-size: 0.9875rem; line-height: 1.45; min-height: 28px;
}
.check input[type="checkbox"], .check input[type="radio"], .case {
  flex: none; width: 24px; height: 24px; margin: 0; margin-top: -1px;
  border: 1.5px solid var(--trait-fort); background: var(--surface);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  display: grid; place-content: center;
  transition: background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.check input[type="checkbox"], .case { border-radius: 7px; }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="checkbox"]::before, .case::before {
  content: ""; width: 14px; height: 14px; transform: scale(0); transition: transform 120ms ease;
  background: var(--sur-jaune);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.check input[type="radio"]::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--sur-jaune); transform: scale(0); transition: transform 120ms ease; }
.check input:checked, .case:checked { background: var(--jaune); border-color: var(--jaune-bord); }
.check input:checked::before, .case:checked::before { transform: scale(1); }
.check input:focus-visible, .case:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.check input:disabled { opacity: 0.6; cursor: not-allowed; }
.check a { font-weight: 600; }

/* Choix en segments (boutons radio présentés côte à côte) */
.segments {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; gap: 4px; border-radius: 14px;
  background: var(--surface-3); border: 1px solid var(--trait);
}
.segments label { position: relative; display: block; min-width: 0; }
.segments input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segments span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px;
  font-weight: 600; font-size: 0.9375rem; color: var(--encre-2); text-align: center; line-height: 1.2;
  transition: background-color var(--transition), color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) { .segments input:hover + span { color: var(--encre); } }
.segments input:checked + span { background: var(--surface); color: var(--encre); box-shadow: var(--ombre-1), 0 0 0 1px var(--trait); }
.segments input:focus-visible + span { outline: 2px solid var(--encre); outline-offset: 1px; }
.segments input:disabled + span { opacity: 0.5; }
.segments-bloc { display: grid; width: 100%; }

/* ---------- Pastilles ---------- */
.chip, .puce {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 26px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 650; line-height: 1.2; white-space: nowrap; text-decoration: none;
  background: var(--surface-3); color: var(--encre-2); border: 1px solid var(--trait);
}
@media (hover: hover) { a.chip:hover, a.puce:hover { text-decoration: none; border-color: var(--trait-fort); } }
.chip-neutral, .puce-neutre { background: var(--surface-3); color: var(--encre-2); }
.chip-ok, .puce-ok { background: var(--vert-pale); color: var(--vert); border-color: color-mix(in srgb, var(--vert) 25%, transparent); }
.chip-warn, .puce-alerte { background: var(--orange-pale); color: var(--orange); border-color: color-mix(in srgb, var(--orange) 25%, transparent); }
.chip-danger, .puce-danger { background: var(--rouge-pale); color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 25%, transparent); }
.chip-pro, .puce-pro, .badge-pro {
  background: var(--jaune); color: var(--sur-jaune); border-color: var(--jaune-bord);
}
.badge-pro { display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 6px; font-size: 0.75rem; font-weight: 750; letter-spacing: 0.02em; border: 1px solid var(--jaune-bord); }
.statut-brouillon { background: var(--surface-3); color: var(--encre-2); }
.statut-envoye, .statut-a_payer { background: var(--jaune-pale); color: var(--jaune-texte); border-color: color-mix(in srgb, var(--jaune-bord) 45%, transparent); }
.statut-accepte, .statut-payee { background: var(--vert-pale); color: var(--vert); border-color: color-mix(in srgb, var(--vert) 25%, transparent); }
.statut-refuse { background: var(--rouge-pale); color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 25%, transparent); }

/* ---------- Encarts ---------- */
.encart, .encadre {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-2);
  background: var(--surface-3); border: 1px solid var(--trait);
  font-size: 0.9375rem; line-height: 1.5;
}
.encart > .ic { margin-top: 1px; }
.encart-alerte { background: var(--orange-pale); border-color: color-mix(in srgb, var(--orange) 25%, transparent); }
.encart-alerte > .ic { color: var(--orange); }
.encart-ok { background: var(--vert-pale); border-color: color-mix(in srgb, var(--vert) 25%, transparent); }
.encart-ok > .ic { color: var(--vert); }
.encart-danger { background: var(--rouge-pale); border-color: color-mix(in srgb, var(--rouge) 25%, transparent); }
.encart-jaune { background: var(--jaune-pale); border-color: color-mix(in srgb, var(--jaune-bord) 50%, transparent); }

/* Messages d'état (formulaires) */
.form-status, .statut-message {
  padding: 12px 14px; border-radius: var(--r-2); font-size: 0.9375rem; line-height: 1.45;
  background: var(--surface-3); border: 1px solid var(--trait);
}
.form-status.is-ok { background: var(--vert-pale); color: var(--vert); border-color: color-mix(in srgb, var(--vert) 25%, transparent); }
.form-status.is-err { background: var(--rouge-pale); color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 25%, transparent); }
.form-status.is-info { background: var(--jaune-pale); color: var(--encre); border-color: color-mix(in srgb, var(--jaune-bord) 45%, transparent); }
.form-status a { font-weight: 650; }

/* ---------- Menu flottant (⋯ et ≡) ---------- */
.menu-rapide {
  position: fixed; z-index: 120; width: min(340px, calc(100vw - 24px));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px; border-radius: var(--r-3);
  background: var(--surface); border: 1px solid var(--trait); box-shadow: var(--ombre-3);
  animation: menu-entree 140ms ease-out;
}
@keyframes menu-entree { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu-groupe + .menu-groupe { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--trait-doux); }
.menu-groupe[hidden] + .menu-groupe { margin-top: 0; padding-top: 0; border-top: 0; }
.menu-titre { padding: 8px 12px 4px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--encre-3); }
.menu-ligne {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 48px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--encre); text-align: left; text-decoration: none; font-size: 0.9875rem; font-weight: 550;
}
@media (hover: hover) { .menu-ligne:hover { background: var(--surface-3); text-decoration: none; } }
.menu-ligne:focus-visible { outline: 2px solid var(--encre); outline-offset: -2px; }
.menu-ligne > .ic, .menu-ligne > svg { width: 20px; height: 20px; color: var(--encre-2); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-ligne[aria-current="page"], .menu-ligne.is-actif { background: var(--jaune-pale); }
.menu-texte { display: flex; flex-direction: column; min-width: 0; }
.menu-detail { font-size: 0.8125rem; font-weight: 450; color: var(--encre-3); line-height: 1.35; }
.menu-cta { margin: 8px 4px 4px; display: flex; width: calc(100% - 8px); }

/* ---------- Boîtes de dialogue ---------- */
dialog.dialogue {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--trait); border-radius: var(--r-4);
  background: var(--surface); color: var(--encre); box-shadow: var(--ombre-3);
  overflow: auto; overscroll-behavior: contain;
}
dialog.dialogue::backdrop { background: var(--voile); }
dialog.dialogue[open] { animation: dialogue-entree 180ms cubic-bezier(.2, .8, .2, 1); }
@keyframes dialogue-entree { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialogue-form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dialogue-form > h2 { font-size: 1.375rem; font-stretch: var(--mi-large); font-weight: 750; padding-right: 24px; }
.dialogue-corps { display: flex; flex-direction: column; gap: 12px; color: var(--encre-2); }
.dialogue-corps ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }
.dialogue-actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 10px; margin-top: 4px; }
@media (max-width: 639px) {
  dialog.dialogue {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-4) var(--r-4) 0 0;
    border-bottom: 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom);
  }
  dialog.dialogue[open] { animation: feuille-entree 220ms cubic-bezier(.2, .8, .2, 1); }
  .dialogue-form { padding: 22px 18px 18px; }
  .dialogue-form::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--trait); margin: -8px 0 2px; }
  .dialogue-actions { flex-direction: column-reverse; }
  .dialogue-actions .btn { width: 100%; }
}
@keyframes feuille-entree { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed; z-index: 150; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: min(560px, calc(100vw - 24px));
  padding: 12px 12px 12px 18px; border-radius: 14px;
  background: var(--encre); color: var(--fond); box-shadow: var(--ombre-3);
  font-size: 0.9375rem; line-height: 1.4; font-weight: 500;
  animation: toast-entree 200ms cubic-bezier(.2, .8, .2, 1);
}
.toast:not(.avec-action) { padding-right: 18px; }
.toast.is-erreur { background: var(--rouge); color: #FFFFFF; }
:root[data-theme="dark"] .toast.is-erreur { color: #1A0B0A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.is-erreur { color: #1A0B0A; } }
.toast-action {
  flex: none; min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px;
  background: var(--jaune); color: var(--sur-jaune); font-weight: 700; font-size: 0.9375rem;
}
@media (hover: hover) { .toast-action:hover { background: var(--jaune-vif); } }
@keyframes toast-entree { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Petites aides ---------- */
.spinner {
  display: inline-block; width: 18px; height: 18px; flex: none;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; border-radius: 50%;
  animation: tourne 0.8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
.separateur { height: 1px; background: var(--trait); border: 0; margin: 0; }

/* ==========================================================================
   4. Site (en-tête, pied de page, pages de texte)
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 90;
  background: color-mix(in srgb, var(--fond) 94%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), background-color var(--transition);
}
.site-header.is-defile, .page-texte .site-header { border-bottom-color: var(--trait); }
@supports (backdrop-filter: blur(8px)) {
  .site-header { background: color-mix(in srgb, var(--fond) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
}
.header-row { display: flex; align-items: center; gap: 16px; height: var(--entete-h); }
.main-nav { display: flex; align-items: center; gap: 4px; margin-left: 20px; }
.main-nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--encre-2); font-weight: 550; font-size: 0.9688rem; text-decoration: none;
}
@media (hover: hover) { .main-nav a:hover { color: var(--encre); background: var(--surface-3); } }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.header-actions .btn { min-height: 42px; }
.bouton-menu {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--trait); background: var(--surface); color: var(--encre);
}
@media (hover: hover) { .bouton-menu:hover { background: var(--surface-3); } }
.bouton-menu .ic { width: 22px; height: 22px; }
.bouton-menu[aria-expanded="true"] { background: var(--surface-3); border-color: var(--trait-fort); }
.lien-connexion { font-weight: 600; text-decoration: none; padding: 0 10px; }
@media (max-width: 959px) {
  .main-nav, .lien-connexion { display: none; }
  .bouton-menu { display: inline-flex; }
}
@media (max-width: 380px) {
  .header-actions .btn { padding: 0 12px; font-size: 0.9375rem; }
  .logo { font-size: 1.125rem; }
}

/* Sections */
.section { padding-block: clamp(64px, 9vw, 112px); }
.section-fond { background: var(--fond-2); }
.section-tete { max-width: 720px; margin-bottom: clamp(32px, 5vw, 56px); }
.section-tete.centre { margin-inline: auto; text-align: center; }
.titre-section {
  font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 800; font-stretch: var(--large);
  letter-spacing: -0.028em; line-height: 1.04;
}
.section-tete p { margin-top: 16px; font-size: 1.125rem; color: var(--encre-2); max-width: 60ch; }
.section-tete.centre p { margin-inline: auto; }

/* Pied de page */
.site-footer { background: var(--bande); color: var(--sur-bande); padding: 56px 0 28px; }
.site-footer .logo { color: var(--sur-bande); }
.footer-grid { display: grid; gap: 32px; grid-template-columns: 1fr; }
.footer-grid h2 { font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sur-bande-2); font-weight: 700; margin-bottom: 14px; }
.footer-grid p { color: var(--sur-bande-2); margin-top: 14px; max-width: 34ch; font-size: 0.9688rem; }
.footer-links { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.footer-links a { display: inline-flex; min-height: 36px; align-items: center; color: var(--sur-bande); text-decoration: none; font-size: 0.9688rem; }
@media (hover: hover) { .footer-links a:hover { text-decoration: underline; } }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
  margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--trait-bande);
  color: var(--sur-bande-2); font-size: 0.875rem;
}
.site-footer :focus-visible { outline-color: var(--jaune); }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }

/* Pages de texte (mentions, confidentialité, CGU, CGV) */
.page-info { padding: clamp(40px, 6vw, 72px) 0 clamp(56px, 8vw, 96px); }
.prose { max-width: 780px; }
.prose h1 { font-size: clamp(2rem, 4.6vw, 3rem); font-weight: 800; font-stretch: var(--large); letter-spacing: -0.028em; line-height: 1.05; }
.prose .maj { margin-top: 12px; color: var(--encre-3); font-size: 0.9375rem; }
.prose h2 { margin-top: 44px; font-size: 1.375rem; font-weight: 750; font-stretch: var(--mi-large); }
.prose h3 { margin-top: 28px; font-size: 1.125rem; font-weight: 700; }
.prose p, .prose ul, .prose ol, .prose address, .prose blockquote, .prose .encadre, .prose .table-scroll { margin-top: 14px; }
.prose p, .prose li, .prose address, .prose blockquote { color: var(--encre-2); }
.prose ul, .prose ol { padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.prose address, .prose blockquote { margin-left: 0; margin-right: 0; font-style: normal; padding: 16px 18px; border-radius: var(--r-2); background: var(--surface); border: 1px solid var(--trait); line-height: 1.65; }
.prose a { font-weight: 550; }
.prose strong { color: var(--encre); }
.prose .encadre { display: block; background: var(--jaune-pale); border-color: color-mix(in srgb, var(--jaune-bord) 45%, transparent); color: var(--encre); }
.prose .encadre p { color: var(--encre); }
.prose .encadre > :first-child { margin-top: 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--trait); border-radius: var(--r-2); background: var(--surface); }
.table-scroll:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; min-width: 560px; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--trait-doux); color: var(--encre-2); }
.prose th { color: var(--encre); font-weight: 700; background: var(--surface-2); }
.prose tr:last-child td { border-bottom: 0; }

/* Pages courtes (merci, 404, confirmation d'abonnement) */
.page-simple { padding: clamp(56px, 10vw, 120px) 0; }
.page-simple .container, .page-simple .conteneur { max-width: 680px; }
.page-simple .code {
  font-size: clamp(4.5rem, 14vw, 8rem); font-weight: 850; font-stretch: 125%; line-height: 0.9; letter-spacing: -0.04em;
  color: transparent; -webkit-text-stroke: 2px var(--encre); margin-bottom: 18px;
}
.page-simple h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; font-stretch: var(--large); letter-spacing: -0.028em; line-height: 1.06; }
.page-simple p { margin-top: 16px; font-size: 1.125rem; color: var(--encre-2); }
.page-simple .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.page-simple .hint { font-size: 0.9375rem; }
.cle-abonnement { margin-top: 28px; padding: 20px; border-radius: var(--r-3); background: var(--surface); border: 1px solid var(--trait); display: flex; flex-direction: column; gap: 10px; }
.cle-abonnement label { font-weight: 650; }
.cle-ligne { display: flex; gap: 8px; }
.cle-ligne input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1rem; }
.cle-ligne .btn { flex: none; }
.page-simple .marque-ok {
  width: 56px; height: 56px; border-radius: 16px; background: var(--jaune); color: var(--sur-jaune);
  display: grid; place-items: center; margin-bottom: 22px;
}
.page-simple .marque-ok .ic { width: 30px; height: 30px; stroke-width: 2.4; }

/* Interrupteur (mode sombre) */
.interrupteur {
  position: relative; flex: none; margin-left: auto; width: 42px; height: 26px; border-radius: 999px;
  background: var(--surface-3); border: 1.5px solid var(--trait-fort);
  transition: background-color var(--transition), border-color var(--transition);
}
.interrupteur::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--trait-fort); transition: transform var(--transition), background-color var(--transition);
}
[aria-pressed="true"] > .interrupteur { background: var(--jaune); border-color: var(--jaune-bord); }
[aria-pressed="true"] > .interrupteur::after { transform: translateX(16px); background: var(--sur-jaune); }
