/* ================================================================
   FONTS — Satoshi (Fontshare) · JetBrains Mono (Google Fonts)
   ================================================================ */
@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

/* ================================================================
   DESIGN TOKENS — Règles opinionnées anti-générique IA

   ✗ Interdits : teal "couleur IA", border-radius excessifs,
     bulle iMessage, barre latérale colorée sur les messages,
     palette froide SaaS, emoji décoratif en guise d'icône,
     input flottant avec box-shadow, dots ronds dans la sidebar.

   ✓ Autorisés : terracotta brûlé + parchemin linen, géométrie
     rectilinéaire (coins presque plats = intention délibérée),
     hiérarchie typographique assertive, design éditorial.
   ================================================================ */
:root {
  /* ── Accent : Terracotta/brique brûlée ──
     Chaleureux, autoritaire. L'opposé du bleu/teal IA générique.  */
  --clr-primary:       #C2410C;
  --clr-primary-hover: #9A3412;
  --clr-primary-light: #FFF7ED;
  --clr-primary-muted: rgba(194,65,12,.12);

  /* ── Catégories — contraste calibré sur fond chaud ── */
  --clr-technique: #1D4ED8;
  --clr-rh:        #047857;
  --clr-juridique: #6D28D9;

  /* ── Surfaces — parchemin/linen, pas de gris SaaS froid ──
     #F5F0E8 : la couleur du papier de qualité, pas d'un fond d'app. */
  --clr-bg:        #F5F0E8;
  --clr-surface:   #FDFBF7;
  --clr-surface-2: #EDE5D8;   /* bulle utilisateur : ambre teinté  */
  --clr-sidebar:   #12100A;   /* noir café — chaud, pas navy        */

  /* ── Texte — profond et chaud, jamais #000 ── */
  --clr-text:       #1C1109;
  --clr-text-muted: #6B5C45;
  --clr-text-faint: #A89880;

  /* ── Bordures — chaudes ── */
  --clr-border: #D8D0C4;

  /* ── États ── */
  --clr-success: #047857;
  --clr-warn:    #B45309;
  --clr-error:   #B91C1C;

  /* ── Messages ── */
  --clr-bubble-user: var(--clr-surface-2);
  --clr-bubble-bot:  var(--clr-surface);

  /* ── Layout ── */
  --sidebar-w: 260px;
  --header-h:  54px;

  /* ── Rayons — rectilinéaires, intentionnels.
     Le design imprimé n'arrondit pas tout. Les coins presque plats
     sont la marque d'une géométrie voulue, pas générée.           */
  --r-sm:  2px;
  --r:     4px;
  --r-lg:  6px;
  --r-xl:  10px;
  --r-full:9999px;

  /* ── Ombres — teinte ambrée, plus naturelles que les grises ── */
  --shadow-sm: 0 1px 3px  rgba(28,17,9,.06);
  --shadow:    0 2px 8px  rgba(28,17,9,.08), 0 1px 3px rgba(28,17,9,.05);
  --shadow-md: 0 4px 18px rgba(28,17,9,.10);
  --shadow-lg: 0 10px 36px rgba(28,17,9,.15);

  /* ── Easing — Impeccable animate.md + Taste MOTION_INTENSITY:6 ──
     ease-out-expo : "confident, decisive" (cubic-bezier(0.16,1,0.3,1))
     Utilisé pour TOUT. Jamais `ease`, jamais `linear`, jamais bounce.  */
  --ease:      cubic-bezier(0.16, 1, 0.3, 1);   /* ease-out-expo     */
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);       /* ease-in — sorties */

  /* ── Durées par intention (Impeccable animate.md) ──
     100–150ms : feedback immédiat (touche, toggle)
     200–300ms : changement d'état (hover, menu)
     300–500ms : layout (accordéon, modal)           */
  --t:      200ms var(--ease);
  --t-fast: 120ms var(--ease);
  --t-slow: 300ms var(--ease);

  /* ── Espacement fluide (clamp) ── */
  --sp-xs: clamp(0.5rem,  1vw,  0.75rem);
  --sp-sm: clamp(0.75rem, 2vw,  1rem);
  --sp-md: clamp(1rem,    3vw,  1.5rem);
  --sp-lg: clamp(1.5rem,  4vw,  2.5rem);
  --sp-xl: clamp(2rem,    6vw,  4rem);

  /* ── Typographie ── */
  --font:      'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}

/* ================================================================
   RESET
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
[hidden] { display: none !important; }

/* Supprime le flash bleu sur tap — iOS & Android */
* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  font-size: clamp(0.9375rem, 0.875rem + 0.33vw, 1rem);
  color: var(--clr-text);
  background: var(--clr-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* OpenType features Satoshi — kern + ligatures (Impeccable typeset.md) */
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-kerning: normal;
}

/* ── Focus-visible — anneau clavier accessible, invisible au clic ──
   Impeccable product.md : state vocabulary complet obligatoire         */
:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
/* Neutralise l'outline natif (remplacé par :focus-visible ci-dessus) */
:focus:not(:focus-visible) { outline: none; }

body.modal-open { overflow: hidden; }

/* touch-action: manipulation → supprime le délai 300ms iOS/Android
   sans désactiver le zoom utilisateur sur la page               */
button {
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
code { font-family: var(--font-mono); }
a    { color: var(--clr-primary); }

/* ================================================================
   LAYOUT
   ================================================================ */
.app {
  display: flex;
  /* 100dvh = hauteur réelle sur mobile (exclut barres nav Safari) */
  height: 100dvh;
  overflow: hidden;
}

/* ================================================================
   SIDEBAR — mobile-first : drawer caché par défaut
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(var(--sidebar-w), 85vw);
  flex-shrink: 0;
  background: var(--clr-sidebar);
  color: #A1A1AA;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* scroll momentum iOS */
  transform: translateX(-100%);
  transition: transform var(--t-slow), box-shadow var(--t-slow);
  z-index: 100;
  /* iOS : ne pas couper le contenu sous la barre d'état */
  padding-top: env(safe-area-inset-top);
}

.sidebar--open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.sidebar-header {
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-icon {
  width: 30px; height: 30px;
  /* Carré aux coins légèrement arrondis — pas de cercle générique */
  border-radius: var(--r);
  background: var(--clr-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #FFF;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  /* Même teinte parchemin que le fond — cohérence palette */
  color: #F5F0E8;
  letter-spacing: -0.3px;
}

.sidebar-section {
  padding: 20px 12px 12px;
  flex: 1;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid rgba(255,255,255,.04);
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3F3F46;
  padding: 0 6px;
  margin-bottom: 10px;
}

/* ── Catégories ── */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t);
  font-size: 0.875rem;
  color: #71717A;
  user-select: none;
  touch-action: manipulation;
}

.category-item input[type="radio"] { display: none; }
.category-item:hover   { background: rgba(255,255,255,.05); color: #D4D4D8; }
.category-item--active { background: rgba(194,65,12,.18);   color: #FDBA74 !important; }

.category-dot {
  width: 6px; height: 6px;
  /* Carré intentionnel — les ronds sont le défaut paresseux */
  border-radius: 1px;
  flex-shrink: 0;
}
.category-dot.all       { background: #52525B; }
.category-dot.technique { background: var(--clr-technique); }
.category-dot.rh        { background: var(--clr-rh); }
.category-dot.juridique { background: var(--clr-juridique); }

.category-count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  background: rgba(255,255,255,.06);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: #52525B;
}

/* ── Liste documents ── */
.document-list { display: flex; flex-direction: column; gap: 10px; }

.doc-list__empty {
  font-size: 0.8125rem;
  color: #52525B;
  padding: 4px 6px;
  line-height: 1.8;
}

.doc-list__empty code {
  background: rgba(255,255,255,.07);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  color: #FDBA74;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.doc-group__label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #3F3F46;
  padding: 0 6px;
  margin-bottom: 4px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  color: #71717A;
  font-size: 0.8125rem;
  transition: color var(--t), background var(--t);
  position: relative;
  touch-action: manipulation;
}

.doc-item:hover { color: #D4D4D8; background: rgba(255,255,255,.04); }
.doc-item__icon { font-size: 0.75rem; flex-shrink: 0; }
.doc-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
  flex: 1;
}

/* ── Boutons d'action sur les documents ── */
.doc-item__actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t);
  flex-shrink: 0;
}
.doc-item:hover .doc-item__actions { opacity: 1; }

.doc-item__btn {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border: none; border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem; line-height: 1; padding: 0;
  transition: background var(--t);
  color: inherit;
  touch-action: manipulation;
}
.doc-item__btn:disabled { opacity: .4; cursor: not-allowed; }
.doc-item__btn--reindex:hover { background: rgba(194,65,12,.22); }
.doc-item__btn--delete:hover  { background: rgba(185,28,28,.22); }

/* ── Bouton suppression catégorie custom ── */
.cat-delete-btn {
  display: none;
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  color: #71717A;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
  touch-action: manipulation;
}
.category-item--custom:hover .cat-delete-btn { display: flex; }
.cat-delete-btn:hover { background: rgba(185,28,28,.18); color: #FCA5A5; }

/* ── Toast de notification ── */
.app-toast {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: 0.875rem; font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  text-align: center;
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.app-toast--ok    { background: #052e16; color: #86efac; border: 1px solid #14532d; }
.app-toast--error { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
.app-toast--warn  { background: #431407; color: #fdba74; border: 1px solid #7c2d12; }

/* ── Bouton upload sidebar ── */
.sidebar-upload {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.05);
  margin-top: auto;
  /* iOS : espace au-dessus du home indicator */
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.upload-trigger-btn {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid rgba(194,65,12,.35);
  background: rgba(194,65,12,.10);
  color: #FDBA74;
  font-size: 0.8125rem; font-weight: 600;
  transition: background var(--t), border-color var(--t), color var(--t);
  touch-action: manipulation;
  min-height: 44px;
}

.upload-trigger-btn:hover {
  background: rgba(194,65,12,.20);
  border-color: rgba(194,65,12,.55);
  color: #FED7AA;
}

.upload-trigger-btn__icon { font-size: 1rem; font-weight: 300; }

/* ================================================================
   MAIN
   ================================================================ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Header ── */
.header {
  height: var(--header-h);
  background: var(--clr-surface);
  /* Bordure épaisse — séparation structurelle, pas un shadow flottant */
  border-bottom: 2px solid var(--clr-border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
  /* iOS : dégager la barre d'état (Dynamic Island, notch) */
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}

.menu-btn {
  display: flex; flex-direction: column; gap: 4.5px;
  background: none; border: none; padding: 4px;
  min-width: 44px; min-height: 44px;
  align-items: center; justify-content: center;
  touch-action: manipulation;
}
.menu-btn span {
  display: block;
  width: 18px; height: 1.5px;
  background: var(--clr-text-muted);
  border-radius: 1px;
  transition: background var(--t);
}
.menu-btn:hover span { background: var(--clr-text); }

.header-center { flex: 1; }

.header-title {
  font-size: 0.9375rem; font-weight: 700;
  color: var(--clr-text);
  line-height: 1.2; letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 0.6875rem;
  color: var(--clr-text-faint);
  margin-top: 1px; letter-spacing: .2px;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Status badge ── */
.status-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: .3px;
  border: 1px solid transparent;
}
.status-badge--ok    { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.status-badge--warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.status-badge--error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Puce de requêtes (dans le badge de statut) ── */
.rate-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 0.625rem; font-weight: 700; letter-spacing: .2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.rate-chip--ok     { background: #dcfce7; color: #15803d; border-color: #86efac; }
.rate-chip--warn   { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.rate-chip--danger { background: #fef2f2; color: #991b1b; border-color: #fca5a5;
                     animation: rate-blink 1.2s ease-in-out infinite; }
@keyframes rate-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}

/* ── Modal alerte (limite journalière, etc.) ── */
.modal--alert {
  max-width: 380px;
  text-align: center;
  padding: 36px 32px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.modal__alert-icon { font-size: 2.5rem; line-height: 1; }
.modal--alert .modal__title { font-size: 1.1rem; }
.modal__alert-body {
  font-size: 0.9rem; color: var(--clr-text-secondary);
  line-height: 1.55; margin: 0;
}
.modal--alert .btn-primary {
  margin-top: 6px; width: 100%; max-width: 220px;
  padding: 10px 24px;
  background: var(--clr-primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.modal--alert .btn-primary:hover { background: var(--clr-primary-hover, #4f46e5); }

/* ── Sélecteur de langue ── */
.lang-switcher {
  display: flex; align-items: center;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-full);
  padding: 2px; gap: 2px;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: var(--r-full); border: none;
  background: transparent;
  font-size: 0.6875rem; font-weight: 700;
  color: var(--clr-text-muted); letter-spacing: .8px;
  transition: background var(--t), color var(--t);
  touch-action: manipulation;
}
.lang-btn:hover   { color: var(--clr-text); }
.lang-btn--active { background: var(--clr-primary); color: #FFF; }

.new-chat-btn {
  width: 44px; height: 44px;
  border-radius: var(--r); border: 1px solid var(--clr-border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9375rem;
  transition: background var(--t), border-color var(--t);
  color: var(--clr-text-muted);
  touch-action: manipulation;
}
.new-chat-btn:hover {
  background: var(--clr-primary-light);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

/* ── Chat container ── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* scroll momentum iOS */
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;   /* centre la colonne de lecture */
  gap: 4px;
  scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar       { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 2px; }

/* ── Écran de bienvenue — éditorial, gauche, pas centré-iMessage ── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;   /* aligné à gauche dans la colonne */
  justify-content: center;   /* centré verticalement */
  text-align: left;
  padding: clamp(2rem, 6vw, 4rem) 0 clamp(1.5rem, 4vw, 3rem);
  flex: 1;
  max-width: 680px;
  width: 100%;
}

/* Ornement typographique — remplace l'emoji décoratif générique.
   Une barre colorée : simple, intentionnelle, pas un picto.        */
.welcome-icon {
  display: block;
  width: 32px; height: 3px;
  background: var(--clr-primary);
  border-radius: 1px;
  margin-bottom: 24px;
  /* Cache le contenu texte (émoji) de la div HTML */
  font-size: 0; color: transparent; overflow: hidden;
}

.welcome h2 {
  /* Heading assertif — 26px mobile → 40px desktop */
  font-size: clamp(1.625rem, 1rem + 2.4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--clr-text);
  /* Tracking serré sur les gros titres = marque du design imprimé */
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.welcome p {
  color: var(--clr-text-muted);
  max-width: 52ch;
  font-size: clamp(0.875rem, 0.83rem + 0.23vw, 0.9375rem);
  line-height: 1.75;
}

.example-questions {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: flex-start;   /* gauche, pas centré */
  margin-top: 28px;
}

.example-btn {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text-muted);
  font-size: 0.8125rem; font-weight: 500;
  /* Stagger reveal — apparition en cascade (Taste MOTION_INTENSITY:6) */
  opacity: 0;
  animation: exampleIn 400ms var(--ease) forwards;
  touch-action: manipulation;
  will-change: transform;
}
/* Stagger par position (Taste Section 4 : staggered orchestration) */
.example-btn:nth-child(1) { animation-delay: 80ms; }
.example-btn:nth-child(2) { animation-delay: 160ms; }
.example-btn:nth-child(3) { animation-delay: 240ms; }
.example-btn:nth-child(4) { animation-delay: 320ms; }

@keyframes exampleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hover : uniquement si l'appareil supporte le hover (Impeccable responsive.md) */
@media (hover: hover) {
  .example-btn:hover {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
    border-color: var(--clr-primary);
    transform: translateY(-1px);
    transition: background var(--t), color var(--t), border-color var(--t),
                transform var(--t-fast);
  }
}
/* Active : retour physique (Impeccable delight.md + Taste Rule 5) */
.example-btn:active {
  transform: translateY(1px);
  transition-duration: 80ms;
  opacity: .9;
}

/* ================================================================
   MESSAGES — style éditorial, pas "iMessage"
   ================================================================ */
#messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 740px;
  width: 100%;
}

.message {
  display: flex; align-items: flex-start; gap: 0;
  animation: msgIn 180ms cubic-bezier(0.25, 0, 0, 1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message__avatar { display: none; }

.message__body { display: flex; flex-direction: column; gap: 5px; width: 100%; }

.message__time {
  display: block;
  font-size: 0.6875rem; color: var(--clr-text-faint);
  font-family: var(--font-mono);
  padding: 0 4px; letter-spacing: .3px;
}

.message__bubble {
  padding: 12px 16px;
  border-radius: var(--r);
  word-break: break-word; line-height: 1.75;
  transition: box-shadow 160ms ease;
}

/* ── Message UTILISATEUR ──
   Côté droit, tint ambre chaud.
   Pas de bleu, pas de violet, pas de teal "couleur IA".            */
.message--user { justify-content: flex-end; padding: 2px 0; }

.message--user .message__body {
  align-items: flex-end; max-width: 70%;
}
.message--user .message__time { text-align: right; }
.message--user .message__bubble {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  border: 1px solid rgba(194,65,12,.14);
  border-radius: var(--r);
  /* Coin inférieur droit aplati — discret, pas l'asymétrie extrême  */
  border-bottom-right-radius: 2px;
}
.message--user .message__text p  { margin: 0; }
.message--user .message__text br { display: block; margin: 2px 0; }

/* ── Message ASSISTANT ──
   Pleine largeur, fond légèrement chaud, bordure complète.
   ✗ Pas de barre latérale colorée — c'est la signature du code IA. */
.message--assistant { padding: 2px 0; }
.message--assistant .message__body { max-width: 100%; }
.message--assistant .message__bubble {
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
  border-radius: var(--r);
  border-bottom-left-radius: 2px;
  box-shadow: var(--shadow-sm);
}
.message--assistant .message__bubble:hover { box-shadow: var(--shadow); }
.message--assistant {
  transition: transform var(--t-fast);
  will-change: transform;
}
/* Le :hover du message est géré dans @media (hover: hover) plus bas */

/* ── Markdown ── */
.message__text p            { margin: 0 0 8px; }
.message__text p:last-child { margin-bottom: 0; }
.message__text strong       { font-weight: 600; }
.message__text em           { font-style: italic; }

.message__text .md-h1,
.message__text .md-h2,
.message__text .md-h3 {
  font-weight: 700; color: var(--clr-text); margin: 16px 0 6px;
}
.message__text .md-h1:first-child,
.message__text .md-h2:first-child,
.message__text .md-h3:first-child { margin-top: 0; }

.message__text .md-h1 { font-size: clamp(1rem, 0.875rem + 0.63vw, 1.125rem); letter-spacing: -0.02em; }
.message__text .md-h2 { font-size: clamp(0.9375rem, 0.875rem + 0.33vw, 1rem); border-bottom: 1px solid var(--clr-border); padding-bottom: 5px; }
.message__text .md-h3 { font-size: 0.875rem; color: var(--clr-primary); }

.message__text .md-ul,
.message__text .md-ol { padding-left: 20px; margin: 6px 0 10px; }
.message__text .md-ul li,
.message__text .md-ol li { margin-bottom: 5px; line-height: 1.7; }

.message__text .md-hr { border: none; border-top: 1px solid var(--clr-border); margin: 14px 0; }

/* ── Code inline ── */
.message__text .inline-code {
  background: var(--clr-bg); border: 1px solid var(--clr-border);
  padding: 1px 6px; border-radius: var(--r-sm);
  font-size: 0.8125rem; font-family: var(--font-mono); color: var(--clr-text);
}

/* ── Bloc de code — noir café cohérent avec la sidebar ── */
.message__text .code-block {
  background: #0E0C08;    /* noir café, chaud */
  color: #E4DDD5;          /* blanc légèrement teinté ivoire */
  border-radius: var(--r);
  padding: 14px 16px; margin: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 0.8125rem; line-height: 1.7;
  font-family: var(--font-mono); position: relative;
}
.message__text .code-block::before {
  content: attr(data-lang);
  position: absolute; top: 8px; left: 12px;
  font-size: 0.6875rem; font-family: var(--font-mono);
  color: #6B5C45; text-transform: lowercase; letter-spacing: .5px;
}
.message__text .code-block code {
  display: block; margin-top: 12px;
  background: none; border: none; padding: 0;
  color: inherit; font-size: inherit;
}

/* ── Bouton copier ── */
.code-copy-btn {
  position: absolute; top: 6px; right: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.10);
  color: #6B5C45; border-radius: var(--r-sm);
  padding: 3px 8px; font-size: 0.6875rem;
  cursor: pointer; line-height: 1.4; font-family: var(--font);
  transition: background var(--t), color var(--t);
  touch-action: manipulation;
}
.code-copy-btn:hover       { background: rgba(255,255,255,.15); color: #E4DDD5; }
.code-copy-btn--done       { background: rgba(194,65,12,.22); color: #FDBA74; border-color: rgba(194,65,12,.35); }

/* ── Table Markdown ── */
.md-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 12px 0; border-radius: var(--r); border: 1px solid var(--clr-border);
}
.md-table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.md-table th,
.md-table td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--clr-border); }
.md-table th {
  background: var(--clr-bg); font-weight: 700; color: var(--clr-text);
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .6px;
}
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:hover td      { background: var(--clr-bg); }

/* ── Curseur de streaming ── */
.cursor-blink {
  display: inline-block; width: 2px; height: 1em;
  background: var(--clr-primary); margin-left: 2px;
  vertical-align: text-bottom; border-radius: 1px;
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ================================================================
   SOURCES — panneau de références, style liste éditoriale
   ================================================================ */
.sources {
  display: flex; flex-direction: column; gap: 0;
  margin-top: 12px; border-top: 1px solid var(--clr-border); padding-top: 10px;
}

.sources__label {
  font-size: 0.6875rem; font-weight: 700;
  color: var(--clr-text-faint); letter-spacing: .9px;
  text-transform: uppercase; margin-bottom: 6px;
}

.sources__list { display: flex; flex-direction: column; gap: 0; }

.source-card {
  background: transparent; border: none;
  border-top: 1px solid var(--clr-border);
  border-radius: 0; overflow: hidden;
  transition: background 130ms ease;
}
.source-card:first-child { border-top: none; }
.source-card:hover       { background: var(--clr-bg); }

.source-card__header {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
}
.source-card__index {
  min-width: 20px; border-radius: var(--r-sm);
  background: transparent !important;
  color: var(--clr-text-faint); font-size: 0.6875rem; font-weight: 500;
  font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 1px 4px; border: 1px solid var(--clr-border);
}

.source-card__meta { flex: 1; min-width: 0; }
.source-card__name {
  display: block; font-size: 0.8125rem; font-weight: 600;
  color: var(--clr-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  text-transform: capitalize; margin-bottom: 2px;
}
.source-card__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.source-card__badge {
  font-size: 0.6875rem; padding: 1px 6px; border-radius: var(--r-sm);
  background: transparent; color: var(--clr-text-faint);
  font-weight: 600; border: 1px solid var(--clr-border);
}
.source-card__page { font-size: 0.6875rem; color: var(--clr-text-faint); font-family: var(--font-mono); }

.source-card__score-wrap {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0;
}
.source-card__score-track {
  width: 36px; height: 2px; background: var(--clr-border); border-radius: 1px; overflow: hidden;
}
.source-card__score-fill  { height: 100%; border-radius: 1px; transition: width .3s ease; }
.source-card__score-label {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--clr-text-faint); font-family: var(--font-mono);
}

.source-card__toggle {
  width: 100%; text-align: left; padding: 0 6px 6px 36px;
  background: none; border: none;
  font-size: 0.6875rem; color: var(--clr-text-faint);
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: color 130ms ease; touch-action: manipulation;
}
.source-card__toggle:hover { color: var(--clr-primary); }
.source-card__toggle-icon  { font-size: 0.6875rem; transition: transform 130ms ease; }

.source-card__excerpt { padding: 0 6px 8px 36px; }
.source-card__excerpt blockquote {
  font-size: 0.8125rem; color: var(--clr-text-muted);
  line-height: 1.7; border-left: 2px solid var(--clr-border);
  padding-left: 10px; margin: 0; font-style: italic;
}

/* ================================================================
   TYPING INDICATOR
   ================================================================ */
.typing-indicator {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 4px 0; max-width: 740px; width: 100%;
}
.typing-bubble {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r); border-bottom-left-radius: 2px;
  padding: 12px 16px; display: flex; gap: 5px; align-items: center;
  box-shadow: var(--shadow-sm);
}
.typing-bubble span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--clr-text-faint); animation: typingDot 1.3s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot {
  0%, 80%, 100% { transform: scale(1); opacity: .35; }
  40%           { transform: scale(1.25); opacity: 1; }
}

/* ================================================================
   INPUT AREA
   ================================================================ */
.input-area {
  padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 4vw, 2rem);
  background: var(--clr-surface);
  /* Séparation structurelle forte — pas un shadow flottant générique */
  border-top: 2px solid var(--clr-border);
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
  /* iOS : dégager le home indicator (iPhone sans bouton home) */
  padding-bottom: max(clamp(0.75rem, 2vw, 1rem), env(safe-area-inset-bottom));
}

.category-badge-active {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 12px; border-radius: var(--r-sm);
  background: var(--clr-primary-light);
  border: 1px solid rgba(194,65,12,.3);
  color: var(--clr-primary); font-size: 0.75rem; font-weight: 600;
  align-self: flex-start;
}
.category-badge-active button {
  background: none; border: none; color: var(--clr-primary);
  font-size: 0.875rem; line-height: 1; padding: 0; opacity: .6;
  transition: opacity var(--t); touch-action: manipulation;
}
.category-badge-active button:hover { opacity: 1; }

.input-form {
  display: flex; gap: 10px; align-items: flex-end;
  /* Fond légèrement plus sombre que la surface — profondeur subtile */
  background: var(--clr-bg);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--r);
  padding: 8px 8px 8px 14px;
  transition: border-color var(--t), box-shadow var(--t);
  max-width: 740px; width: 100%; margin-inline: auto;
}
.input-form:focus-within {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(194,65,12,.09);
}

.input-field {
  flex: 1; border: none; background: transparent; resize: none;
  /* min 16px OBLIGATOIRE : iOS zoome automatiquement si font < 16px  */
  font-size: max(1rem, 16px);
  font-family: inherit; color: var(--clr-text); outline: none;
  line-height: 1.5; max-height: 160px; min-height: 24px; padding: 2px 0;
}
.input-field::placeholder { color: var(--clr-text-faint); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: var(--r);
  background: var(--clr-primary); border: none; color: #FFF;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--t), opacity var(--t), transform 100ms ease;
  touch-action: manipulation;
}
.send-btn svg { width: 15px; height: 15px; }
@media (hover: hover) {
  .send-btn:hover:not(:disabled) { background: var(--clr-primary-hover); }
}
/* Active : push physique + ombre compressée (Impeccable delight.md) */
.send-btn:active:not(:disabled) {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 1px 3px rgba(28,17,9,.18);
  transition-duration: 80ms;
}
.send-btn:disabled { background: var(--clr-border); color: var(--clr-text-faint); cursor: not-allowed; }

.input-footer {
  display: flex; justify-content: space-between; padding: 0 2px;
  max-width: 740px; width: 100%; margin-inline: auto;
}
/* tabular-nums : chiffres largeur fixe (Impeccable typeset.md) */
.char-counter {
  font-size: 0.6875rem; color: var(--clr-text-faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.disclaimer { font-size: 0.6875rem; color: var(--clr-text-faint); }

/* ================================================================
   NOTICE
   ================================================================ */
.app-notice {
  padding: 10px 16px; border-radius: var(--r);
  background: #fffbeb; border: 1px solid #fde68a;
  color: #92400e; font-size: 0.875rem; margin-bottom: 14px;
}
.app-notice code {
  background: rgba(0,0,0,.07); padding: 1px 5px;
  border-radius: var(--r-sm); font-size: 0.75rem; font-family: var(--font-mono);
}

/* ================================================================
   OVERLAY MOBILE
   ================================================================ */
.sidebar-overlay {
  display: block; position: fixed; inset: 0;
  /* Teinte chaude cohérente avec la palette */
  background: rgba(18,16,10,.55);
  z-index: 90; opacity: 0; pointer-events: none;
  transition: opacity var(--t-slow);
}
.sidebar-overlay--visible { opacity: 1; pointer-events: auto; }

/* ================================================================
   MODAL UPLOAD
   ================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(18,16,10,.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  /* iOS : respacter la safe area dans les modals */
  padding-top:    max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: backdropIn 180ms ease both;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--clr-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  position: relative;
  animation: modalIn 200ms cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--clr-border);
}
.modal__title { font-size: 1rem; font-weight: 700; color: var(--clr-text); letter-spacing: -0.3px; }

.modal__close {
  width: 32px; height: 32px; border-radius: var(--r);
  border: 1px solid var(--clr-border); background: transparent;
  color: var(--clr-text-muted); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t); touch-action: manipulation;
}
.modal__close:hover { background: var(--clr-bg); color: var(--clr-text); }

.modal__panel      { padding: 20px 24px; border-bottom: 1px solid var(--clr-border); }
.modal__step-label {
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: .9px; text-transform: uppercase;
  color: var(--clr-text-muted); margin-bottom: 14px;
}
.modal__footer      { padding: 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.modal__footer-row  { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.modal__footer-actions { display: flex; justify-content: flex-end; gap: 10px; }

.btn--reindex {
  background: transparent; border: 1px solid var(--clr-border);
  color: var(--clr-text-muted); font-size: 0.8125rem;
  padding: 7px 14px; border-radius: var(--r);
  transition: background var(--t), color var(--t), border-color var(--t);
  touch-action: manipulation;
}
.btn--reindex:hover:not(:disabled) { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.btn--reindex:disabled             { opacity: .5; cursor: not-allowed; }

/* ── Boutons génériques ── */
.btn {
  padding: 8px 18px; border-radius: var(--r); border: none;
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t), opacity var(--t),
              transform var(--t-fast), box-shadow var(--t-fast);
  touch-action: manipulation;
  will-change: transform;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--clr-primary); color: #FFF; }
@media (hover: hover) {
  .btn--primary:hover:not(:disabled) { background: var(--clr-primary-hover); transform: translateY(-1px); }
  .btn--ghost:hover:not(:disabled)   { background: var(--clr-bg); color: var(--clr-text); transform: translateY(-1px); }
}
/* Active : retour physique — toujours, hover ou pas (Taste Rule 5) */
.btn--primary:active:not(:disabled),
.btn--ghost:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(28,17,9,.10);
  transition-duration: 80ms;
}
.btn--ghost { background: transparent; color: var(--clr-text-muted); border: 1px solid var(--clr-border); }
.btn--sm    { padding: 6px 12px; font-size: 0.8125rem; }

/* ── Radios catégorie (dans la modale) ── */
.cat-radio-group {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 200px; overflow-y: auto; padding-right: 4px;
}
.cat-radio {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r);
  border: 1.5px solid var(--clr-border);
  cursor: pointer; transition: border-color var(--t), background var(--t);
  user-select: none; touch-action: manipulation;
}
.cat-radio:hover { background: var(--clr-bg); }
.cat-radio input[type="radio"] { display: none; }
.cat-radio input:checked ~ * { color: var(--clr-primary); }
.cat-radio:has(input:checked) { border-color: var(--clr-primary); background: var(--clr-primary-light); }

.cat-radio__dot {
  width: 8px; height: 8px;
  /* Carré — cohérent avec les category-dot de la sidebar */
  border-radius: 1px;
  flex-shrink: 0;
}
.cat-radio__emoji { font-size: 0.9375rem; }
.cat-radio__label { flex: 1; font-size: 0.875rem; font-weight: 500; color: var(--clr-text); }
.cat-radio__count { font-size: 0.75rem; color: var(--clr-text-muted); font-family: var(--font-mono); }

.btn-new-cat {
  margin-top: 10px; background: none; border: none;
  color: var(--clr-primary); font-size: 0.8125rem; font-weight: 600;
  padding: 4px 0; cursor: pointer; text-align: left;
  transition: color var(--t); touch-action: manipulation;
}
.btn-new-cat:hover { color: var(--clr-primary-hover); }

/* ── Formulaire nouvelle catégorie ── */
.new-cat-form { display: flex; flex-direction: column; gap: 14px; }
.new-cat-form__row { display: flex; gap: 10px; align-items: flex-end; }
.new-cat-form__actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.75rem; font-weight: 700; color: var(--clr-text-muted); letter-spacing: .3px; }
.form-input {
  border: 1.5px solid var(--clr-border); border-radius: var(--r);
  padding: 8px 10px; font-size: 0.875rem; font-family: inherit;
  color: var(--clr-text); background: var(--clr-bg); outline: none;
  transition: border-color var(--t), box-shadow var(--t); width: 100%;
}
.form-input:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(194,65,12,.09); }
.form-input--emoji { width: 54px; text-align: center; font-size: 1.125rem; padding: 6px; }
.form-input--color { width: 48px; height: 38px; padding: 2px 4px; cursor: pointer; }
.form-hint { font-size: 0.6875rem; color: var(--clr-text-faint); }

/* ── Emoji picker ── */
.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 10px;
  background: var(--clr-bg); border: 1.5px solid var(--clr-border);
  border-radius: var(--r); max-height: 148px; overflow-y: auto;
}
.emoji-picker::-webkit-scrollbar       { width: 4px; }
.emoji-picker::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 2px; }

.emoji-btn {
  width: 34px; height: 34px; font-size: 1.125rem;
  border: 1.5px solid transparent; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), border-color var(--t), transform var(--t);
  line-height: 1; touch-action: manipulation;
}
.emoji-btn:hover    { background: var(--clr-surface); transform: scale(1.08); }
.emoji-btn--active  { background: var(--clr-primary-light); border-color: var(--clr-primary); transform: scale(1.05); }

/* ── Drop zone ── */
.drop-zone {
  border: 1.5px dashed var(--clr-border); border-radius: var(--r-lg);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color var(--t), background var(--t);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--clr-bg); touch-action: manipulation;
}
.drop-zone:hover,
.drop-zone:focus-within,
.drop-zone--over { border-color: var(--clr-primary); background: var(--clr-primary-light); }
.drop-zone__icon  { font-size: 2rem; opacity: .45; }
.drop-zone__title { font-size: 0.875rem; font-weight: 700; color: var(--clr-text); }
.drop-zone__hint  { font-size: 0.8125rem; color: var(--clr-text-muted); }

/* ── Liste de fichiers ── */
.file-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--clr-bg);
  border: 1px solid var(--clr-border); border-radius: var(--r);
  font-size: 0.8125rem;
}
.file-item__icon { font-size: 1rem; }
.file-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--clr-text); }
.file-item__size { font-size: 0.6875rem; color: var(--clr-text-muted); flex-shrink: 0; font-family: var(--font-mono); }
.file-item__remove {
  background: none; border: none; color: var(--clr-text-faint);
  font-size: 1rem; line-height: 1; padding: 0 2px; flex-shrink: 0;
  transition: color var(--t); touch-action: manipulation;
}
.file-item__remove:hover { color: var(--clr-error); }

/* ── Feedback upload ── */
.upload-feedback { padding: 10px 14px; border-radius: var(--r); font-size: 0.8125rem; font-weight: 500; }
.upload-feedback--ok    { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.upload-feedback--warn  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.upload-feedback--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Overlay progression ── */
.upload-overlay {
  position: absolute; inset: 0;
  background: rgba(253,251,247,.95); border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.upload-overlay__inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 32px; text-align: center;
}
.upload-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--clr-border); border-top-color: var(--clr-primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-overlay__text     { font-size: 0.875rem; font-weight: 600; color: var(--clr-text); }
.upload-progress-bar      { width: 200px; height: 3px; background: var(--clr-border); border-radius: 2px; overflow: hidden; }
.upload-progress-bar__fill { height: 100%; background: var(--clr-primary); border-radius: 2px; transition: width .2s ease; }
.upload-overlay__pct      { font-size: 0.75rem; color: var(--clr-text-muted); font-weight: 600; font-family: var(--font-mono); }

/* ================================================================
   SKELETON SHIMMER — Impeccable animate.md + Taste Rule 5
   "Skeletal loaders matching layout sizes — avoid generic spinners"
   ================================================================ */
@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position:  200% center; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--clr-border) 25%,
    var(--clr-bg)     50%,
    var(--clr-border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s var(--ease) infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}

/* Skeleton adaptatif par composant */
.skeleton--line   { height: 0.875rem; width: 100%; }
.skeleton--line-sm { height: 0.75rem; width: 60%; }
.skeleton--avatar { width: 28px; height: 28px; border-radius: var(--r); }
.skeleton--doc    { height: 1.5rem; width: 100%; margin-bottom: 4px; }

/* source-card__score-label — tabular-nums pour alignement chiffres */
.source-card__score-label {
  font-variant-numeric: tabular-nums;
}

/* new-chat-btn et upload-trigger : active feedback */
.new-chat-btn:active {
  transform: scale(0.93);
  transition-duration: 80ms;
}

@media (hover: hover) {
  .new-chat-btn:hover {
    background: var(--clr-primary-light);
    border-color: var(--clr-primary);
    color: var(--clr-primary);
    transform: translateY(-1px);
  }
  .upload-trigger-btn:hover {
    background: rgba(194,65,12,.20);
    border-color: rgba(194,65,12,.55);
    color: #FED7AA;
    transform: translateY(-1px);
  }
  /* Message assistant : lift uniquement sur device hover */
  .message--assistant:hover { transform: translateY(-1px); }
}

/* ================================================================
   RESPONSIVE — Mobile-first
   Breakpoints :
     Mobile    : 375px–767px    → styles de base (aucun media query)
     Tablette  : ≥ 768px        → @media (min-width: 768px)
     Desktop   : ≥ 1024px       → @media (min-width: 1024px)
     Large     : ≥ 1280px       → @media (min-width: 1280px)

   iOS  : safe-area-inset-*, min font 16px, 100dvh, momentum scroll
   Android : touch-action: manipulation, min cibles 48px
   ================================================================ */

/* ── Très petit mobile (<480px) ── */
@media (max-width: 479px) {
  .status-badge    { display: none; }
  .lang-switcher   { display: none; }
  .header-subtitle { display: none; }

  .welcome         { padding-top: clamp(1.25rem, 6vw, 2rem); }
  .welcome h2      { font-size: clamp(1.5rem, 1rem + 3vw, 2rem); }

  .example-questions { flex-direction: column; align-items: stretch; }
  .example-btn       { text-align: left; }

  .new-cat-form__row { flex-direction: column; }
  .modal__header,
  .modal__panel,
  .modal__footer     { padding-left: 1rem; padding-right: 1rem; }
  .header-actions    { gap: 6px; }
  .header            { padding: env(safe-area-inset-top) 14px 0; }

  /* Messages user : presque toute la largeur sur très petit écran */
  .message--user .message__body { max-width: 88%; }
}

/* ── Tablette (≥ 768px) : sidebar fixe dans le flux ── */
@media (min-width: 768px) {
  .sidebar {
    position: relative;
    transform: none !important;
    box-shadow: none !important;
    width: var(--sidebar-w);
    /* Séparation droite subtile avec le main */
    border-right: 1px solid rgba(255,255,255,.06);
    /* Plus besoin de safe-area top en mode large écran */
    padding-top: 0;
  }
  .sidebar-overlay { display: none !important; }
  .menu-btn        { display: none; }
  .header-subtitle { display: block; }
  /* Header : hauteur fixe sans safe-area (pas de notch sur tablette) */
  .header          { height: var(--header-h); padding-top: 0; }

  .message--user .message__body { max-width: 72%; }
}

/* ── Desktop (≥ 1024px) ── */
@media (min-width: 1024px) {
  .message--user .message__body { max-width: 65%; }
}

/* ── Large (≥ 1280px) ── */
@media (min-width: 1280px) {
  /* Les clamp() gèrent automatiquement le scaling */
}

/* ================================================================
   CIBLES TACTILES — iOS & Android
   pointer: coarse = écran tactile (le navigateur le détecte)
   Minimum : 44px Apple HIG / 48dp Android Material Design
   ================================================================ */
@media (pointer: coarse) {
  .lang-btn            { padding: 8px 14px;  min-height: 44px; }
  .example-btn         { min-height: 48px;   padding: 12px 16px; }
  .category-item       { min-height: 44px;   padding: 10px 12px; }
  .upload-trigger-btn  { min-height: 48px; }
  .btn                 { min-height: 48px;   padding-block: 12px; }
  .modal__close        { width: 44px; height: 44px; }
  .doc-item            { min-height: 44px;   padding: 8px; }
  .source-card__toggle { min-height: 44px; }
  /* Actions de doc agrandies pour les doigts */
  .doc-item__btn       { width: 36px; height: 36px; }
  .emoji-btn           { width: 40px; height: 40px; }
  .cat-radio           { min-height: 52px; }
  .btn-new-cat         { min-height: 44px; display: flex; align-items: center; }
}

/* ================================================================
   HOVER — désactivé sur écrans tactiles (iOS & Android)
   hover: none = le pointeur principal ne peut pas planer
   Évite les états stuck-hover qui bloquent sur mobile
   ================================================================ */
@media (hover: none) {
  .message--assistant:hover { transform: none; }
  .example-btn:hover {
    background: var(--clr-surface);
    color: var(--clr-text-muted);
    border-color: var(--clr-border);
  }
  .source-card:hover { background: transparent; }
  /* Actions de doc : toujours visibles — pas de hover-reveal inaccessible */
  .doc-item .doc-item__actions { opacity: 1; }
}

/* ================================================================
   MODALE CONFIRMATION (oui / non)
   ================================================================ */
.modal--confirm { max-width: 400px; }

.confirm-modal-body {
  padding: 20px 24px 4px;
}
.confirm-modal-body p {
  font-size: 0.9375rem; color: var(--clr-text); margin: 0; line-height: 1.55;
}

.modal__footer--confirm {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Bouton action destructive (suppression) */
.btn--danger { background: var(--clr-error); color: #fff; border: none; }
@media (hover: hover) {
  .btn--danger:hover:not(:disabled) { background: #991b1b; transform: translateY(-1px); }
}
.btn--danger:active:not(:disabled) { transform: translateY(1px); transition-duration: 80ms; }

/* ================================================================
   MODALE PROGRESSION INDEXATION
   ================================================================ */
.modal--reindex { max-width: 440px; }

.reindex-modal-body {
  padding: 28px 24px 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; text-align: center;
}

/* Spinner agrandi pour le modal reindex */
.reindex-spinner {
  width: 40px; height: 40px; border-width: 3px;
}

/* Wrap autour du spinner : devient icône après fin */
.reindex-spinner-wrap { display: flex; align-items: center; justify-content: center; }
.reindex-spinner-wrap--done .reindex-spinner,
.reindex-spinner-wrap--error .reindex-spinner { display: none; }
.reindex-spinner-wrap--done::after  { content: '✅'; font-size: 2.2rem; }
.reindex-spinner-wrap--error::after { content: '❌'; font-size: 2.2rem; }

.reindex-status-line {
  font-size: 0.9375rem; font-weight: 600; color: var(--clr-text); margin: 0;
}

/* Liste des étapes */
.reindex-steps {
  width: 100%; text-align: left;
  display: flex; flex-direction: column; gap: 5px;
  max-height: 180px; overflow-y: auto;
}
.reindex-steps::-webkit-scrollbar       { width: 4px; }
.reindex-steps::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 2px; }

.reindex-step {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--r);
  font-size: 0.8125rem; color: var(--clr-text-muted);
  background: var(--clr-bg);
  transition: background var(--t), color var(--t);
}
.reindex-step--active { color: var(--clr-text); background: var(--clr-primary-muted); font-weight: 600; }
.reindex-step--done   { color: var(--clr-success); }
.reindex-step__icon   { font-size: 0.9rem; flex-shrink: 0; }

/* Résumé final */
.reindex-stats {
  width: 100%; padding: 10px 14px; border-radius: var(--r);
  font-size: 0.875rem; font-weight: 500;
}
.reindex-stats--ok    { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.reindex-stats--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Footer du modal reindex */
.modal__footer--reindex {
  padding: 14px 24px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.reindex-warn-msg {
  font-size: 0.8125rem; color: var(--clr-warn); font-weight: 500; margin: 0;
}

/* ── Flash nouveaux documents après upload ── */
@keyframes docFlash {
  0%   { background: rgba(194,65,12,.14); }
  100% { background: transparent; }
}
.doc-item--new { animation: docFlash 1.8s var(--ease) forwards; }

/* ================================================================
   RÉDUCTION DES ANIMATIONS — WCAG 2.1 (prefers-reduced-motion)
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:        0.01ms !important;
    animation-iteration-count: 1      !important;
    transition-duration:       0.01ms !important;
    scroll-behavior:           auto   !important;
  }
}
