:root {
  --fond: #f6f7f9;
  --surface: #ffffff;
  --texte: #1c2330;
  --discret: #5d6777;
  --bordure: #dde2ea;
  --accent: #2456d6;
  --accent-texte: #ffffff;
  --accent-doux: #e8eefc;
  --erreur: #b42318;
  --code: #f0f2f5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11151c;
    --surface: #181e27;
    --texte: #e6e9ef;
    --discret: #9aa4b4;
    --bordure: #2a3240;
    --accent: #6d95ff;
    --accent-texte: #0b1020;
    --accent-doux: #1e2a45;
    --erreur: #ff8a7a;
    --code: #222a36;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
button { font: inherit; cursor: pointer; }
.discret { color: var(--discret); }
.erreur { color: var(--erreur); }

.bandeau {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.marque { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); font-size: 1.2em; }
.pastille {
  font-size: .72em; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 99px; background: var(--accent-doux); color: var(--accent);
}
.compte { display: flex; align-items: center; gap: 12px; font-size: .92em; }
.compte form { margin: 0; }

button.secondaire, button.lien { background: none; border: 1px solid var(--bordure); color: var(--texte);
  border-radius: 8px; padding: 6px 10px; }
button.lien { border: 0; color: var(--discret); padding: 6px 0; text-decoration: underline; }

/* Connexion */
.connexion { flex: 1; display: grid; place-items: center; padding: 16px; }
.carte {
  width: min(100%, 380px); background: var(--surface); border: 1px solid var(--bordure);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.carte h1 { margin: 0; font-size: 1.35em; }
.carte p { margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .92em; font-weight: 550; }
input, textarea {
  font: inherit; color: var(--texte); background: var(--fond); border: 1px solid var(--bordure);
  border-radius: 9px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button[type="submit"] {
  background: var(--accent); color: var(--accent-texte); border: 0; border-radius: 9px;
  padding: 10px 16px; font-weight: 600;
}
button[disabled] { opacity: .55; cursor: progress; }

/* Chat */
.chat {
  flex: 1; min-height: 0; width: min(100%, 860px); margin: 0 auto; padding: 0 16px;
  display: flex; flex-direction: column;
}
.accueil { padding: 28px 0 8px; overflow-y: auto; }
.accueil h1 { font-size: 1.5em; line-height: 1.25; margin: 0 0 8px; }
.exemples { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.groupe { display: flex; flex-direction: column; gap: 8px; }
.groupe h2 { font-size: .8em; text-transform: uppercase; letter-spacing: .05em; color: var(--discret); margin: 0; }
.exemple {
  text-align: left; background: var(--surface); color: var(--texte); border: 1px solid var(--bordure);
  border-radius: 10px; padding: 10px 12px; font-size: .92em; line-height: 1.4;
}
.exemple:hover { border-color: var(--accent); background: var(--accent-doux); }

.fil { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 16px; }
.fil:empty { display: none; }
.message { max-width: 100%; }
.message.utilisateur {
  align-self: flex-end; max-width: 85%; background: var(--accent-doux); border-radius: 14px 14px 4px 14px;
  padding: 10px 14px; white-space: pre-wrap;
}
.message.assistant { background: var(--surface); border: 1px solid var(--bordure); border-radius: 14px; padding: 14px 16px; }
.message.assistant .corps { white-space: pre-wrap; }
.message.assistant .corps.rendu { white-space: normal; }
.corps p:first-child { margin-top: 0; }
.corps p:last-child { margin-bottom: 0; }
.corps table { border-collapse: collapse; margin: 10px 0; font-size: .92em; display: block; overflow-x: auto; }
.corps th, .corps td { border: 1px solid var(--bordure); padding: 5px 9px; text-align: left; }
.corps th { background: var(--fond); }
.corps code { background: var(--code); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

.etapes { list-style: none; margin: 0 0 10px; padding: 0; font-size: .86em; color: var(--discret);
  display: flex; flex-direction: column; gap: 4px; }
.etapes li::before { content: "↳ "; color: var(--accent); }
.etapes details { display: inline; }
.etapes summary { cursor: pointer; display: inline; }
.etapes pre { margin: 6px 0 4px; padding: 8px 10px; background: var(--code); border-radius: 8px;
  white-space: pre-wrap; word-break: break-word; font-size: .92em; }
.attente { color: var(--discret); font-size: .9em; }
.attente::after { content: "…"; animation: points 1.2s steps(4, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes points { from { width: 0; } to { width: 1.2em; } }
.pied { margin-top: 10px; font-size: .78em; color: var(--discret); }

.saisie { display: flex; gap: 10px; align-items: flex-end; padding: 12px 0 16px; }
.saisie textarea { resize: none; min-height: 48px; max-height: 200px; }

@media (max-width: 600px) {
  .compte .discret { display: none; }
  .accueil h1 { font-size: 1.25em; }
  .message.utilisateur { max-width: 95%; }
}

/* Navigation */
a.marque { color: inherit; text-decoration: none; }
.navigation { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.navigation a, .filtre-historique a {
  color: var(--discret); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .92em;
}
.navigation a:hover, .filtre-historique a:hover { color: var(--texte); background: var(--fond); }
.navigation a[aria-current="page"], .filtre-historique a[aria-current="page"] {
  color: var(--accent); background: var(--accent-doux); font-weight: 600;
}
.retour { padding: 4px 0 0; }

/* Historique */
.historique { width: min(100%, 1200px); margin: 0 auto; padding: 24px 16px 40px; }
.titre-historique { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.titre-historique h1 { margin: 0; font-size: 1.4em; }
.filtre-historique { display: flex; gap: 4px; }
.totaux { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 20px 0; }
.totaux > div { background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; }
.totaux .chiffre { font-size: 1.4em; font-weight: 650; font-variant-numeric: tabular-nums; }
.defilement { overflow-x: auto; background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px; }
.tableau { width: 100%; border-collapse: collapse; font-size: .9em; }
.tableau th, .tableau td { padding: 10px 12px; border-bottom: 1px solid var(--bordure); text-align: left; vertical-align: top; }
.tableau tbody tr:last-child td { border-bottom: 0; }
.tableau th { font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); font-weight: 600; }
.tableau .nombre { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tableau .date { white-space: nowrap; }
.tableau .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; white-space: nowrap; }
.tableau .demande { min-width: 320px; max-width: 560px; }
.tableau .demande summary { cursor: pointer; font-weight: 550; }
.tableau .demande .corps { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--bordure); }
.tableau .demande .etapes { margin-top: 8px; }
.tableau tr.en-erreur td:first-child { box-shadow: inset 3px 0 0 var(--erreur); }
.legende { font-size: .8em; margin-top: 8px; }
.pages { display: flex; justify-content: space-between; margin-top: 12px; }
.pages a { color: var(--accent); }

@media (max-width: 600px) {
  .navigation { margin-left: 0; }
  .bandeau { flex-wrap: wrap; }
}
