/* Application municipale de Ménil : feuille de style de la PWA (élus, agents, administrateur)
   Charte communale : Poppins ; violet #3D3453, turquoise #2EA8C8, doré #D9A441, encre #2A2439, fond #F4F7F9.
   Turquoise et doré ne servent jamais de couleur de texte sur fond clair (contraste insuffisant) :
   ils restent des accents (filets, triangle, pastilles). Les variantes lisibles sont --link et --gold-ink. */

/* Poppins hébergée sur le serveur de la commune (licence OFL, fonts/OFL.txt) : aucun appel à Google. */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/poppins-latin-800-normal.woff2") format("woff2"); }

:root {
  --violet: #3D3453;
  --turquoise: #2EA8C8;
  --dore: #D9A441;
  --encre: #2A2439;
  --fond: #F4F7F9;

  --bg: var(--fond);
  --surface: #FFFFFF;
  --surface-2: #F4F7F9;
  --ink: var(--encre);          /* 14,9:1 sur blanc */
  --ink-2: #5C5670;             /* 6,5:1 sur le fond */
  --line: #E4E9EF;             /* filets plus légers (application lumineuse, 30/11/2026) */
  --line-strong: #7A7290;       /* bordure des champs, 4,5:1 */
  --primary: var(--violet);     /* blanc sur violet : 11,6:1 */
  --on-primary: #FFFFFF;
  --primary-press: #2E2740;
  --link: #17708A;              /* turquoise foncé pour le texte : 5,3:1 */
  --accent: var(--turquoise);
  --accent-soft: #E3F4F9;
  --gold: var(--dore);
  --gold-soft: #FBF3E2;
  --gold-ink: #6B4E0E;          /* 7:1 sur --gold-soft */
  --danger: #B3261E;
  --danger-soft: #FCEDEB;
  --bubble: var(--violet);
  --on-bubble: #FFFFFF;
  --topbar: #FFFFFF;             /* barre du haut blanche (choix d'Arnaud, 30/11/2026) */
  --on-topbar: var(--violet);
  --on-topbar-2: var(--ink-2);
  --focus: var(--violet);
  --tile: #FFFFFF;
  --shadow: 0 1px 2px rgba(42, 36, 57, .04), 0 8px 24px rgba(42, 36, 57, .05);
  --viewer-bg: #E3E7ED;         /* fond de la visionneuse, la page blanche s'en détache */
  --mark: #FBE3A6;              /* mots cherchés surlignés */

  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 20px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --dur: 180ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

/* Mode sombre : réglage du téléphone, sauf choix forcé ?theme=light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1726;
    --surface: #262036;
    --surface-2: #1F1A2D;
    --ink: #F1EEF7;             /* 13,6:1 */
    --ink-2: #BDB6CC;           /* 8:1 */
    --line: #3A3350;
    --line-strong: #948CAB;
    --primary: #5CC3DD;         /* texte sombre sur turquoise clair : 8,6:1 */
    --on-primary: #1B1726;
    --primary-press: #7FD3EA;
    --link: #6FD0E8;
    --accent-soft: #1E3A47;
    --gold-soft: #3A3122;
    --gold-ink: #E2B865;
    --danger: #FFB4AB;
    --danger-soft: #3D2226;
    --bubble: #4A3F66;
    --topbar: #262036;
    --on-topbar: #F1EEF7;
    --on-topbar-2: #BDB6CC;
    --focus: #6FD0E8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --viewer-bg: #121019;
    --mark: #6B5418;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1726;
  --surface: #262036;
  --surface-2: #1F1A2D;
  --ink: #F1EEF7;
  --ink-2: #BDB6CC;
  --line: #3A3350;
  --line-strong: #948CAB;
  --primary: #5CC3DD;
  --on-primary: #1B1726;
  --primary-press: #7FD3EA;
  --link: #6FD0E8;
  --accent-soft: #1E3A47;
  --gold-soft: #3A3122;
  --gold-ink: #E2B865;
  --danger: #FFB4AB;
  --danger-soft: #3D2226;
  --bubble: #4A3F66;
  --topbar: #262036;
  --on-topbar: #F1EEF7;
  --on-topbar-2: #BDB6CC;
  --focus: #6FD0E8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --viewer-bg: #121019;
  --mark: #6B5418;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;          /* 17 px : confortable pour tous les âges */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
/* Titres qui reçoivent le focus par programme (changement d'onglet) : pas de cadre, qui ressemblait à un champ */
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible { outline: none; }

.sr-only {
  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 {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 12px 16px; border-radius: var(--r-s);
  font-weight: 600; box-shadow: var(--shadow);
}
.skip:focus { top: calc(8px + var(--safe-t)); }

.icon {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 10px 20px;
  border: 2px solid transparent; border-radius: 999px;
  font-weight: 600; font-size: 1.0625rem; line-height: 1.2; text-decoration: none;
  transition: background-color var(--dur) var(--ease-out), transform 120ms var(--ease-out);
}
.btn:active { transform: scale(.98); }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-press); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--quiet { background: transparent; color: var(--link); padding-inline: 12px; text-decoration: underline; text-underline-offset: 3px; }
.btn--outline-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--outline-danger:hover { background: var(--danger-soft); }
.btn--danger { background: var(--danger); color: var(--surface); }
.btn--danger:hover { filter: brightness(.92); }
.btn--small { min-height: 44px; padding: 8px 16px; font-size: 1rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.spinner {
  display: none; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent;
  animation: spin 800ms linear infinite;
}
.is-busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Démarrage et écrans isolés ---------- */
.boot {
  min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 16px;
  color: var(--ink-2);
}
.boot__logo { background: var(--tile); border-radius: var(--r-m); padding: 10px; width: 84px; }
.standalone {
  max-width: 440px; margin: 0 auto; padding: calc(48px + var(--safe-t)) 20px 32px;
  display: grid; gap: 20px; text-align: center; justify-items: center;
}
.standalone h1 { font-size: 1.625rem; font-weight: 800; }
.standalone__logo { background: var(--tile); border-radius: var(--r-m); padding: 12px; width: 120px; }

/* ---------- Connexion ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; }
.login__brand {
  position: relative;
  background: var(--violet);
  padding: calc(24px + var(--safe-t)) 20px 0;
  height: calc(132px + var(--safe-t));
  display: flex; justify-content: center; align-items: flex-start;
  overflow: visible;
}
/* Rappel du triangle turquoise du logo */
.login__brand::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  width: 46%; height: 100%;
  background: var(--turquoise);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
/* Tuile blanche entière, arrondie de tous côtés, avec une ombre : elle chevauche le bandeau sans paraître coupée */
.login__logo-tile {
  position: relative; z-index: 1;
  background: #FFFFFF; border-radius: var(--r-l);
  padding: 14px 22px;
  box-shadow: 0 2px 4px rgba(42, 36, 57, .12), 0 10px 28px rgba(42, 36, 57, .18);
}
.login__logo-tile img { width: 92px; }
.login__panel {
  flex: 1; width: 100%; max-width: 480px; margin: 0 auto;
  padding: 92px 20px calc(32px + var(--safe-b));
  display: flex; flex-direction: column; gap: 20px;
}
.login__title { font-size: 1.75rem; font-weight: 800; letter-spacing: .04em; text-align: center; }
.login__slogan { margin-top: -4px; color: var(--ink-2); font-weight: 500; text-align: center; }
.login__lead { color: var(--ink-2); text-align: center; }
.login__foot {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--ink-2); font-size: 1rem; display: grid; gap: 4px; text-align: center;
}
.login__foot strong { color: var(--ink); }

.notice {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  padding: 12px 14px; border-radius: var(--r-s);
}

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; }
.field__hint { color: var(--ink-2); font-size: 1rem; min-height: 1.6em; }
.field__error { color: var(--danger); font-weight: 500; display: flex; gap: 6px; }
.field__error::before { content: "!"; display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; margin-top: 2px; border-radius: 50%; background: var(--danger); color: var(--surface); font-weight: 800; font-size: .875rem; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: var(--r-s);
  font-size: 1.0625rem;
}
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input::placeholder { color: var(--ink-2); opacity: 1; }
.pw { position: relative; }
.pw__input { padding-right: 104px; }
.pw__toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  min-height: 44px; min-width: 92px; padding: 0 12px;
  background: transparent; border: 0; border-radius: var(--r-s);
  color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.form-error {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--danger-soft); color: var(--ink);
  border-left: 4px solid var(--danger); border-radius: var(--r-s); padding: 12px 14px;
}

/* ---------- Coque de l'application ---------- */
.is-app, .is-app body { overflow: hidden; }
.is-app body { height: var(--app-h, 100dvh); min-height: 0; }
.shell {
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "demo" "off" "main" "composer" "tabs";
}
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--topbar); color: var(--on-topbar);
  border-bottom: 3px solid var(--turquoise);
}
.topbar__tile {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; background: #FFFFFF; border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.topbar__tile img { width: 32px; }
.topbar__titles { display: grid; line-height: 1.25; min-width: 0; }
.topbar__title { font-weight: 800; font-size: 1.125rem; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { color: var(--on-topbar-2); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 479px) { .role-chip__more { display: none; } }
@media (max-width: 479px) { .topbar__sub { white-space: normal; font-size: .8125rem; line-height: 1.3; } }
.topbar .role-chip { margin-left: auto; }
.role-chip {
  display: inline-flex; align-items: center; flex: none;
  padding: 3px 12px; border-radius: 999px;
  font-size: .875rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--accent-soft); color: var(--ink);
  border: 1px solid transparent;
}
.topbar .role-chip { background: var(--accent-soft); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .topbar .role-chip { background: rgba(255, 255, 255, .14); color: var(--on-topbar); border-color: rgba(255, 255, 255, .35); }
.role-chip--admin { background: var(--gold-soft); color: var(--gold-ink); }
.topbar .role-chip--admin { background: var(--dore); color: #2A2439; border-color: var(--dore); }

.banner { padding: 8px 16px; font-size: 1rem; font-weight: 500; text-align: center; }
.banner--demo { grid-area: demo; background: var(--gold-soft); color: var(--gold-ink); border-bottom: 1px solid var(--gold); }
.banner--offline { grid-area: off; background: var(--danger-soft); color: var(--ink); border-bottom: 1px solid var(--danger); }

.main {
  grid-area: main;
  position: relative;            /* bloc conteneur : les éléments .sr-only ne font plus déborder la page */
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: 12px;
}
.main:focus { outline: none; }
.view { max-width: 680px; margin: 0 auto; padding: 20px 16px 28px; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  grid-area: tabs;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 64px; padding: 6px 4px;
  color: var(--ink-2); text-decoration: none; font-size: .9375rem; font-weight: 500;
}
.tab .icon {
  width: 56px; height: 30px; padding: 3px 16px; border-radius: 999px;
  transition: background-color var(--dur) var(--ease-out);
}
.tab[aria-current] { color: var(--ink); font-weight: 700; }
.tab[aria-current] .icon { background: var(--accent-soft); color: var(--link); }
.tab:focus-visible { outline-offset: -4px; border-radius: var(--r-m); }
.tab__label { white-space: nowrap; }
/* « Administration » abrégé en « Admin » sur les petits écrans (le nom accessible suit le texte visible) */
@media (max-width: 479px) { .tab__more { display: none; } .tab { font-size: .875rem; } }

/* Clavier ouvert : on libère la place de la barre d'onglets */
.kbd-open .tabbar { display: none; }

/* ---------- Zone de saisie ---------- */
.composer {
  grid-area: composer;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 12px 6px;
}
.composer__box { display: flex; align-items: flex-end; gap: 8px; max-width: 680px; margin: 0 auto; }
.composer__input {
  flex: 1; min-width: 0; min-height: 52px; max-height: 160px; resize: none;
  padding: 13px 18px; line-height: 1.45;
  background: var(--bg); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: 26px;
  font-size: 1.0625rem;
}
.composer__input::placeholder { color: var(--ink-2); opacity: 1; }
.composer__input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.composer__send {
  flex: none; display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--primary); color: var(--on-primary);
  transition: background-color var(--dur) var(--ease-out), transform 120ms var(--ease-out);
}
.composer__send .icon { width: 26px; height: 26px; stroke-width: 2.4; }
.composer__send:active { transform: scale(.94); }
.composer__send[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.composer__hint { max-width: 680px; margin: 2px auto 0; min-height: 1.2em; padding-inline: 18px; color: var(--ink-2); font-size: .9375rem; line-height: 1.3; }

/* ---------- Accueil des questions ---------- */
.intro { display: grid; gap: 14px; }
.intro__hello { color: var(--ink-2); font-weight: 500; }
.intro__title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
.intro__text { color: var(--ink-2); }
.intro__subtitle { font-size: 1.0625rem; font-weight: 600; margin-top: 8px; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.suggestion {
  width: 100%; min-height: 56px; padding: 12px 16px 12px 18px; text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--r-m); box-shadow: var(--shadow);
  font-weight: 500; line-height: 1.4;
  transition: background-color var(--dur) var(--ease-out), transform 120ms var(--ease-out);
}
.suggestion:hover { background: var(--accent-soft); }
.suggestion:active { transform: scale(.99); }
.ai-note {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 8px;
  padding: 14px 16px; border-radius: var(--r-m);
  background: var(--gold-soft); color: var(--ink);
}
.ai-note .icon { color: var(--gold-ink); margin-top: 2px; }

/* ---------- Historique ---------- */
.thread-tools { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.history { flex: 1; min-width: 0; }
.history__summary {
  min-height: var(--tap); display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-weight: 600; color: var(--ink); list-style: none;
}
.history__summary::-webkit-details-marker { display: none; }
.history__summary::after {
  content: ""; width: 9px; height: 9px; margin-left: 6px; margin-top: -4px;
  border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: rotate(45deg); transition: transform var(--dur) var(--ease-out);
}
.history[open] .history__summary::after { transform: rotate(-135deg); margin-top: 4px; }
.history__list { margin: 4px 0 8px; padding-left: 22px; display: grid; gap: 2px; }
.history__list a { display: inline-block; padding: 8px 0; color: var(--link); }

/* ---------- Fil des questions et réponses ---------- */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; }
.turn { display: grid; gap: 12px; scroll-margin-top: 12px; }
.turn__q {
  justify-self: end; max-width: 88%;
  background: var(--bubble); color: var(--on-bubble);
  border-radius: var(--r-l) var(--r-l) 6px var(--r-l);
  padding: 12px 16px;
}
.turn__qlabel { font-size: .875rem; opacity: .85; font-weight: 500; }

.answer {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 16px; box-shadow: var(--shadow);
  display: grid; gap: 14px;
}
.answer:focus { outline: none; }
.answer__badge {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start;
  font-size: .9375rem; font-weight: 600; color: var(--ink-2);
}
.answer__badge .icon { width: 20px; height: 20px; color: var(--gold-ink); }
.answer__verify {
  display: flex; gap: 10px; align-items: flex-start;
  border-top: 1px solid var(--line); padding-top: 12px;
  color: var(--ink-2); font-size: 1rem;
}
.answer__verify .icon { width: 20px; height: 20px; margin-top: 3px; }
.answer__time { color: var(--ink-2); font-size: .9375rem; }

/* Texte de réponse (Markdown simple rendu en DOM) */
.md { display: grid; gap: 10px; }
.md ul, .md ol { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; }
.md li::marker { color: var(--ink-2); }
.md strong { font-weight: 700; }
.md__h { font-weight: 700; }
/* Renvoi [n] : visible en 34 x 30 px, zone de clic élargie à 44 x 46 px par un pseudo-élément transparent */
.cite {
  position: relative;
  display: inline-grid; place-items: center; vertical-align: baseline;
  min-width: 34px; height: 30px; padding: 0 8px; margin: 0 5px;
  border: 1.5px solid var(--link); border-radius: 8px;
  background: var(--accent-soft); color: var(--link);
  font-size: 1rem; font-weight: 700; line-height: 1;
}
.cite::before { content: ""; position: absolute; inset: -8px -5px; border-radius: 10px; }
.cite:hover { background: var(--surface); }
.md p, .md li { line-height: 1.85; }

/* Sources : présentées comme des extraits du registre */
.sources { display: grid; gap: 10px; }
.sources__title { font-size: 1.0625rem; font-weight: 700; }
.sources__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.src {
  position: relative;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--r-s) var(--r-m) var(--r-m) var(--r-s);
  padding: 14px 14px 14px 16px;
  display: grid; gap: 10px;
  scroll-margin: 16px;
  transition: box-shadow 300ms var(--ease-out), border-color 300ms var(--ease-out);
}
.src:focus { outline: none; }
.src.is-flash { box-shadow: 0 0 0 3px var(--focus); }
.src__head { display: flex; gap: 12px; align-items: flex-start; }
.src__num {
  flex: none; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 800; font-size: 1rem;
}
.src__title { font-weight: 700; line-height: 1.35; }
.src__meta { color: var(--ink-2); font-size: 1rem; }
.src__quote {
  margin: 0; padding: 0 0 0 2px;
  color: var(--ink); font-size: 1rem; line-height: 1.6;
  white-space: pre-line;
}
.src__actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.src__actions .btn { min-height: 44px; padding: 8px 16px; font-size: 1rem; }
.src__more { justify-self: start; min-height: 44px; margin-top: -6px; padding-inline: 2px; }
.src__nopdf { color: var(--ink-2); font-size: 1rem; }
.more-sources { border-top: 1px dashed var(--line); padding-top: 6px; }
.more-sources > summary {
  min-height: var(--tap); display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-weight: 600; color: var(--link); list-style: none;
}
.more-sources > summary::-webkit-details-marker { display: none; }
.more-sources > summary::before {
  content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease-out);
}
.more-sources[open] > summary::before { transform: rotate(45deg); }
.more-sources[open] > summary { margin-bottom: 8px; }

/* Attente : la réponse prend 10 à 30 secondes */
.pending { display: grid; gap: 12px; }
.pending__row { display: flex; gap: 12px; align-items: center; }
.pending__phase { font-weight: 600; }
.pending__time { color: var(--ink-2); font-size: 1rem; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; flex: none; }
.pending__help { color: var(--ink-2); font-size: 1rem; }
.bar { position: relative; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 40%;
  background: var(--accent); border-radius: inherit;
  animation: slide 1.6s var(--ease-out) infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: 1rem; }
.steps li::before {
  content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-strong);
}
.steps li.is-done { color: var(--ink); }
.steps li.is-done::before { background: var(--accent); border-color: var(--accent); }
.steps li.is-current { color: var(--ink); font-weight: 600; }
.steps li.is-current::before { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 6px var(--accent); }

/* Refus bienveillant */
.answer--refus { background: var(--gold-soft); border-color: var(--gold); border-left-width: 4px; }
.answer--refus .answer__badge .icon { color: var(--gold-ink); }
.refus__title { font-weight: 700; font-size: 1.125rem; }
.refus__tips { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }

/* Erreur */
.answer--error { background: var(--danger-soft); border-color: var(--danger); border-left-width: 4px; }
.answer--error .answer__badge { color: var(--danger); }
.answer--error .answer__badge .icon { color: var(--danger); }
.error__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.error__actions .btn { flex: 1 1 auto; }

/* ---------- Séances ---------- */
.page-head { display: grid; gap: 6px; margin-bottom: 18px; }
.page-title { font-size: 1.625rem; font-weight: 800; letter-spacing: -.01em; }
.page-lead { color: var(--ink-2); }
.field--search { margin-bottom: 18px; }
.mandat { margin-bottom: 28px; }
.mandat__title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.25rem; font-weight: 800; margin-bottom: 10px;
}
.mandat__title::before { content: ""; width: 6px; height: 1.2em; border-radius: 3px; background: var(--accent); }
.mandat__note { color: var(--ink-2); font-size: 1rem; margin: -4px 0 12px; }
.annee { margin-bottom: 16px; }
.annee__title { font-size: 1.0625rem; font-weight: 700; color: var(--ink-2); margin: 0 0 6px 2px; }
.seances {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden;
}
.seances li + li { border-top: 1px solid var(--line); }
.seance {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 12px 14px 12px 16px;
  color: var(--ink); text-decoration: none;
}
a.seance:hover { background: var(--surface-2); }
a.seance:focus-visible { outline-offset: -3px; border-radius: var(--r-m); }
.seance__text { flex: 1; min-width: 0; display: grid; }
.seance__date { font-weight: 600; }
.seance__type { color: var(--ink-2); font-size: 1rem; line-height: 1.4; }
.seance__go {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  color: var(--link); font-weight: 600; font-size: 1rem;
}
.seance__go .icon { width: 22px; height: 22px; }
.seance__nopdf { flex: none; color: var(--ink-2); font-size: .9375rem; text-align: right; max-width: 7.5em; line-height: 1.3; }

.state {
  display: grid; gap: 14px; justify-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px;
}
.skeleton { display: grid; gap: 10px; }
.skeleton span { display: block; height: 64px; border-radius: var(--r-m); background: var(--line); opacity: .55; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- À propos ---------- */
.about { display: grid; gap: 12px; }
.about__block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 16px; display: grid; gap: 8px;
}
.about__block--gold { background: var(--gold-soft); border-color: var(--gold); }
.about__title { font-size: 1.125rem; font-weight: 700; }
.about__list { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.about__engine { font-weight: 600; }
.about__warn {
  background: var(--gold-soft); color: var(--ink); border-left: 4px solid var(--gold);
  border-radius: var(--r-s); padding: 10px 12px; font-weight: 500;
}
.refus__pistes { display: grid; gap: 10px; border-top: 1px solid var(--gold); padding-top: 12px; }
.answer--refus .src { background: var(--surface); }
.account {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line);
  display: grid; gap: 14px;
}
.account__version { color: var(--ink-2); font-size: .9375rem; text-align: center; }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(150px + var(--safe-b)); z-index: 50;
  max-width: 480px; margin: 0 auto;
  background: var(--ink); color: var(--bg);
  padding: 14px 18px; border-radius: var(--r-m); box-shadow: var(--shadow);
  font-weight: 500;
}

/* ---------- Bandeau « IA indisponible » ---------- */
.ia-banner {
  display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px;
  padding: 12px 14px; border-radius: var(--r-m);
  background: var(--gold-soft); border-left: 4px solid var(--gold); color: var(--ink);
}
.ia-banner .icon { color: var(--gold-ink); margin-top: 2px; }
.ia-banner__why { color: var(--ink-2); font-size: 1rem; margin-top: 4px; }

/* ---------- Tableau de bord ---------- */
.dash { display: grid; gap: 12px; margin-bottom: 8px; }
.dash__grid { display: grid; gap: 16px; }
.dash__block { display: grid; gap: 8px; align-content: start; }
.dash__title { font-size: 1.0625rem; font-weight: 700; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 10px 12px; display: grid; gap: 2px; align-content: start;
}
.stat__label { color: var(--ink-2); font-size: .9375rem; line-height: 1.3; }
.stat__value { font-size: 1.375rem; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat__sub { color: var(--ink-2); font-size: .9375rem; line-height: 1.3; }
.stat__bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.stat__fill { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; }
.stat__fill.is-high { background: var(--dore); }
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: 1 / -1; }
}
.seances--compact .seance { min-height: 56px; padding-block: 8px; }
.skeleton--small span { height: 48px; }
.skeleton--tall span { height: 120px; }

/* Lignes de séance cliquables (bouton qui ouvre la visionneuse) */
button.seance { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; color: var(--ink); }
button.seance:hover { background: var(--surface-2); }
button.seance:focus-visible { outline-offset: -3px; border-radius: var(--r-m); }
.annees { display: grid; }

/* ---------- Réponses : pied, copie, alertes, mode extraits ---------- */
.answer__foot {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); padding-top: 12px;
}
.answer__foot .answer__verify { border-top: 0; padding-top: 0; flex: 1 1 260px; }
.answer__copy { min-height: 44px; padding-inline: 10px; gap: 8px; }
.answer__copy .icon { width: 20px; height: 20px; }
.answer__copy.is-done { color: var(--ink); text-decoration: none; }
.answer__alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--r-s);
  background: var(--gold-soft); border-left: 4px solid var(--gold); font-size: 1rem;
}
.answer__alert .icon { color: var(--gold-ink); width: 22px; height: 22px; margin-top: 2px; }
.answer--extraits { border-left: 4px solid var(--accent); }
.answer--extraits .answer__badge .icon { color: var(--link); }
.extraits__lead { font-weight: 500; }

/* Badge « Lecture automatique » (document scanné) : explication dépliable, lisible au doigt comme au clavier */
.ocr { justify-self: start; }
.ocr__badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px;
  border-radius: 999px; border: 1px solid var(--gold);
  background: var(--gold-soft); color: var(--gold-ink);
  font-size: .9375rem; font-weight: 600; cursor: pointer; list-style: none;
}
.ocr__badge::-webkit-details-marker { display: none; }
.ocr__badge .icon { width: 18px; height: 18px; }
.ocr__badge::after {
  content: ""; width: 7px; height: 7px; margin: -3px 0 0 4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.ocr[open] .ocr__badge::after { transform: rotate(-135deg); margin-top: 3px; }
.ocr__text {
  margin-top: 8px; padding: 8px 12px; border-radius: var(--r-s);
  background: var(--gold-soft); color: var(--ink); font-size: 1rem;
}
.src__version { color: var(--ink-2); font-size: .9375rem; }
.src__headtext { min-width: 0; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Confirmation intégrée à la page ---------- */
.confirm {
  display: grid; gap: 10px; padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--r-m); background: var(--danger-soft); border-left: 4px solid var(--danger);
}
.confirm p { font-weight: 600; }
.confirm__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Documents : recherche par mots-clés ---------- */
.docsearch {
  display: grid; gap: 12px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px;
}
.docsearch__filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.docsearch .field__hint:empty { display: none; }
.select {
  appearance: none; -webkit-appearance: none; 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='%237A7290' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px;
}
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.result {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--r-s) var(--r-m) var(--r-m) var(--r-s); padding: 14px 16px; display: grid; gap: 8px;
}
.result__title { font-weight: 700; }
.result__meta { color: var(--ink-2); font-size: 1rem; }
.result__quote { margin: 0; font-size: 1rem; }
.results__foot { margin-top: 12px; }

.copy-buffer { position: fixed; top: 0; left: -9999px; opacity: 0; }

/* ---------- Visionneuse PDF ---------- */
.viewer-open body { overflow: hidden; }
.viewer {
  padding: 0; border: 0; margin: 0;
  width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  background: var(--surface); color: var(--ink);
}
.viewer[open] {
  position: fixed; inset: 0; height: var(--app-h, 100dvh);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
}
.viewer::backdrop { background: rgba(27, 23, 38, .65); }
.viewer__bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-t)) calc(6px + env(safe-area-inset-right, 0px)) 6px calc(16px + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.viewer__titles { flex: 1; min-width: 0; }
.viewer__title { font-size: 1.0625rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer__sub { color: var(--ink-2); font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer__download { min-height: 44px; padding: 8px 14px; font-size: 1rem; flex: none; }
.viewer__iconbtn {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink);
}
.viewer__iconbtn:hover { background: var(--surface-2); }
.viewer__iconbtn:disabled { opacity: .4; cursor: not-allowed; }
.viewer__iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--link); }
.viewer__stage {
  position: relative; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--viewer-bg); padding: 16px;
}
.viewer__stage:focus-visible { outline-offset: -4px; }
.viewer__page { width: max-content; margin: 0 auto; }
.viewer__canvas { display: block; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .14); }
.viewer__status {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px; text-align: center; color: var(--ink); background: var(--viewer-bg);
}
.viewer__status p { max-width: 28em; font-weight: 600; }
.viewer__spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--line-strong); border-right-color: transparent;
  animation: spin 800ms linear infinite;
}
.viewer__tools {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px 12px;
  padding: 4px calc(8px + env(safe-area-inset-right, 0px)) calc(4px + var(--safe-b)) calc(8px + env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line); background: var(--surface);
}
.viewer__group { display: flex; align-items: center; gap: 2px; }
.viewer__counter { min-width: 4.5em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.viewer__zoom { min-width: 3.6em; text-align: center; color: var(--ink-2); font-size: .9375rem; font-variant-numeric: tabular-nums; }
@media (max-width: 479px) {
  /* Le bouton de téléchargement garde son nom accessible, seul le libellé visible est masqué */
  .viewer__download { width: 48px; padding: 0; border-radius: 12px; }
  .viewer__download-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .viewer__zoom { display: none; }
}
@media (min-width: 1024px) {
  .viewer[open] {
    inset: 24px; width: auto; height: auto; max-width: 1120px; max-height: none; margin: 0 auto;
    border-radius: var(--r-l); overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  }
}

/* ---------- Administration ---------- */
.admin-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.admin-tab {
  flex: 1 1 auto; min-height: 44px; padding: 8px 14px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 1rem;
}
.admin-tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); }
@media (max-width: 599px) {
  .admin-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-tab { padding-inline: 8px; }
}
.admin-tab:hover:not([aria-selected="true"]) { background: var(--surface-2); color: var(--ink); }
.admin-panel { display: grid; gap: 16px; }
.admin-panel:focus { outline: none; }
.admin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.admin-title { font-size: 1.25rem; font-weight: 800; }
.admin-lead { color: var(--ink-2); font-size: 1rem; }
.admin-subtitle { font-size: 1.125rem; font-weight: 700; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; display: grid; gap: 16px; }
.admin-count { color: var(--ink-2); font-size: 1rem; margin-bottom: 4px; }
.admin-ok {
  font-weight: 600; padding: 8px 12px; border-radius: var(--r-s);
  background: var(--accent-soft); border-left: 4px solid var(--accent);
}
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-create { padding: 0; gap: 0; }
.admin-create__summary {
  min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-weight: 700; color: var(--link); cursor: pointer; list-style: none;
}
.admin-create__summary::-webkit-details-marker { display: none; }
.admin-create__plus {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-weight: 800; line-height: 1;
}
.admin-create[open] .admin-create__summary { border-bottom: 1px solid var(--line); }
.admin-form { padding: 16px; }
.admin-form__row { display: grid; gap: 14px; }

/* Code affiché une seule fois */
.codebox {
  display: grid; gap: 12px; padding: 16px; border-radius: var(--r-m);
  background: var(--accent-soft); border: 2px solid var(--accent);
}
.codebox__title { font-size: 1.125rem; font-weight: 700; }
.codebox__title:focus { outline: none; }
.codebox__code {
  justify-self: start; max-width: 100%;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 1.75rem; font-weight: 700; letter-spacing: .14em; line-height: 1.3;
  background: var(--surface); border-radius: var(--r-s); padding: 10px 14px;
  user-select: all; overflow-wrap: anywhere;
}
.codebox__rule { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.codebox__rule .icon { color: var(--gold-ink); margin-top: 2px; }
.codebox__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Comptes : tableau sur ordinateur, cartes sur téléphone */
.table-wrap { overflow-x: auto; }
.acct-table { width: 100%; border-collapse: collapse; }
.acct-table th { text-align: left; font-size: .9375rem; color: var(--ink-2); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.acct-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.acct.is-off td { color: var(--ink-2); }
.acct__id { font-size: .9375rem; overflow-wrap: anywhere; }
.etat { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9375rem; white-space: nowrap; }
.etat::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.etat--on::before { background: var(--link); }
.etat--off::before { border: 2px solid var(--ink-2); }
.acct__actions { text-align: right; }
.acct__panelcell { background: var(--surface-2); }
.acct__panel { display: grid; gap: 12px; padding: 4px 0; justify-items: start; }
.acct__paneltitle { font-weight: 700; }
.acct__tools { display: grid; gap: 12px; width: 100%; }
.acct__role { display: grid; gap: 4px; }
.acct__roleline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acct__roleline .select { width: auto; flex: 1 1 200px; max-width: 280px; min-height: 44px; padding-block: 8px; }
.acct__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 767px) {
  .acct-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .acct-table, .acct-table tbody, .acct-table tr, .acct-table td { display: block; width: 100%; }
  .acct { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 14px; margin-top: 10px; }
  .acct td { border: 0; padding: 4px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; text-align: right; }
  .acct td[data-label]::before { content: attr(data-label); color: var(--ink-2); font-size: .9375rem; text-align: left; }
  .acct td.acct__nom { font-size: 1.0625rem; text-align: left; }
  .acct td.acct__nom::before { content: none; }
  .acct td.acct__actions { justify-content: flex-end; padding-top: 8px; }
  .acct__panelcell { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-m) var(--r-m); padding: 12px 14px; }
}

/* Accès : matrice collection × rôle */
.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.matrix thead th { font-size: .9375rem; color: var(--ink-2); font-weight: 600; }
.matrix .matrix__role, .matrix .matrix__cell { text-align: center; width: 1%; hyphens: auto; }
.matrix__name { display: block; font-weight: 700; }
.matrix__desc { display: block; color: var(--ink-2); font-size: .9375rem; font-weight: 400; }
.matrix__count { display: block; color: var(--ink-2); font-size: .875rem; font-weight: 400; }
.check-wrap { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.matrix__lbl { display: none; }
/* Téléphone : chaque collection devient une carte, chaque case porte son rôle en clair */
@media (max-width: 599px) {
  .matrix thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .matrix, .matrix tbody { display: block; }
  .matrix tr { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .matrix tr:last-child { border-bottom: 0; }
  .matrix th, .matrix td { display: block; border: 0; padding: 0; }
  .matrix .matrix__col { width: 100%; }
  .matrix .matrix__cell { width: auto; }
  .matrix .check-wrap { display: inline-flex; gap: 8px; padding: 0 14px 0 10px; border: 1px solid var(--line); border-radius: 999px; }
  .matrix__lbl { display: inline; font-size: 1rem; }
}
.check, .radio { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); }

/* Journal */
.journal { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.journal__item { display: grid; gap: 0 14px; padding: 10px 14px; }
.journal__item + .journal__item { border-top: 1px solid var(--line); }
.journal__date { color: var(--ink-2); font-size: .9375rem; font-variant-numeric: tabular-nums; }
.journal__action { font-weight: 700; }
.journal__who { font-size: 1rem; }
.journal__detail { color: var(--ink-2); font-size: 1rem; }
.journal__item--echec_connexion .journal__action { color: var(--danger); }
@media (min-width: 900px) {
  .journal__item { grid-template-columns: 12em 16em minmax(0, 1fr); }
  .journal__detail { grid-column: 3; }
}

/* IA */
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.switch-row__label { display: grid; gap: 2px; cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 56px; height: 32px; border-radius: 999px; background: var(--line-strong); cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}
.switch::before {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: #FFFFFF; transition: transform var(--dur) var(--ease-out);
}
.switch:checked { background: var(--primary); }
.switch:checked::before { transform: translateX(24px); }
.fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--accent-soft); }
.choice label { display: grid; gap: 2px; cursor: pointer; flex: 1; min-width: 0; }
.choice .radio { margin-top: 3px; flex: none; }
.choice.is-disabled label { cursor: not-allowed; }
.choice__name { font-weight: 600; }
.choice__meta { color: var(--ink-2); font-size: .9375rem; }
.input--short { max-width: 9em; }
.input-suffix { display: flex; align-items: center; gap: 10px; }
.field__warn {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: var(--r-s);
  background: var(--danger-soft); border-left: 4px solid var(--danger); color: var(--ink); font-weight: 600; font-size: 1rem;
}
.field__warn .icon { color: var(--danger); width: 20px; height: 20px; margin-top: 2px; }
.ia-etat { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-s); font-weight: 600; }
.ia-etat--on { background: var(--accent-soft); border-left: 4px solid var(--accent); }
.ia-etat--off { background: var(--gold-soft); border-left: 4px solid var(--gold); }
.ia-etat .icon { margin-top: 1px; }
.usage__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.usage__grid div { background: var(--surface-2); border-radius: var(--r-s); padding: 10px 12px; }
.usage__grid dt { color: var(--ink-2); font-size: .9375rem; }
.usage__grid dd { margin: 0; font-weight: 700; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.gauge { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.gauge__fill { display: block; width: 0; height: 100%; background: var(--accent); }
.gauge__fill.is-high { background: var(--dore); }
.usage__daystitle { font-size: 1rem; font-weight: 700; }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.days__row { display: grid; grid-template-columns: 6.2em minmax(40px, 1fr) auto; gap: 10px; align-items: center; font-size: .9375rem; }
.days__date { font-variant-numeric: tabular-nums; }
.days__bar { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.days__fill { display: block; width: 0; height: 100%; background: var(--accent); border-radius: 4px; }
.days__val { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage__note { color: var(--ink-2); font-size: .9375rem; }

/* ---------- Tablette ---------- */
@media (min-width: 720px) {
  .view { padding-top: 28px; }
  .tabbar { justify-content: center; grid-auto-columns: minmax(0, 180px); }
  .docsearch { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .docsearch__filters { grid-template-columns: 190px 150px; }
  .docsearch .field__hint { grid-column: 1 / -1; }
}
@media (min-width: 768px) {
  .admin-form__row { grid-template-columns: 1.3fr 1fr .9fr; align-items: start; }
}
@media (min-width: 900px) {
  .usage__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Ordinateur : navigation latérale, colonnes plus larges ---------- */
@media (min-width: 1024px) {
  .shell {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "tabs demo" "tabs off" "tabs main" "tabs composer";
  }
  .topbar { padding-inline: 20px 24px; }
  .tabbar {
    display: flex; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tab {
    display: flex; align-items: center; justify-content: flex-start; gap: 12px;
    min-height: 52px; padding: 8px 14px; border-radius: 12px; font-size: 1rem;
  }
  .tab .icon { width: 24px; height: 24px; padding: 0; }
  .tab[aria-current] .icon { background: none; }
  .tab:hover { background: var(--surface-2); color: var(--ink); }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .tab:focus-visible { outline-offset: -3px; }
  .view { max-width: 840px; padding: 32px 32px 40px; }
  .view--wide { max-width: 1060px; }
  .composer__box, .composer__hint { max-width: 840px; }
  .dash__grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
  .suggestions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .suggestion { height: 100%; }
  .annees { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; align-items: start; }
  .toast { bottom: 120px; }
}
@media (min-width: 1280px) {
  .view { max-width: 920px; }
  .view--wide { max-width: 1140px; }
  .composer__box, .composer__hint { max-width: 920px; }
  .sources__list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* ---------- Téléphone en paysage (hauteur réduite) : rail de navigation à gauche, en-tête compact ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .shell {
    grid-template-columns: calc(88px + env(safe-area-inset-left, 0px)) minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "tabs demo" "tabs off" "tabs main" "tabs composer";
  }
  .topbar {
    gap: 10px; border-bottom-width: 2px;
    padding: calc(4px + var(--safe-t)) calc(12px + env(safe-area-inset-right, 0px)) 4px calc(12px + env(safe-area-inset-left, 0px));
  }
  .topbar__tile { width: 34px; height: 34px; border-radius: 9px; }
  .topbar__tile img { width: 24px; }
  .topbar__titles { display: flex; align-items: baseline; gap: 10px; }
  .topbar__title { font-size: 1rem; }
  .topbar__sub { font-size: .875rem; }
  .banner { padding: 2px 12px; font-size: .875rem; }
  .tabbar {
    display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; overflow-y: auto;
    padding: 4px 4px calc(4px + var(--safe-b)) calc(4px + env(safe-area-inset-left, 0px));
    border-top: 0; border-right: 1px solid var(--line);
  }
  .tab { min-height: 52px; padding: 2px; gap: 0; font-size: .8125rem; }
  .tab .icon { width: 48px; height: 26px; padding: 2px 12px; }
  .tab__more { display: none; }
  .view { padding: 12px calc(16px + env(safe-area-inset-right, 0px)) 16px 16px; }
  .composer { padding: 6px calc(12px + env(safe-area-inset-right, 0px)) 4px 12px; }
  .composer__input { min-height: 44px; padding: 9px 16px; border-radius: 22px; max-height: 96px; }
  .composer__send { width: 44px; height: 44px; }
  .composer__hint:empty { display: none; }
  .kbd-open .tabbar { display: flex; }
  .kbd-open .topbar, .kbd-open .banner { display: none; }
  .toast { bottom: calc(72px + var(--safe-b)); }

  .login { flex-direction: row; }
  .login__brand {
    position: sticky; top: 0; width: 34%; max-width: 300px; height: 100dvh;
    align-items: center; padding: 16px;
  }
  .login__panel { padding: calc(16px + var(--safe-t)) calc(24px + env(safe-area-inset-right, 0px)) calc(16px + var(--safe-b)); gap: 14px; max-width: 520px; }
  .login__title { font-size: 1.5rem; }
  .viewer__title { font-size: 1rem; }
  .viewer__sub { display: none; }
  .viewer__stage { padding: 8px; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
  .bar::before { animation: none; width: 100%; opacity: .5; }
  .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
}

/* ---------- Contraste renforcé (Windows) ---------- */
@media (forced-colors: active) {
  .src, .answer, .suggestion, .seances, .about__block { border: 1px solid CanvasText; }
  .cite, .src__num { border: 1px solid ButtonText; }
  .result, .stat, .admin-card, .journal, .codebox, .confirm, .ia-banner, .docsearch, .viewer__canvas { border: 1px solid CanvasText; }
  .switch { border: 2px solid ButtonText; }
  .switch:checked::before { background: Highlight; }
  .admin-tab[aria-selected="true"], .tab[aria-current="page"] { outline: 2px solid Highlight; }
}

/* ---------- Application lumineuse (30/11/2026) ----------
   Charte v1.1 : environ 70 % de blanc glacier, 20 % de prune (texte, bouton principal), 10 % d'accents.
   Surfaces blanches sur fond blanc glacier ; la voile cyan du logo reste le seul élément marquant ;
   un fin trait ocre sous le logo signe chaque écran (« signature chaude permanente »).
   Le thème sombre (?theme=dark) n'est pas concerné. */
:root:not([data-theme="dark"]) .login__brand { background: var(--surface); border-bottom: 1px solid var(--line); }
:root:not([data-theme="dark"]) .login__brand::after { width: 34%; }
:root:not([data-theme="dark"]) .login__logo-tile {
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(42, 36, 57, .08);
}
.login__logo-tile::after,
.topbar__tile::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  height: 3px; border-radius: 3px; background: var(--dore);
}
.login__logo-tile::after { bottom: -14px; width: 56px; }
.topbar__tile { position: relative; }
.topbar__tile::after { bottom: -6px; width: 26px; height: 2px; }
@media (max-width: 1023px) { .topbar__tile::after { bottom: -4px; width: 20px; } }
:root:not([data-theme="dark"]) .topbar { border-bottom-width: 2px; }


/* Lien d'évitement caché : son ombre ne doit pas déborder en haut de l'écran */
.skip:not(:focus) { box-shadow: none; }

/* ---------- Coquille de logiciel métier (30/11/2026) ----------
   Organisation des logiciels de gestion des collectivités (barre du haut avec collectivité, recherche,
   alertes, compte et lanceur de modules ; menu latéral coloré à pilule ; fil d'Ariane), aux couleurs de
   la charte : prune pour l'institution (menu, environ 20 %), blanc glacier dominant, cyan en accent. */
.topbar__ctx, .topsearch, .topbar .topbtn--lanceur { display: none; }
.topbtn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 999px; border: 0; background: transparent;
  color: var(--violet); cursor: pointer; text-decoration: none;
}
.topbtn .icon { width: 22px; height: 22px; }
.topbtn:hover { background: var(--surface-2); }
.topbtn__badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #FFFFFF;
  font-size: .6875rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--topbar);
}
.topbar .role-chip { margin-left: auto; }
.topbar #top-alertes { margin-left: auto; }
.compte { position: relative; flex: none; }
.avatar {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px;
  border: 0; background: var(--violet); color: #FFFFFF; cursor: pointer;
  font: 700 .875rem/1 var(--font); letter-spacing: .02em;
}
.avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--accent-soft); }
.popover {
  position: absolute; z-index: 40; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: 0 2px 6px rgba(42, 36, 57, .06), 0 18px 40px rgba(42, 36, 57, .12);
}
.compte-menu { top: calc(100% + 8px); right: 0; width: 260px; padding: 8px; display: grid; }
.compte-menu[hidden], .lanceur[hidden] { display: none; }
.compte-menu__nom { padding: 8px 12px 0; font-weight: 700; }
.compte-menu__role { padding: 0 12px 8px; color: var(--ink-2); font-size: .9375rem; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.compte-menu__item {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--r-s);
  border: 0; background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.compte-menu__item:hover { background: var(--surface-2); }
#compte-logout { color: var(--danger); }
.lanceur {
  top: calc(100% + 6px); right: 12px; width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 96px); overflow: auto; padding: 18px 20px 20px;
}
.lanceur__entete { font-size: 1.0625rem; font-weight: 700; margin-bottom: 12px; }
.lanceur__grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.lanceur__titre { font-size: .875rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.lanceur__liens { display: grid; gap: 2px; }
.lanceur__lien {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px;
  border-radius: var(--r-s); color: var(--ink); text-decoration: none; font-size: .9375rem;
}
.lanceur__lien .icon { width: 20px; height: 20px; color: var(--link); flex: none; }
.lanceur__lien:hover { background: var(--accent-soft); }
.topbar { position: relative; }

/* Fil d'Ariane des modules */
.ariane ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; list-style: none; margin: 0 0 10px; padding: 0; font-size: .9375rem; color: var(--ink-2); }
.ariane li + li::before { content: "›"; margin-right: 4px; color: var(--ink-2); }
.ariane a { color: var(--link); text-underline-offset: 2px; }
.ariane [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* Raccourcis de l'accueil (sites officiels) */
.raccourcis { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; }
.raccourci {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  font-size: .9375rem; font-weight: 500; text-decoration: none;
}
.raccourci:hover { border-color: var(--turquoise); background: var(--accent-soft); }

@media (max-width: 1023px) {
  .raccourci { min-height: 44px; }
  .topbar .role-chip { display: none; }
  .compte-menu { position: fixed; top: calc(64px + var(--safe-t)); right: 12px; }
}

@media (min-width: 1024px) {
  .topbar { min-height: 68px; gap: 14px; }
  .topbar__sub { font-size: .8125rem; }
  .topbar .role-chip { display: none; }
  .topbar__ctx {
    display: inline-flex; align-items: center; height: 36px; padding: 0 14px; margin-left: 12px;
    border: 1px solid var(--line); border-radius: 999px; color: var(--violet);
    font-size: .875rem; font-weight: 600; white-space: nowrap;
  }
  .topsearch { display: flex; align-items: center; position: relative; flex: 1 1 auto; max-width: 520px; margin-left: auto; }
  .topsearch__icon { position: absolute; left: 14px; width: 20px; height: 20px; color: var(--ink-2); pointer-events: none; }
  .topsearch__input {
    width: 100%; height: 44px; padding: 0 16px 0 44px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--fond); color: var(--ink); font: inherit; font-size: .9375rem;
  }
  .topsearch__input::placeholder { color: var(--ink-2); }
  .topsearch__input:focus { background: var(--surface); border-color: var(--violet); }
  .topbar .topbtn--lanceur { display: inline-grid; }
  .topbar #top-alertes { margin-left: 4px; }

  /* Menu latéral prune, élément actif en pilule blanc glacier (texte prune) */
  :root:not([data-theme="dark"]) .tabbar { background: var(--violet); border-right: 0; scrollbar-color: rgba(255, 255, 255, .3) transparent; }
  :root:not([data-theme="dark"]) .tabbar .tab { color: #FFFFFF; }
  :root:not([data-theme="dark"]) .tabbar .tab:hover { background: rgba(255, 255, 255, .10); color: #FFFFFF; }
  :root:not([data-theme="dark"]) .tabbar .tab[aria-current="page"] { background: var(--fond); color: var(--violet); box-shadow: none; }
  :root:not([data-theme="dark"]) .tabbar .tab[aria-current="true"] { background: none; color: #FFFFFF; }
  :root:not([data-theme="dark"]) .tabbar .tabsub__link { color: #E4DFF0; }
  :root:not([data-theme="dark"]) .tabbar .tabsub__link:hover { background: rgba(255, 255, 255, .10); color: #FFFFFF; }
  :root:not([data-theme="dark"]) .tabbar .tabsub__link[aria-current="page"] { background: var(--fond); color: var(--violet); font-weight: 700; box-shadow: none; }
  :root:not([data-theme="dark"]) .tabbar :focus-visible { outline-color: #FFFFFF; }
  :root:not([data-theme="dark"]) .tabbar .tab[aria-current] .icon { color: inherit; }
  .tabsub__groupe { list-style: none; }
  .tabsub__titre { display: block; padding: 12px 12px 4px; font-size: .8125rem; font-weight: 600; color: #C9C1DD; }
  .tabsub__liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
}
