/* === Chat Area === */
#chat-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Le pied de saisie flotte visuellement au-dessus du chat. Sa hauteur réelle
     est mesurée par chat.js afin que le dernier contenu puisse toujours
     remonter entièrement au-dessus du champ opaque. */
  padding: 80px var(--space-5) var(--chat-bottom-space, 180px) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4); /* page plus dense entre question et réponse (était --space-8) */
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  max-width: 80%;
  position: relative;
  min-width: 0;
}

.msg.user {
  align-self: flex-end;
  max-width: 80%;
  /* Ne pas conserver le transform final : `forwards` créait durablement un
     contexte d'empilement autour de tout le message. */
  animation: slideInRight 0.25s ease-out;
}

.msg.assistant {
  align-self: flex-start;
  /* Colonne : la bulle puis, sous elle (hors zone de texte), .msg-actions —
     voir "Message Actions" plus bas. .msg-avatar est display:none, n'affecte
     pas la disposition. position:relative sert d'ancre à .msg-actions
     (position:absolute), qui flotte donc sans jamais pousser le texte ni
     les messages suivants. */
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  animation: slideInLeft 0.3s ease-out;
}

/* Dernière réponse : espace minimal réservé sous la bulle pour .msg-actions.
   Si la barre de saisie remonte au-delà de cette réserve (champ multilignes,
   fenêtre basse), le positionnement adaptatif plus bas prend le relais. */
.msg.assistant:last-child {
  margin-bottom: 48px;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Avatars masqués */
.msg-avatar {
  display: none;
}

.msg-bubble {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  word-wrap: break-word;
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: break-word;
}

html[data-dys-spacing="true"] .msg-bubble {
  line-height: var(--dys-line-height);
  letter-spacing: var(--dys-spacing);
  word-spacing: var(--dys-word-spacing);
}

.msg.user .msg-bubble {
  background: var(--ansu-bubble-user);
  color: var(--ansu-bubble-user-text);
  border-bottom-right-radius: var(--radius-xs);
  border: 1px solid var(--ansu-bubble-user-border);
  /* Bulle élève en textContent (pas de rendu markdown) : préserver les sauts
     de ligne saisis au clavier sans interpréter le reste du texte comme HTML. */
  white-space: pre-wrap;
}

.msg.assistant .msg-bubble {
  background: var(--ansu-bubble-assistant);
  color: var(--ansu-bubble-assistant-text);
  border-bottom-left-radius: var(--radius-xs);
  border: 1px solid var(--ansu-bubble-assistant-border);
}

/* Message de bienvenue */
#chat-area .msg.assistant:first-child .msg-bubble {
  background: var(--ansu-bubble-assistant);
}

.msg-bubble p {
  margin: 0 0 10px 0;
}

.msg-bubble p:last-child {
  margin: 0;
}

.msg-bubble pre {
  background: rgba(0, 0, 0, 0.05);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

html[data-theme="nuit"] .msg-bubble pre {
  background: rgba(255, 255, 255, 0.05);
}

/* Dégradé de fond subtil en nuit — nécessaire pour rendre le glassmorphisme perceptible */
html[data-theme="nuit"] #chat-area {
  background:
    radial-gradient(ellipse 70% 45% at 20% 15%, rgba(59, 158, 255, 0.06) 0%, transparent 100%),
    radial-gradient(ellipse 60% 50% at 80% 85%, rgba(59, 158, 255, 0.04) 0%, transparent 100%);
}

html[data-theme="nuit"] textarea {
  color: #e2e8f0;
}

html[data-theme="nuit"] textarea::placeholder {
  color: #4a5568;
}

html[data-theme="nuit"] #scroll-to-bottom {
  background: #080e1e;
  border-color: rgba(214, 235, 253, 0.22);
}

html[data-theme="nuit"] .char-counter {
  color: #94a3b8; /* contraste ~7:1 sur fond quasi noir (le précédent #475569 était trop proche du fond) */
}

.msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.9em;
}

.msg-bubble th,
.msg-bubble td {
  border: 1px solid var(--ansu-bubble-assistant-border);
  padding: 6px 10px;
  text-align: left;
}

.msg-bubble th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* === Message Actions ===
   Sibling de .msg-bubble (pas un descendant, voir chat.js/send.js), en
   position:absolute sous la bulle : un overlay flottant qui ne fait jamais
   bouger le texte ni les messages suivants (contrairement à un max-height
   animé, qui grandit la boîte de .msg pendant la transition). Pour la
   dernière bulle, .msg.assistant:last-child réserve un espace minimal ;
   chat.js bascule le menu au-dessus s'il risque de dépasser la zone visible.

   Déclenchement via .actions-visible (posée par chat.js wireMessageActions)
   avec un délai de grâce avant fermeture (HOVER_HIDE_DELAY_MS), plus robuste
   qu'un simple :hover CSS pour un overlay qu'on doit atteindre à la souris.
   :focus-within reste géré en CSS pur pour la navigation clavier. */
.msg-actions {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-2);
  /* Seul le menu passe devant la saisie. Le texte du message reste dans le
     plan normal et ne peut donc jamais recouvrir le champ opaque. */
  z-index: 110;
  display: flex;
  gap: var(--space-2);
  justify-content: flex-start;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

/* Si le menu risque de dépasser la conversation ou de rencontrer la barre de
   saisie, chat.js pose cette classe et l'ouvre au-dessus de la réponse. */
.msg.assistant.actions-above .msg-actions {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: var(--space-2);
}

.msg.assistant.actions-visible .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  /* Pas de survol sur tactile : autant réserver l'espace normalement plutôt
     que de flotter en permanence par-dessus le message suivant. */
  .msg-actions {
    position: static;
    opacity: 1;
    pointer-events: auto;
  }
  .msg.assistant.actions-above .msg-actions {
    margin-bottom: 0;
  }
  .msg.assistant:last-child {
    margin-bottom: 0; /* déjà réservé par le flux normal ci-dessus */
  }
}

.btn-save-mem {
  background: transparent;
  border: none;
  color: var(--ansu-primary);
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
  opacity: 0.7;
}

.btn-save-mem:hover {
  background: color-mix(in srgb, var(--ansu-primary) 10%, transparent);
  opacity: 1;
}

/* Lecteur TTS déplié dans .msg-actions : .tts-player (memory.css) a width:100%
   pensé pour le panneau mémoires en colonne — ici il doit rester compact dans
   la rangée d'actions de la bulle. */
.tts-inline-wrap {
  display: inline-flex;
}

.tts-player.tts-player--inline {
  width: auto;
  max-width: 220px;
}


/* === Message d'erreur système (avec Réessayer) === */
.msg.system-error {
  align-self: flex-start;
  max-width: 80%;
}

.msg.system-error .msg-bubble {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

html[data-theme="nuit"] .msg.system-error .msg-bubble {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-retry {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  /* Pas --radius-full : il vaut 50 %, ce qui déforme en ellipse tout élément
     plus large que haut. Un rayon en pixels donne une extrémité en
     demi-cercle quelle que soit la longueur du libellé. */
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-retry:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* === Typing indicator === */
.typing {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-1);
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--ansu-primary);
  border-radius: 50%;
  opacity: 0.6;
  animation: bounceTyping 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounceTyping {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-4px); }
}

/* === Scroll To Bottom === */
#scroll-to-bottom {
  position: absolute;
  /* Position mesurée par rapport au bord supérieur du champ de question. */
  bottom: var(--scroll-button-bottom, 150px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ansu-chat-bg);
  border: 1px solid var(--ansu-input-border);
  color: var(--ansu-text-main);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 120;
  transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
  opacity: 1;
}

#scroll-to-bottom.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

#scroll-to-bottom:hover {
  background: color-mix(in srgb, var(--ansu-primary) 12%, var(--ansu-chat-bg));
  border-color: var(--ansu-primary);
  transform: translateX(-50%) translateY(-2px);
}

/* === Input Area — Fenêtre flottante sélectivement transparente ===
   Le conteneur extérieur flotte au-dessus de la conversation et reste
   transparent. chat.js réserve simultanément sa hauteur dans le scroll : le
   dernier message ne finit jamais derrière le champ, mais les messages plus
   anciens peuvent glisser visuellement dans la bande transparente. */
#input-area {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
  margin: 0;
  padding: 12px 20px 24px;
  background: transparent;
  z-index: 100;
  pointer-events: none;
}

@media (max-width: 768px) {
  #input-area {
    width: 95%;
    bottom: 15px;
    padding: 14px var(--space-4);
  }
}

@media (max-width: 640px) {
  #input-area {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
}

/* .input-wrapper : bloc unique (fusion de 3 définitions redondantes — l'ancien
   fichier redéclarait ce sélecteur à trois endroits, la dernière l'emportant
   pour la plupart des propriétés). Toutes les valeurs ci-dessous sont celles
   effectivement rendues avant la fusion ; aucune n'a été modifiée. */
.input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  /* Le champ seul reste opaque : aucun texte défilant n'est lisible derrière
     la saisie, contrairement à la bande extérieure volontairement transparente. */
  background: var(--ansu-chat-bg);
  border: 1px solid var(--ansu-frost-border, #e2e8f0);
  border-radius: 28px;
  padding: 12px 48px 12px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), rgba(176, 199, 217, 0.08) 0px 0px 0px 1px;
  transition: border-color 0.2s, box-shadow 0.2s;
  pointer-events: all; /* Laisse passer les clics sur le chat derriere si on clique a cote */
  /* Aucun backdrop-filter ici : sur Chrome, le calque de flou pouvait être
     recomposé comme translucide pendant le défilement, malgré le fond opaque. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.input-wrapper textarea {
  width: 100%;
}

.input-wrapper:focus-within {
  border-color: var(--ansu-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ansu-primary) 12%, transparent), 0 8px 32px rgba(0, 0, 0, 0.1);
}

textarea {
  width: 100%;
  padding: 16px 18px 16px 20px;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ansu-text-main);
  background: transparent;
  resize: none;
  outline: none;
  min-height: 56px;
  max-height: 160px; /* ~6 lignes maximum */
  line-height: 1.5;
  display: block;
}

textarea:focus-visible {
  outline: none;
}

#chat-input {
  border: none;
  padding: 0;
  box-shadow: none;
  background: transparent;
  min-height: 24px;
  line-height: 1.5;
}

/* #send-btn : bloc unique (fusion de 2 définitions — la 2de, positionnée "à
   cheval" sur le bord du input-wrapper via right:0 + translate(50%,-50%),
   l'emportait pour la position/couleur/ombre finales). */
#send-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--ansu-chat-bg); /* effet "à cheval" sur le bord du input-wrapper */
  background: var(--ansu-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.5;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

#send-btn.has-text {
  opacity: 1;
}

#send-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
  transition: transform 0.2s;
}

#send-btn:hover:not(:disabled) {
  transform: translate(50%, -50%) scale(1.05);
  /* --ansu-primary-dark n'a jamais existé : le repli bleu-gris s'appliquait
     donc toujours, y compris sur les thèmes abeille et nature, où le bouton
     changeait de famille de couleur au survol. La teinte descend maintenant
     du primaire du thème. */
  background: color-mix(in srgb, var(--ansu-primary) 82%, black);
}

#send-btn:active {
  transform: scale(0.92);
}

#send-btn:active svg {
  transform: translateX(2px) translateY(-2px);
}

#send-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

/* === Bouton Arrêter (pendant la génération) === */
#send-btn.stopping {
  background: #ef4444;
  opacity: 1;
  animation: pulsePrimary 1.5s infinite;
}

#send-btn.stopping:hover {
  background: #dc2626;
}

@keyframes pulsePrimary {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* .char-counter : bloc unique (fusion de 2 définitions — la 2de repositionnait
   le compteur en absolute dans le coin bas-droit du input-wrapper). */
.char-counter {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 9px;
  color: #6b7280; /* contraste ~4.6:1 sur fond clair (le précédent #94a3b8 ~2.6:1 échouait WCAG AA) */
  text-align: right;
  padding: 0 18px 8px 0;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  user-select: none;
}

.char-counter.visible {
  opacity: 1;
}

.char-counter.warn {
  color: #ef4444;
  font-weight: 600;
}

/* === Status Bar === */
#status-bar {
  font-size: 0.8rem;
  text-align: center;
  color: var(--ansu-primary);
  padding-bottom: 8px;
  min-height: 1.2em;
}

#status-bar.thinking::after {
  content: '...';
  display: inline;
  animation: dotPulse 1.5s steps(3, end) infinite;
  letter-spacing: 2px;
}

@keyframes dotPulse {
  0%   { opacity: 0.2; }
  50%  { opacity: 1; }
  100% { opacity: 0.2; }
}

.input-tools-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 8px;
  padding-right: 8px;
  /* Les zones vides laissent passer les clics vers la conversation. */
  pointer-events: none;
}

.input-tools-bar > .tool-btn,
.input-tools-secondary {
  pointer-events: auto;
}

/* La version classique conserve la rangée historique. Les versions suivantes
   peuvent transformer ce conteneur en menu sans dupliquer les contrôles. */
#btn-more-tools {
  display: none;
}

.input-tools-secondary {
  display: contents;
}

/* Ordre historique de la rangée classique malgré le regroupement des actions
   secondaires dans un conteneur partagé avec les versions candidates. */
#btn-clear { order: 1; }
#btn-context { order: 2; }
#mic-btn { order: 3; }
#btn-document-link { order: 4; }
#btn-attach-pdf { order: 5; }

.tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--ansu-chat-bg) 80%, transparent);
  border: 1px solid var(--ansu-frost-border, var(--ansu-input-border));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ansu-text-main);
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
}

.tool-btn:hover {
  background: color-mix(in srgb, var(--ansu-primary) 10%, transparent);
  color: var(--ansu-primary);
  border-color: var(--ansu-primary);
  transform: translateY(-1px);
}

.tool-btn.off {
  opacity: 0.4;
  filter: grayscale(1);
}

/* ── Carte pièce jointe (chat with PDF) ── */
.attachment-card {
  border: 1px solid var(--ansu-frost-border, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.85rem;
}
.attachment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(37, 99, 235, 0.06);
  flex-wrap: wrap;
}
.attachment-toggle {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--ansu-primary, #2563eb);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.attachment-content {
  padding: 10px 12px;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0,0,0,0.02);
}
.attachment-content pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  color: #475569;
  margin: 0;
}

/* ── Bouton microphone — états enregistrement ── */
#mic-btn.recording {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
  animation: ansu-mic-pulse 1.2s ease-in-out infinite;
}

#mic-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

@keyframes ansu-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* ── Thème Nuit — overrides zone de saisie ── */

/* border-color/box-shadow gardent !important : en nuit, .input-wrapper et
   .input-wrapper:focus-within ont la même spécificité (0,2,0) et focus-within
   est déclaré plus loin dans ce fichier — sans !important le focus-within
   (anneau bleu primary) l'emporterait à nouveau en thème nuit sur ces deux
   propriétés, ce qui n'est pas le rendu actuel (nuit garde son style figé,
   sans anneau de focus visible). background n'a pas ce conflit : il n'est
   jamais réécrit par focus-within. */
html[data-theme="nuit"] .input-wrapper {
  /* La zone de saisie doit masquer totalement la conversation, même si la
     bande flottante qui l'entoure reste transparente. */
  background: #080e1e;
  border-color: rgba(214, 235, 253, 0.22) !important;
  box-shadow: rgba(176, 199, 217, 0.145) 0px 0px 0px 1px, 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="nuit"] #chat-input::placeholder {
  color: #475569;
}

html[data-theme="nuit"] .input-tools-bar .tool-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border-color: rgba(214, 235, 253, 0.19);
}

html[data-theme="nuit"] .input-tools-bar .tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border-color: rgba(214, 235, 253, 0.4);
}

/* background garde !important : #send-btn:hover:not(:disabled) (spécificité
   1,2,0) est plus spécifique que ce sélecteur nuit (1,1,0) — sans !important,
   le survol repasserait à la couleur primary-dark du thème clair même en nuit. */
html[data-theme="nuit"] #send-btn {
  background: #3b9eff !important;
  box-shadow: 0 4px 14px rgba(59, 158, 255, 0.35);
}

/* ── Suggestions de démarrage (chips) ── */
.starter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 80%;
  padding-left: 2px;
  align-self: flex-start;
}

/* ── Boutons de routage agent ── */
.routing-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 2px 0;
}

.routing-btn {
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--ansu-frost-border, var(--ansu-input-border));
  background: color-mix(in srgb, var(--ansu-chat-bg) 85%, transparent);
  color: var(--ansu-text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.routing-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ansu-primary) 10%, transparent);
  border-color: var(--ansu-primary);
  color: var(--ansu-primary);
  transform: translateY(-1px);
}

.routing-btn.selected {
  background: var(--ansu-primary);
  color: white;
  border-color: var(--ansu-primary);
}

.routing-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

html[data-theme="nuit"] .routing-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(214, 235, 253, 0.22);
  color: #cbd5e1;
}

html[data-theme="nuit"] .routing-btn:hover:not(:disabled) {
  background: rgba(59, 158, 255, 0.12);
  border-color: rgba(59, 158, 255, 0.5);
  color: #93c5fd;
}

html[data-theme="nuit"] .routing-btn.selected {
  background: #3b9eff;
  color: white;
}

/* ── Séparateur de changement d'agent ── */
.routing-separator {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ansu-text-main);
  opacity: 0.55;
  margin: -8px 0;
}

.routing-separator::before,
.routing-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ansu-frost-border, var(--ansu-input-border));
  min-width: 24px;
}

.routing-separator strong {
  font-weight: 600;
  opacity: 1;
}

/* ============================================================
   Inspecteur de raisonnement (mode aperçu développeur)
   Jamais rendu chez un élève : le serveur n'émet pas les données.
   Volontairement en retrait des bulles — c'est un outil, pas un message.
   ============================================================ */

.msg.inspect-turn {
  max-width: 100%;
  align-self: stretch;
}

.inspect-panel {
  border: 1px dashed var(--ansu-frost-border);
  border-radius: var(--radius-md);
  background: var(--ansu-bubble-assistant);
  color: var(--ansu-bubble-assistant-text);
  font-size: 0.82rem;
  overflow: hidden;
}

.inspect-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.inspect-summary::-webkit-details-marker { display: none; }

.inspect-summary::after {
  content: "▸";
  margin-left: auto;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.inspect-panel[open] > .inspect-summary::after { transform: rotate(90deg); }

.inspect-title { font-weight: 600; }

.inspect-stats {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.inspect-body {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Le flux de raisonnement : texte brut, jamais interprété comme du Markdown. */
.inspect-stream,
.inspect-prompt {
  margin: 0;
  padding: 10px;
  max-height: 340px;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ansu-frost-border);
  background: var(--ansu-chat-bg);
  color: var(--ansu-text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.inspect-stream:empty { display: none; }

.inspect-section > summary {
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
  opacity: 0.85;
}

.inspect-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.inspect-table th,
.inspect-table td {
  text-align: left;
  padding: 3px 8px 3px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--ansu-frost-border);
}

.inspect-table th {
  font-weight: 500;
  opacity: 0.7;
  white-space: nowrap;
}

.inspect-table td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.inspect-verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.inspect-badge {
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--ansu-primary-contrast);
}

.inspect-badge.ok { background: var(--ansu-success); }
.inspect-badge.ko { background: var(--ansu-danger); }

.inspect-reason { opacity: 0.8; }
