/* ============================================================================
   QLOA — DESIGN SYSTEM MOBILE (qloa-mobile.css)
   Créé le 2026-06-16 · Sprint S1 Lane Mobile

   RÈGLES ABSOLUES DE CE FICHIER :
   ─ 100 % des règles sont sous @media (max-width: 768px) — zéro pollution desktop
   ─ Les tokens V3 sont CONSOMMÉS (var(--radius-card), etc.), JAMAIS redéfinis
   ─ Toutes les classes sont préfixées .qm-* (qloa-mobile) — pas de collision
   ─ Ne pas charger dans base.html avant le sprint de port

   COMPOSANTS CANON :
     .qm-header      — barre supérieure sticky (56 px, MAX 2 actions droite)
     .qm-tabbar      — navigation bottom 4-5 onglets
     .qm-chips       — filtres horizontaux scroll-x (sans wrap)
     .qm-card        — carte générique (radius token, glass 0.25)
     .qm-panel       — panneau latéral full-width slide-from-right
     .qm-fab         — action primaire flottante
     .qm-sheet       — bottom-sheet (remonte du bas)
     .qm-item        — ligne de liste swipeable
     .qm-search      — barre de recherche collapse
     .qm-empty       — état vide
     .qm-skeleton    — squelette de chargement

   TOKENS RÉCONCILIÉS (maquette → réel) :
     radius cards    : 20 px → var(--radius-card) = 10 px
     transparence    : 0.05 → var(--panel-bg) = rgba(255,255,255,0.25/0.55 dark)
     boutons         : pills 999 px → var(--btn-radius) = 10 px
     tabbar height   : 78 px (safe area aware)
     header height   : 56 px
     touch target    : 44 px minimum (WCAG)
   ============================================================================ */

/* ─── Gateway rules (hors @media) : cache les blocs mobile sur desktop ───────
   Exception justifiée : sans ces 2 règles, les éléments .qm-* s'affichent
   non-stylisés en desktop (aucun display défini hors media query).
   ─────────────────────────────────────────────────────────────────────────── */
.qm-header        { display: none; }
.qm-back-bar      { display: none; }
.qm-tabbar        { display: none; }

/* Bouton TTS (lecture notes) — global desktop + mobile */
.qtts-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border: none; border-radius: 7px;
  background: rgba(0,0,0,0.06); color: #555; cursor: pointer; font-size: 11px; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.qtts-btn:hover { background: rgba(0,0,0,0.1); }
.dark .qtts-btn { background: rgba(255,255,255,0.1); color: #bbb; }
.qtts-btn.qtts-on { background: #7c3aed; color: #fff; }
.qtts-btn.qtts-on i { animation: qtts-pulse 1s ease-in-out infinite; }
@keyframes qtts-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.qm-tabbar-spacer { display: none; }
.qm-mobile-only   { display: none; }
.qm-fab           { display: none; }
.qm-search        { display: none; }
/* Recherche intra-fiche (qm_back_bar) : mobile-only — sinon s'affiche sur desktop (oubli du défaut) */
@media (min-width: 769px) { .qm-fiche-search { display: none !important; } }

/* Action-bar détail (même design tabbar, actions contextuelles) : remplace la tabbar globale.
   Quand une .qm-tabbar--detail est présente, on masque la tabbar standard. */
@media (max-width: 768px) {
  body:has(.qm-tabbar--detail) .qm-tabbar:not(.qm-tabbar--detail) { display: none !important; }
  body:has(.qm-tabbar--detail) .qm-tabbar:not(.qm-tabbar--detail) + .qm-tabbar-spacer { display: none !important; }
  .qm-tab--primary { color: #dc2626 !important; opacity: 1 !important; }
  .qm-tab--primary i { color: #dc2626 !important; }
}

/* CATCH-ALL desktop : tous les overlays du moteur mobile sont masqués hors mobile.
   (Les .qm-sheet n'ont pas de display hors @media → s'affichaient en block sur desktop,
    le menu "Plus" .qm-sheet--full du qm_tabbar recouvrait le header. Fix global.) */
@media (min-width: 769px) {
  .qm-sheet, .qm-sheet-backdrop, .qm-voice-overlay, .qm-voice-backdrop,
  .qm-radial, .qm-radial-backdrop, .qm-notif, .qm-detail-search { display: none !important; }
}

@media (max-width: 768px) {

  /* ==========================================================================
     VARIABLES LOCALES (valeurs safe-area uniquement — PAS de tokens V3 redéfinis)
     ========================================================================== */

  :root {
    --qm-safe-top:    env(safe-area-inset-top, 0px);
    --qm-safe-bottom: env(safe-area-inset-bottom, 0px);
    --qm-header-h:    56px;
    --qm-tabbar-h:    78px;
    /* Couleurs locales mobile (ne surchargent pas les tokens globaux --accent, etc.) */
    --qm-bg:          #F5F5F7;
    --qm-bg-elev:     #FFFFFF;
    --qm-border:      rgba(0, 0, 0, 0.08);
    --qm-text:        #000000;
    --qm-text-2:      #6B7280;
    --qm-text-3:      #9CA3AF;
  }

  .dark {
    --qm-bg:          #1C1C1E;
    --qm-bg-elev:     #2C2C2E;
    --qm-border:      rgba(255, 255, 255, 0.08);
    --qm-text:        #FFFFFF;
    --qm-text-2:      #A3A3A3;
    --qm-text-3:      #737373;
  }


  /* ==========================================================================
     QM-HEADER — barre supérieure sticky 56 px
     Contrainte : MAX 2 actions à droite. Si besoin de plus → view-switcher ou menu "…"
     HTML :
       <header class="qm-header">
         <button class="qm-icon-btn" type="button">←</button>
         <div class="qm-header-title">
           <h1>Tickets</h1>
           <span class="qm-sub">18 ouverts · LDB</span>
         </div>
         <button class="qm-icon-btn" type="button">🔍</button>  ← action 1
         <button class="qm-icon-btn" type="button">⋮</button>   ← action 2 (MAX)
       </header>
     ========================================================================== */

  /* Back-bar mobile pages détail (sticky top, retour + titre) */
  .qm-back-bar {
    display: flex !important; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: var(--z-sticky, 30);
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding: calc(env(safe-area-inset-top, 0px) + 6px) 14px 6px;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 0.5px solid var(--qm-border, rgba(0,0,0,0.1));
    /* bleed = -12px pour contrer le padding horizontal 12px des pages détail → barre pleine largeur, contenu inset */
    margin: 0 -12px 8px;
  }
  .dark .qm-back-bar { background: rgba(20,20,22,0.96); border-bottom-color: rgba(255,255,255,0.1); }
  .qm-back-bar-btn {
    width: 36px; height: 36px; flex-shrink: 0; border: none; border-radius: 999px;
    background: rgba(0,0,0,0.05); color: #000; cursor: pointer; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .dark .qm-back-bar-btn { background: rgba(255,255,255,0.1); color: #fff; }
  .qm-back-bar-title { flex: 1; font-size: 17px; font-weight: 700; color: var(--qm-text, #000); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qm-back-bar-search { margin-left: auto; flex-shrink: 0; }

  /* Barre de recherche intra-fiche (glisse sous le back-bar, comme l'inbox) */
  .qm-fiche-search {
    position: sticky; top: calc(48px + env(safe-area-inset-top, 0px)); z-index: calc(var(--z-sticky, 30) - 1);
    background: var(--qm-bg-elev, #fff); border-bottom: 0.5px solid var(--qm-border, rgba(0,0,0,0.08));
    padding: 8px 12px; margin: -8px -12px 8px;
    max-height: 0; overflow: hidden; opacity: 0; padding-top: 0; padding-bottom: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
  }
  .dark .qm-fiche-search { background: #1c1c1e; }
  body.qm-fiche-searching .qm-fiche-search { max-height: 60px; opacity: 1; padding-top: 8px; padding-bottom: 8px; }
  .qm-fiche-search .qm-search-wrap { display: flex; align-items: center; gap: 8px; }
  .qm-fiche-search input { flex: 1; border: none; background: transparent; outline: none; font-size: 15px; color: var(--qm-text, #000); padding: 4px 0; }
  .qm-fiche-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
  .qm-fiche-search-close { width: 28px; height: 28px; border: none; border-radius: 999px; background: rgba(0,0,0,0.06); color: #666; cursor: pointer; flex-shrink: 0; }
  .dark .qm-fiche-search-close { background: rgba(255,255,255,0.1); color: #aaa; }
  /* Résultats : estompe les cartes/lignes sans correspondance, met en avant les hits */
  .qm-fiche-dim { opacity: 0.3; transition: opacity 0.2s; }
  .qm-fiche-hit { box-shadow: 0 0 0 2px rgba(37,99,235,0.4); border-radius: 12px; }

  /* Sous-onglets fiches : grilles stats desktop (3/4/5/6 col) → 2 col mobile (générique) */
  .cd-detail-page [style*="repeat(3"], .cd-detail-page [style*="repeat(4"], .cd-detail-page [style*="repeat(5"], .cd-detail-page [style*="repeat(6"],
  .tkt-detail-page [style*="repeat(3"], .tkt-detail-page [style*="repeat(4"], .tkt-detail-page [style*="repeat(5"], .tkt-detail-page [style*="repeat(6"],
  .fent-detail-page [style*="repeat(3"], .fent-detail-page [style*="repeat(4"], .fent-detail-page [style*="repeat(5"], .fent-detail-page [style*="repeat(6"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Filtres en rangée (boutons) des sous-onglets → scrollables, pas de wrap cassé */
  .cd-detail-page .tl-view > div:first-child[style*="flex"],
  .fent-detail-page [data-view] > div:first-child[style*="flex"] {
    flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }

  /* Tables → cards mobile (sous-onglets fiches) : chaque <tr> = carte "Libellé : valeur" */
  .qm-table-cards { display: block; width: 100%; }
  .qm-table-cards thead { display: none; }
  .qm-table-cards tbody { display: block; width: 100%; }
  .qm-table-cards tr { display: block; background: var(--qm-bg-elev, #fff); border: 1px solid rgba(0,0,0,0.08); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
  .dark .qm-table-cards tr { background: #1c1c1e; border-color: rgba(255,255,255,0.1); }
  .qm-table-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: none !important; font-size: 13px; text-align: right; white-space: normal !important; max-width: none !important; min-width: 0 !important; }
  .qm-table-cards td::before { content: attr(data-label); font-weight: 600; color: var(--qm-text-2, #777); text-align: left; flex-shrink: 0; }
  .qm-table-cards td:first-child { font-weight: 700; font-size: 14px; padding-bottom: 6px; }
  .qm-table-cards td:first-child::before { display: none; }
  .qm-table-cards td:empty, .qm-table-cards td.col-check { display: none; }

  .qm-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky, 30);
    height: var(--qm-header-h);
    padding: 4px 12px;
    /* !important : sinon .qm-mobile-only (display:block, défini plus bas) écrase le flex quand les 2 classes coexistent */
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 0.5px solid var(--qm-border);
    flex-shrink: 0;
    /* Tap highlight suppression */
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-header {
    background: rgba(28, 28, 30, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  /* Titre + sous-titre (flex:1 + overflow ellipsis = nowrap sans wrap) */
  .qm-header-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .qm-header-title h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--qm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
  }

  /* .qm-sub : sous-titre nowrap+ellipsis (règle #60 maquette canon) */
  .qm-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--qm-text-2);
    margin-top: -1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Bouton icône standard (touch target 44 px WCAG) */
  .qm-icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--qm-text);
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-icon-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--qm-text);
  }

  .qm-icon-btn:active {
    background: rgba(0, 0, 0, 0.12);
    transform: scale(0.92);
  }

  .dark .qm-icon-btn:active {
    background: rgba(255, 255, 255, 0.15);
  }

  /* Badge notification sur icon-btn */
  .qm-icon-btn .qm-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--qm-bg-elev);
  }


  /* ==========================================================================
     QM-TABBAR — bottom navigation 4-5 onglets
     HTML :
       <nav class="qm-tabbar">
         <button class="qm-tab active" type="button">
           <i class="fas fa-inbox"></i>
           <span>Inbox</span>
         </button>
         <button class="qm-tab" type="button">
           <i class="fas fa-ticket"></i>
           <span>Tickets</span>
           <span class="qm-tab-badge">5</span>
         </button>
         <!-- … 2-3 autres onglets … -->
       </nav>
     ========================================================================== */

  .qm-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky, 30);
    height: calc(var(--qm-tabbar-h) + var(--qm-safe-bottom));
    padding: 8px 8px calc(8px + var(--qm-safe-bottom));
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 0.5px solid var(--qm-border);
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-tabbar {
    background: rgba(28, 28, 30, 0.92);
    border-top-color: rgba(255, 255, 255, 0.08);
  }

  /* Espace sous le contenu scrollable pour ne pas masquer le dernier item */
  .qm-tabbar-spacer {
    display: block;
    height: calc(var(--qm-tabbar-h) + var(--qm-safe-bottom));
    flex-shrink: 0;
  }

  /* Blocs visibles uniquement sur mobile */
  .qm-mobile-only {
    display: block;
  }

  .qm-tab {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--qm-text);
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    opacity: 0.4;
    position: relative;
    padding: 4px 0 0;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px; /* touch target horizontal */
  }

  .qm-tab i {
    font-size: 20px;
    transition: transform 0.2s cubic-bezier(0.32, 1.5, 0.5, 1);
  }

  .qm-tab.active {
    opacity: 1;
    font-weight: 800;
  }

  .qm-tab:active {
    transform: scale(0.92);
  }

  .qm-tab:active i {
    transform: scale(0.85);
  }

  /* Badge sur onglet tabbar */
  .qm-tab-badge {
    position: absolute;
    top: 0;
    right: 30%;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--qm-bg-elev);
    animation: qm-badge-bounce 0.5s cubic-bezier(0.32, 1.8, 0.5, 1);
  }

  @keyframes qm-badge-bounce {
    0%   { transform: scale(0); }
    100% { transform: scale(1); }
  }

  /* Onglet central "Qloa" (logo flottant au-dessus de la barre) */
  .qm-tab.qm-tab--qloa {
    opacity: 1 !important;
    margin-top: -38px;
    flex: 0 0 70px;
  }

  .qm-tab.qm-tab--qloa i {
    background: #fff;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 4px solid var(--qm-bg-elev);
    font-size: 20px;
  }

  /* Bouton central avec le VRAI logo Qloa (img) — badge circulaire blanc */
  .qm-tab.qm-tab--qloa .qm-qloa-logo {
    width: 64px; height: 64px; border-radius: 50%; background: #fff;
    padding: 13px; box-sizing: border-box; object-fit: contain; display: block;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 4px solid var(--qm-bg-elev);
  }
  .dark .qm-tab.qm-tab--qloa .qm-qloa-logo { background: #1C1C1E; border-color: var(--qm-bg); }

  .dark .qm-tab.qm-tab--qloa i {
    background: #1C1C1E;
    border-color: var(--qm-bg);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  }


  /* ==========================================================================
     QM-CHIPS — filtres horizontaux scroll-x sans wrap
     HTML :
       <div class="qm-chips">
         <button class="qm-chip active" type="button">Tous <span class="qm-chip-count">218</span></button>
         <button class="qm-chip" type="button">Ouverts <span class="qm-chip-count">18</span></button>
       </div>
     ========================================================================== */

  .qm-chips {
    display: flex;
    gap: 6px;
    padding: 8px 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    background: var(--qm-bg);
    border-bottom: 0.5px solid var(--qm-border);
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px;
    /* Masque la scrollbar sur tous les navigateurs */
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-chips {
    background: var(--qm-bg);
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .qm-chips::-webkit-scrollbar {
    display: none;
  }

  /* Padding interne via pseudo-éléments (conserve le scroll edge-to-edge) */
  .qm-chips::before {
    content: '';
    flex: 0 0 16px;
  }

  .qm-chips::after {
    content: '';
    flex: 0 0 16px;
  }

  .qm-chip {
    flex-shrink: 0;
    padding: 7px 13px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-pill, 999px);
    font-size: 12px;
    font-weight: 600;
    color: var(--qm-text-2);
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
    scroll-snap-align: start;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-chip {
    background: rgba(255, 255, 255, 0.07);
    color: var(--qm-text-2);
  }

  .qm-chip.active {
    background: var(--qm-text);
    color: #fff;
  }

  .dark .qm-chip.active {
    background: #fff;
    color: #000;
  }

  .qm-chip:active {
    transform: scale(0.94);
  }

  .qm-chip-count {
    font-size: 10px;
    opacity: 0.7;
    font-weight: 700;
  }

  .qm-chip.active .qm-chip-count {
    opacity: 0.85;
    color: #fff;
  }


  /* ==========================================================================
     QM-CARD — carte générique (radius 10 px token, glass)
     HTML :
       <div class="qm-card">
         <div class="qm-card-body">…</div>
       </div>
       <!-- Variante interactive (tap feedback) -->
       <div class="qm-card qm-card--interactive" onclick="…">…</div>
     ========================================================================== */

  .qm-card {
    background: var(--panel-bg, rgba(255, 255, 255, 0.55));
    backdrop-filter: var(--panel-blur, blur(20px) saturate(180%));
    -webkit-backdrop-filter: var(--panel-blur, blur(20px) saturate(180%));
    border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.6));
    border-radius: var(--radius-card, 10px);
    box-shadow: var(--panel-shadow, 0 2px 8px rgba(0, 0, 0, 0.06));
    overflow: hidden;
  }

  .dark .qm-card {
    background: var(--panel-bg); /* override via :root.dark déjà appliqué */
    border-color: var(--panel-border);
  }

  .qm-card-body {
    padding: 14px 16px;
  }

  .qm-card--interactive {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-card--interactive:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-card, 0 1px 4px rgba(0, 0, 0, 0.04));
  }

  /* Card KPI mobile (grille 2 colonnes) */
  .qm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }

  .qm-kpi {
    background: var(--panel-bg, rgba(255, 255, 255, 0.55));
    backdrop-filter: var(--panel-blur, blur(20px) saturate(180%));
    -webkit-backdrop-filter: var(--panel-blur, blur(20px) saturate(180%));
    border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.6));
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--panel-shadow, 0 2px 8px rgba(0, 0, 0, 0.06));
    padding: 14px 16px;
  }

  .qm-kpi-value {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--qm-text);
  }

  .qm-kpi-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--qm-text-2);
    font-weight: 700;
    margin-top: 4px;
  }

  .qm-kpi-sub {
    font-size: 10px;
    color: var(--qm-text-3);
    margin-top: 2px;
  }


  /* ==========================================================================
     QM-PANEL — panneau latéral full-width en mobile (slide depuis la droite)
     En mobile : full-width (pas le 420 px desktop). Repose sur .lg-slide-panel
     existant mais le surcharge pour être full-width et partir du bottom de l'écran.
     HTML :
       <div class="lg-slide-panel qm-panel" id="my-panel">
         <div class="lg-slide-panel-header">…</div>
         <div class="lg-slide-panel-body">…</div>
         <div class="lg-slide-panel-footer">…</div>
       </div>
       <div class="lg-panel-backdrop" id="my-backdrop"></div>
     ========================================================================== */

  /* Override .lg-slide-panel en mobile → full-width depuis le top (pas positionnement desktop) */
  .lg-slide-panel,
  .qm-panel {
    /* position:fixed indispensable (le _styles.css desktop n'est pas chargé → sinon width:100% = 0) */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    background: var(--qm-bg-elev, #fff) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    /* Slide depuis la droite (même mécanique) */
    transform: translateX(100%) !important;
  }
  .dark .lg-slide-panel, .dark .qm-panel { background: #1c1c1e !important; }

  .lg-slide-panel.open,
  .qm-panel.open {
    transform: translateX(0) !important;
  }

  /* Panneau autonome .qm-panel (sans dépendre de .lg-slide-panel) */
  .qm-panel {
    position: fixed;
    z-index: var(--z-panel, 1200);
    background: var(--panel-bg, rgba(255, 255, 255, 0.92));
    backdrop-filter: blur(36px) saturate(200%);
    -webkit-backdrop-filter: blur(36px) saturate(200%);
    border: none;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
    pointer-events: none;
    overflow: hidden;
  }

  .dark .qm-panel {
    background: rgba(28, 28, 30, 0.95);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .qm-panel.open {
    opacity: 1;
    pointer-events: auto;
  }

  .qm-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 0.5px solid var(--qm-border);
    flex-shrink: 0;
    height: var(--qm-header-h);
  }

  .qm-panel-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--qm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
  }

  .qm-panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }

  .qm-panel-footer {
    padding: 12px 16px calc(12px + var(--qm-safe-bottom));
    border-top: 0.5px solid var(--qm-border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }

  /* Backdrop pour panel mobile */
  .qm-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-panel, 1200) - 1);
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .qm-panel-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }


  /* ==========================================================================
     QM-FAB — action principale flottante
     HTML :
       <button class="qm-fab" type="button" aria-label="Nouveau ticket">
         <i class="fas fa-plus"></i>
       </button>
     ========================================================================== */

  .qm-fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--qm-tabbar-h) + var(--qm-safe-bottom) + 12px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    z-index: calc(var(--z-sticky, 30) + 10);
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-fab {
    background: #fff;
    color: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.3);
  }

  .qm-fab:active {
    transform: scale(0.92);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  /* Variante accent (pour actions contextuelles) */
  .qm-fab--accent {
    background: var(--accent, #2563eb);
    color: #fff;
  }

  /* Pulse d'inactivité (attention subtile) */
  .qm-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    opacity: 0;
    animation: qm-fab-pulse 3s infinite;
    z-index: -1;
  }

  @keyframes qm-fab-pulse {
    0%   { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(1.7); opacity: 0; }
  }


  /* ==========================================================================
     QM-SHEET — bottom-sheet (remonte du bas)
     HTML :
       <div class="qm-sheet-backdrop" id="sheet-bd" onclick="closeSheet()"></div>
       <div class="qm-sheet" id="main-sheet">
         <div class="qm-sheet-handle"></div>
         <div class="qm-sheet-head"><h3>Filtres</h3></div>
         <div class="qm-sheet-body">
           <div class="qm-sheet-section">
             <p class="qm-sheet-section-label">Statut</p>
             <div class="qm-sheet-chips">
               <button class="qm-sheet-chip selected" type="button">Ouvert</button>
             </div>
           </div>
         </div>
         <div class="qm-sheet-footer">
           <button class="qm-sheet-apply" type="button">Appliquer</button>
         </div>
       </div>
     ========================================================================== */

  .qm-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-overlay, 1300) - 1);
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .qm-sheet-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .qm-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-overlay, 1300);
    background: var(--qm-bg-elev);
    border-radius: var(--radius-card, 10px) var(--radius-card, 10px) 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 78vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--qm-safe-bottom);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  }

  .dark .qm-sheet {
    background: #2C2C2E;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  }

  .qm-sheet.open {
    transform: translateY(0);
  }

  /* Poignée de glisser */
  .qm-sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
    margin: 10px auto 8px;
    flex-shrink: 0;
  }

  .dark .qm-sheet-handle {
    background: rgba(255, 255, 255, 0.2);
  }

  .qm-sheet-head {
    padding: 4px 20px 12px;
    border-bottom: 0.5px solid var(--qm-border);
  }

  .qm-sheet-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--qm-text);
  }

  .qm-sheet-body {
    padding: 16px 20px 4px;
  }

  .qm-sheet-section {
    margin-bottom: 18px;
    padding: 4px 14px calc(env(safe-area-inset-bottom, 0px) + 6px);
  }

  .qm-sheet-section-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--qm-text-3);
    margin: 0 0 8px;
    letter-spacing: 0.06em;
  }

  .qm-sheet-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .qm-sheet-chip {
    padding: 8px 14px;
    border: 1px solid var(--qm-border);
    border-radius: var(--radius-pill, 999px);
    background: var(--qm-bg-elev);
    font-size: 13px;
    font-weight: 600;
    color: var(--qm-text);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-sheet-chip.selected {
    background: var(--qm-text);
    color: #fff;
    border-color: var(--qm-text);
  }

  .dark .qm-sheet-chip.selected {
    background: #fff;
    color: #000;
    border-color: #fff;
  }

  .qm-sheet-chip:active {
    transform: scale(0.96);
  }

  .qm-sheet-footer {
    padding: 8px 20px 16px;
  }

  .qm-sheet-apply {
    width: 100%;
    padding: 14px;
    background: var(--qm-text);
    color: #fff;
    border: none;
    border-radius: var(--btn-radius, 10px);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-sheet-apply {
    background: #fff;
    color: #000;
  }

  .qm-sheet-apply:active {
    transform: scale(0.98);
  }


  /* ==========================================================================
     QM-ITEM — ligne de liste (pattern Inbox / Tickets)
     Supporte le swipe gauche/droite via classes JS : .swiped-left / .swiped-right
     HTML :
       <div class="qm-item-wrap">
         <div class="qm-swipe-actions qm-swipe-actions--right">
           <div class="qm-swipe-action qm-swipe-action--done">✓</div>
         </div>
         <div class="qm-swipe-actions qm-swipe-actions--left">
           <div class="qm-swipe-action qm-swipe-action--snooze">💤</div>
           <div class="qm-swipe-action qm-swipe-action--archive">📁</div>
         </div>
         <div class="qm-item-slider">
           <div class="qm-item">
             <div class="qm-item-avatar">MD</div>
             <div class="qm-item-content">
               <div class="qm-item-line1">
                 <span class="qm-item-sender">Marie Dupont</span>
                 <span class="qm-item-time">14 min</span>
               </div>
               <div class="qm-item-preview">Sujet ou aperçu…</div>
               <div class="qm-item-meta">…badges…</div>
             </div>
           </div>
         </div>
       </div>
     ========================================================================== */

  /* Badge de carte (global — utilisé par inbox/contacts/tickets/tasks). Pills propres. */
  .qm-item-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 9px; font-weight: 800; padding: 2px 7px;
    border-radius: 6px; text-transform: uppercase; letter-spacing: 0.03em;
    flex-shrink: 0; line-height: 1.5; white-space: nowrap;
  }
  .qm-item-badge--live    { background: rgba(220,38,38,0.1); color: #dc2626; }
  .qm-item-badge--handoff { background: rgba(249,115,22,0.1); color: #f97316; }
  .qm-item-badge--bot     { background: rgba(107,114,128,0.1); color: #6b7280; }
  .qm-item-badge--vip     { background: rgba(124,58,237,0.1);  color: #7c3aed; }

  .qm-item-wrap {
    position: relative;
    background: var(--qm-bg);
    overflow: hidden;
    touch-action: pan-y;
  }

  .qm-item-wrap + .qm-item-wrap {
    border-top: 0.5px solid var(--qm-border);
  }

  /* État flaggé : barre accent ambre + fond teinté + icône drapeau */
  .qm-item-wrap--flagged .qm-item-slider { background: rgba(245,158,11,0.07); }
  .dark .qm-item-wrap--flagged .qm-item-slider { background: rgba(245,158,11,0.12); }
  .qm-item-wrap--flagged::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: #f59e0b; z-index: 3;
  }
  .qm-item-flag-icon { color: #f59e0b; font-size: 11px; margin-right: 5px; flex-shrink: 0; }
  /* Libellé de la zone "Flaggés" épinglée */
  .qm-date-label--flagged { color: #b45309; display: flex; align-items: center; gap: 6px; }
  .dark .qm-date-label--flagged { color: #f59e0b; }
  .qm-date-label--flagged i { font-size: 10px; }

  /* Slider (l'élément qui se déplace au swipe) */
  .qm-item-slider {
    position: relative;
    z-index: 2;
    width: 100%;
    background: var(--qm-bg-elev);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    transform: translate3d(0, 0, 0);
  }

  .qm-item-wrap.dragging .qm-item-slider {
    transition: none;
  }

  .qm-item-wrap.swiped-right .qm-item-slider {
    transform: translate3d(80px, 0, 0);
  }

  .qm-item-wrap.swiped-left .qm-item-slider {
    transform: translate3d(-160px, 0, 0);
  }

  /* Actions swipe (cachées par défaut) */
  .qm-swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    display: none;
  }

  .qm-swipe-actions--right {
    left: 0;
    width: 80px;
  }

  .qm-swipe-actions--left {
    right: 0;
    width: 160px;
  }

  .qm-item-wrap.dragging .qm-swipe-actions,
  .qm-item-wrap.swiped-right .qm-swipe-actions--right,
  .qm-item-wrap.swiped-left .qm-swipe-actions--left {
    display: flex;
  }

  .qm-swipe-action {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    gap: 4px;
    cursor: pointer;
  }

  .qm-swipe-action i {
    font-size: 16px;
  }

  .qm-swipe-action--done    { background: #16a34a; }
  .qm-swipe-action--take    { background: #16a34a; }
  .qm-swipe-action--snooze  { background: #f97316; }
  .qm-swipe-action--archive { background: #6b7280; }
  .qm-swipe-action--flag    { background: #dc2626; }
  .qm-swipe-action--delete  { background: #dc2626; }
  .qm-swipe-action--escalate { background: #7c3aed; }

  /* Item lui-même */
  .qm-item {
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--qm-bg-elev);
    transition: background 0.15s;
    cursor: pointer;
    min-height: 64px;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-item:active {
    background: rgba(0, 0, 0, 0.04);
  }

  .dark .qm-item {
    background: var(--qm-bg-elev);
  }

  .dark .qm-item:active {
    background: rgba(255, 255, 255, 0.05);
  }

  /* Item non-lu */
  .qm-item.unread {
    background: rgba(37, 99, 235, 0.025);
  }

  /* Avatar */
  .qm-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
    position: relative;
  }

  .qm-item-avatar--green  { background: linear-gradient(135deg, #16a34a, #166534); }
  .qm-item-avatar--blue   { background: linear-gradient(135deg, #2563eb, #1e40af); }
  .qm-item-avatar--orange { background: linear-gradient(135deg, #f97316, #c2410c); }
  .qm-item-avatar--gray   { background: linear-gradient(135deg, #6b7280, #4b5563); }
  .qm-item-avatar--purple { background: linear-gradient(135deg, #7c3aed, #5b21b6); }

  /* Point canal (badge avatar) */
  .qm-item-avatar .qm-channel-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--qm-bg-elev);
    border: 2px solid var(--qm-bg-elev);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    color: #fff;
  }

  .qm-item-content {
    flex: 1;
    min-width: 0;
  }

  .qm-item-line1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
  }

  .qm-item-sender {
    font-size: 14px;
    font-weight: 700;
    color: var(--qm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }

  .qm-item-time {
    font-size: 11px;
    color: var(--qm-text-3);
    flex-shrink: 0;
    font-weight: 600;
  }

  .qm-item-preview {
    font-size: 13px;
    color: var(--qm-text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.35;
  }

  .qm-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
  }

  /* Badges inline dans la meta */
  .qm-item-priority {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
  }

  .qm-item-priority--urgent { background: rgba(220, 38, 38, 0.1); color: #dc2626; }
  .qm-item-priority--high   { background: rgba(249, 115, 22, 0.1); color: #f97316; }
  .qm-item-priority--low    { background: rgba(107, 114, 128, 0.1); color: #6b7280; }

  /* Animation de complétion (item qui sort) */
  .qm-item-wrap.completing {
    animation: qm-item-complete 0.4s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  }

  @keyframes qm-item-complete {
    0%   { transform: translateX(0); opacity: 1; max-height: 100px; }
    50%  { transform: translateX(100%); opacity: 0.6; }
    100% { transform: translateX(100%); opacity: 0; max-height: 0; padding: 0; margin: 0; }
  }


  /* ==========================================================================
     QM-SEARCH — barre de recherche collapse/expand
     HTML :
       <div class="qm-search" id="search-bar">
         <div class="qm-search-wrap">
           <i class="fas fa-magnifying-glass"></i>
           <input type="text" placeholder="Rechercher…" />
           <button type="button" onclick="closeSearch()">Annuler</button>
         </div>
       </div>
     (Toggle : ajouter/retirer la classe .open)
     ========================================================================== */

  .qm-search {
    display: block; /* override gateway display:none */
    padding: 0 14px;
    background: var(--qm-bg);
    border-bottom: 0.5px solid var(--qm-border);
    flex-shrink: 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s cubic-bezier(0.32, 0.72, 0, 1),
                opacity 0.25s,
                padding 0.25s;
  }

  .dark .qm-search {
    background: var(--qm-bg);
  }

  .qm-search.open {
    max-height: 60px;
    opacity: 1;
    padding-top: 6px;
    padding-bottom: 8px;
  }

  .qm-search-wrap {
    display: flex;
    align-items: center;
    background: var(--qm-bg-elev);
    border: 1px solid var(--qm-border);
    border-radius: var(--radius-card, 10px);
    padding: 0 12px;
    gap: 8px;
    height: 40px;
  }

  .dark .qm-search-wrap {
    background: rgba(255, 255, 255, 0.06);
  }

  .qm-search-wrap i {
    color: var(--qm-text-3);
    font-size: 13px;
    flex-shrink: 0;
  }

  .qm-search-wrap input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: var(--qm-text);
    min-width: 0;
  }

  .qm-search-wrap input::placeholder {
    color: var(--qm-text-3);
  }

  .qm-search-wrap button {
    background: none;
    border: none;
    color: var(--qm-text-2);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }


  /* ==========================================================================
     QM-EMPTY — état vide (liste sans résultats)
     HTML :
       <div class="qm-empty">
         <div class="qm-empty-icon"><i class="fas fa-inbox"></i></div>
         <h3>Aucun résultat</h3>
         <p>Modifiez les filtres pour afficher des éléments.</p>
         <button type="button" class="qm-empty-action">Voir tout</button>
       </div>
     ========================================================================== */

  .qm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 28px;
    text-align: center;
  }

  .qm-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--qm-text-3);
    margin-bottom: 20px;
  }

  .dark .qm-empty-icon {
    background: rgba(255, 255, 255, 0.05);
  }

  .qm-empty h3 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 800;
    color: var(--qm-text);
  }

  .qm-empty p {
    margin: 0 0 22px;
    font-size: 13px;
    color: var(--qm-text-2);
    line-height: 1.45;
    max-width: 260px;
  }

  .qm-empty-action {
    padding: 12px 22px;
    background: var(--qm-text);
    color: #fff;
    border: none;
    border-radius: var(--btn-radius, 10px);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .dark .qm-empty-action {
    background: #fff;
    color: #000;
  }


  /* ==========================================================================
     QM-SKELETON — loader squelette (listes en chargement)
     HTML :
       <div class="qm-skeleton-list">
         <div class="qm-skeleton-item">
           <div class="qm-skeleton-avatar"></div>
           <div class="qm-skeleton-content">
             <div class="qm-skeleton-line qm-skeleton-line--short"></div>
             <div class="qm-skeleton-line qm-skeleton-line--medium"></div>
           </div>
         </div>
       </div>
     ========================================================================== */

  @keyframes qm-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  .qm-skeleton-list {
    padding: 4px 0;
  }

  .qm-skeleton-item {
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--qm-bg-elev);
    border-top: 0.5px solid var(--qm-border);
  }

  .qm-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(90deg,
      rgba(0, 0, 0, 0.05) 25%,
      rgba(0, 0, 0, 0.10) 50%,
      rgba(0, 0, 0, 0.05) 75%);
    background-size: 200% 100%;
    animation: qm-shimmer 1.5s infinite;
    flex-shrink: 0;
  }

  .dark .qm-skeleton-avatar {
    background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.04) 25%,
      rgba(255, 255, 255, 0.09) 50%,
      rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
  }

  .qm-skeleton-content {
    flex: 1;
  }

  .qm-skeleton-line {
    height: 11px;
    border-radius: 4px;
    background: linear-gradient(90deg,
      rgba(0, 0, 0, 0.05) 25%,
      rgba(0, 0, 0, 0.10) 50%,
      rgba(0, 0, 0, 0.05) 75%);
    background-size: 200% 100%;
    animation: qm-shimmer 1.5s infinite;
    margin-bottom: 7px;
  }

  .dark .qm-skeleton-line {
    background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.04) 25%,
      rgba(255, 255, 255, 0.09) 50%,
      rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
  }

  .qm-skeleton-line--short  { width: 30%; }
  .qm-skeleton-line--medium { width: 70%; }
  .qm-skeleton-line--tiny   { width: 20%; height: 9px; }


  /* ==========================================================================
     UTILITAIRES MOBILES
     ========================================================================== */

  /* Toast mobile (bas d'écran) */
  .qm-toast {
    position: fixed;
    bottom: calc(var(--qm-tabbar-h) + var(--qm-safe-bottom) + 12px);
    left: 16px;
    right: 16px;
    z-index: var(--z-toast, 1400);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-card, 10px);
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
  }

  .dark .qm-toast {
    background: #e5e5e5;
    color: #000;
  }

  .qm-toast.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  /* Bannière de notification (top, tappable) */
  .qm-notif {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1500;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: none;
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
    border-radius: 0;   /* bandeau plein largeur intégré au header (pas une carte flottante) */
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 11px 14px;
    display: flex; align-items: center; gap: 12px;
    opacity: 0; transform: translateY(-130%);
    transition: opacity 0.28s ease, transform 0.34s cubic-bezier(0.32,0.72,0,1);
    pointer-events: none;
  }
  .dark .qm-notif { background: rgba(28,28,30,0.98); border-color: rgba(255,255,255,0.1); }
  .qm-notif.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .qm-notif-ic {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: 11px;
    background: rgba(245,158,11,0.15); color: #f59e0b;
    display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  }
  .qm-notif-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .qm-notif-txt strong { font-size: 14px; font-weight: 700; color: var(--qm-text, #000); }
  .qm-notif-txt span { font-size: 12.5px; color: var(--qm-text-2, #666); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dark .qm-notif-txt strong { color: #fff; } .dark .qm-notif-txt span { color: #aaa; }
  .qm-notif-x {
    width: 28px; height: 28px; flex-shrink: 0; border: none; border-radius: 999px;
    background: rgba(0,0,0,0.06); color: #888; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .dark .qm-notif-x { background: rgba(255,255,255,0.1); color: #aaa; }

  /* Section label sticky (séparateur dans listes groupées) */
  .qm-section-label {
    padding: 12px 16px 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--qm-text-3);
    letter-spacing: 0.06em;
    background: var(--qm-bg);
    position: sticky;
    top: var(--qm-header-h);
    z-index: 10;
  }

  /* Séparateur */
  .qm-divider {
    height: 0.5px;
    background: var(--qm-border);
    margin: 0;
  }

  /* Wrapper de page mobile (gère le bottom padding tabbar) */
  .qm-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--qm-bg);
    overscroll-behavior-y: none;
  }

  .qm-page-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--qm-tabbar-h) + var(--qm-safe-bottom) + 16px);
  }

  .qm-page-scroll::-webkit-scrollbar {
    display: none;
  }

  /* Masque la scrollbar globalement sur mobile */
  body {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  body::-webkit-scrollbar {
    display: none;
  }

  /* Overrides de layout desktop (sidebar → masquée en mobile) */
  .admin-sidebar,
  .sidebar,
  [class*="sidebar"] {
    display: none !important;
  }

  /* Le contenu principal prend toute la largeur */
  .admin-content,
  .main-content,
  [class*="main-content"] {
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100% !important;
  }

  /* ────────────────────────────────────────────────────────────────────────────
     OVERRIDES DESKTOP → masquer sur mobile (ne s'activent que si le .qm-header
     correspondant est présent dans la page = dashboard, inbox, agents)
     ──────────────────────────────────────────────────────────────────────────── */

  /* Header base.html (h1 + presence widget) — remplacé par .qm-header */
  main > header {
    display: none !important;
  }

  /* Réduction du padding global de main sur mobile */
  main.flex-1 {
    padding: 0 !important;
  }

  /* Gutter horizontal de page : pages form/cards qui s'appuyaient sur le padding
     de main (agents create/edit/wizard/templates, config...). main.flex-1 = padding 0
     → les cards touchaient les bords. .qm-pad rétablit le gutter canon (12px G/D, 0 haut). */
  .qm-pad {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Menus en haut (sub-tabs L2) : scroll horizontal sur mobile, jamais de wrap
     multi-lignes (sinon les onglets retombent à la ligne = sale). Canon règle #62. */
  .sub-tabs, .vis-sub-tabs, .tools-tabs, .prod-subtabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .sub-tabs::-webkit-scrollbar, .vis-sub-tabs::-webkit-scrollbar,
  .tools-tabs::-webkit-scrollbar, .prod-subtabs::-webkit-scrollbar { display: none; }
  .sub-tab, .vis-sub-tab, .tools-tab { flex-shrink: 0; white-space: nowrap; }

  /* Barre de filtres desktop inbox (.v3-filters) et titre .page-title-h1 :
     cachés sur mobile uniquement si le .qm-header mobile est présent dans la page.
     On les cache via .qm-header ~ pour cascade sibling — mais .qm-header est
     hors du .v3-inbox, donc on cache via le contexte global mobile. */
  .v3-filters {
    display: none !important;
  }

  /* Titre page (.page-title-h1) sous le header — remplacé par le titre dans .qm-header */
  .page-title-h1 {
    display: none !important;
  }

  /* q-pagehead (dashboard / agents) — masqué sur mobile (titre dans .qm-header) */
  .q-pagehead {
    display: none !important;
  }

  /* Pagehead macro (_pagehead.html) */
  .pagehead,
  [class*="pagehead"] {
    display: none !important;
  }

  /* Padding compensateur : le main commence direct après le .qm-header sticky */
  .animate-fade-in {
    padding-top: 0 !important;
  }

  /* Stats / presence bar desktop inbox — masquée (info dans subtitle mobile) */
  .flex.items-center.justify-between.gap-4.mb-3.flex-wrap {
    display: none !important;
  }

  /* Gridstack dashboard : empilage 1 colonne déjà géré (.grid-stack > .grid-stack-item width:100%)
     Ajouter padding adapté au body mobile (sous le .qm-header) */
  .grid-stack {
    margin-top: 0;
  }

  /* Scroll principal de main: compenser le header mobile sticky */
  main.flex-1.overflow-y-auto {
    padding-top: 0 !important;
  }


  /* ==========================================================================
     MOTEUR D'INTERACTIONS — styles portés de _mobile.css
     Swipe actions revelees, multi-select, toast, radial, voice overlay,
     workspace mini, @keyframes moteur.
     ========================================================================== */

  /* ── Pull-to-refresh indicator ───────────────────────────────────────────── */
  .qm-ptr {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--qm-text-2);
    z-index: 20;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .qm-ptr.visible {
    transform: translateX(-50%) translateY(20px);
  }

  .qm-ptr.refreshing i {
    animation: qm-ptr-spin 0.8s linear infinite;
    color: #000;
  }

  @keyframes qm-ptr-spin {
    to { transform: rotate(360deg); }
  }


  /* ── Toast (action feedback) ─────────────────────────────────────────────── */
  /* NB : .qm-toast est deja defini dans les utilitaires ci-dessus (bottom-sheet zone).
     On complete ici le comportement dynamique inject par JS. */

  /* ── Multi-select mode ───────────────────────────────────────────────────── */
  body.select-mode .qm-item {
    padding-left: 50px;
  }

  body.select-mode .m-item {
    padding-left: 50px;
  }

  /* Checkbox multi-select (injectee par JS ou presente en HTML) */
  .qm-checkbox {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--qm-text-3);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.32, 1.5, 0.5, 1);
    z-index: 5;
    pointer-events: none;
  }

  body.select-mode .qm-checkbox {
    transform: translateY(-50%) scale(1);
  }

  .qm-item-wrap.selected .qm-checkbox {
    background: #000;
    border-color: #000;
    color: #fff;
  }

  .qm-item-wrap.selected .qm-checkbox::after {
    content: 'check';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    font-style: normal;
  }

  .qm-item-wrap.selected .qm-item {
    background: rgba(0, 0, 0, 0.04);
  }

  /* Select bar (overlay header en mode selection) */
  .qm-select-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #000;
    color: #fff;
    padding: 4px 16px;
    height: 56px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 80;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  }

  body.select-mode .qm-select-bar {
    display: flex;
    animation: qm-slide-down 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }

  @keyframes qm-slide-down {
    from { transform: translateY(-56px); }
    to   { transform: translateY(0); }
  }

  .qm-select-bar-count {
    flex: 1;
    font-size: 14px;
    font-weight: 800;
  }

  .qm-select-bar-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-select-bar-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.92);
  }


  /* ── Radial menu (long-press) ────────────────────────────────────────────── */
  .qm-radial {
    position: absolute;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.32, 1.5, 0.5, 1);
  }

  .qm-radial.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
  }

  .qm-radial-item {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-radial-item:active {
    transform: scale(0.9);
  }

  .qm-radial-item--up    { top: 0; left: 75px; }
  .qm-radial-item--down  { bottom: 0; left: 75px; background: #dc2626; }
  .qm-radial-item--left  { top: 75px; left: 0; background: #2563eb; }
  .qm-radial-item--right { top: 75px; right: 0; background: #16a34a; }


  /* ── Qloa Workspace mini (tap court onglet central) ──────────────────────── */
  /* NOTE : sur la vraie app QLOA le tap court ouvre copilot.toggle() (Vision).
     Ce composant reste en CSS pour les pages qui l'integrent explicitement. */
  .qm-workspace {
    position: fixed;
    inset: 0;
    background: var(--qm-bg);
    z-index: 250;
    display: none;
    flex-direction: column;
    animation: qm-slide-up 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .qm-workspace.open {
    display: flex;
  }

  @keyframes qm-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  @keyframes qm-slide-down-full {
    from { transform: translateY(0); }
    to   { transform: translateY(100%); }
  }

  .qm-workspace-head {
    padding: 4px 16px;
    height: var(--qm-header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--qm-border);
    flex-shrink: 0;
  }

  .qm-workspace-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px 100px;
  }

  .qm-workspace-input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--qm-border);
    padding: 10px 12px calc(10px + var(--qm-safe-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .qm-workspace-input input {
    flex: 1;
    border: 1px solid var(--qm-border);
    background: #fff;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    min-width: 0;
    color: var(--qm-text);
  }

  .qm-msg-bot,
  .qm-msg-user {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 12px;
    max-width: 88%;
  }

  .qm-msg-bot {
    background: #fff;
    border: 1px solid var(--qm-border);
    border-bottom-left-radius: 6px;
  }

  .qm-msg-user {
    background: #000;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 6px;
  }


  /* ── Voice overlay (long-press onglet Qloa) ──────────────────────────────── */
  .qm-voice-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.98));
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    z-index: 300;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: 40px 24px;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-voice-overlay.open {
    display: flex;
    animation: qm-fade-in 0.3s;
  }

  @keyframes qm-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .qm-voice-orb {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    position: relative;
    animation: qm-voice-orb-pulse 1.5s ease-in-out infinite;
  }

  @keyframes qm-voice-orb-pulse {
    0%,  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4), 0 0 0 20px rgba(255,255,255,0.1); }
    50%        { box-shadow: 0 0 0 20px rgba(255,255,255,0.2), 0 0 0 60px rgba(255,255,255,0.05); }
  }

  .qm-voice-waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 30px;
    margin-bottom: 20px;
  }

  .qm-voice-waveform span {
    width: 3px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
    animation: qm-wave-bar 0.8s ease-in-out infinite;
  }

  .qm-voice-waveform span:nth-child(1) { animation-delay: 0s;    height: 30%; }
  .qm-voice-waveform span:nth-child(2) { animation-delay: 0.1s;  height: 60%; }
  .qm-voice-waveform span:nth-child(3) { animation-delay: 0.2s;  height: 100%; }
  .qm-voice-waveform span:nth-child(4) { animation-delay: 0.3s;  height: 80%; }
  .qm-voice-waveform span:nth-child(5) { animation-delay: 0.4s;  height: 50%; }
  .qm-voice-waveform span:nth-child(6) { animation-delay: 0.5s;  height: 90%; }
  .qm-voice-waveform span:nth-child(7) { animation-delay: 0.6s;  height: 40%; }
  .qm-voice-waveform span:nth-child(8) { animation-delay: 0.7s;  height: 70%; }

  @keyframes qm-wave-bar {
    0%,  100% { transform: scaleY(0.3); }
    50%        { transform: scaleY(1); }
  }

  .qm-voice-status {
    font-size: 14px;
    font-weight: 700;
    opacity: 0.7;
    margin-bottom: 4px;
  }

  .qm-voice-transcript {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    max-width: 280px;
    min-height: 60px;
    color: #fff;
  }

  .qm-voice-orb-logo {
    width: 84px; height: 84px; object-fit: contain;
  }

  .qm-voice-close {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-voice-close:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.92);
  }


  /* ── Heartbeat onglet Qloa central ──────────────────────────────────────── */
  @keyframes qm-qloa-heartbeat {
    0%,  100% {
      box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.22),
        0 2px 8px rgba(0, 0, 0, 0.12);
    }
    50% {
      box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.22),
        0 2px 8px rgba(0, 0, 0, 0.12),
        0 0 0 10px rgba(0, 0, 0, 0.04),
        0 0 0 22px rgba(0, 0, 0, 0.02);
    }
  }

  .qm-tab.qm-tab--qloa i {
    animation: qm-qloa-heartbeat 2.5s ease-in-out infinite;
  }


  /* ── @keyframes generaux moteur ──────────────────────────────────────────── */
  @keyframes qm-ai-pulse {
    0%,  100% { opacity: 0.7; transform: scale(1); }
    50%        { opacity: 1;   transform: scale(1.05); }
  }

  @keyframes qm-fab-pulse-atten {
    0%   { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(1.7); opacity: 0; }
  }

  @keyframes qm-dot-pulse {
    0%,  80%,  100% { opacity: 0.3; transform: scale(1); }
    40%              { opacity: 1;   transform: scale(1.3); }
  }

  @keyframes qm-record-pulse {
    0%,  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50%        { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  }

  @keyframes qm-badge-bounce-in {
    0%   { transform: scale(0) rotate(-20deg); }
    70%  { transform: scale(1.15) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
  }

  /* Typing dots (assistant bot) */
  .qm-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--qm-text-2);
    border-radius: 50%;
    display: inline-block;
    animation: qm-dot-pulse 1s infinite;
  }

  .qm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
  .qm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

  /* Snooze items (bottom sheet snooze) */
  .qm-snooze-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .qm-snooze-item {
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-card, 10px);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    width: 100%;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-snooze-item:active {
    transform: scale(0.98);
    background: rgba(0, 0, 0, 0.06);
  }

  .qm-snooze-item i {
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
  }

  .qm-snooze-item strong { font-size: 14px; font-weight: 700; display: block; }
  .qm-snooze-item span   { font-size: 11px; color: var(--qm-text-2); }

  /* Quick replies AI inline */
  .qm-quick-replies {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 16px 12px 68px;
    -webkit-overflow-scrolling: touch;
    background: var(--qm-bg-elev);
    border-top: 0.5px dashed rgba(0, 0, 0, 0.06);
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .qm-quick-replies::-webkit-scrollbar { display: none; }

  .qm-quick-reply {
    flex-shrink: 0;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-pill, 999px);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--qm-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .qm-quick-reply:active {
    transform: scale(0.94);
    background: rgba(0, 0, 0, 0.1);
  }


  /* ==========================================================================
     LIVRABLE 3 — MASQUAGE MOBILE des elements parasites
     a) FAB Qloa Vision bas-droite (#copilot-root) — remplace par l'onglet central
     b) .tc-launcher (messagerie interne) — redondant sur mobile
     c) .copilot-tip / #copilot-tip (bulle 'Besoin d aide ?')
     Tous masques proprement via @media sans toucher la logique JS.
     ========================================================================== */

  /* FAB Vision (copilot bas-droite) — masque le BOUTON seul, PAS #copilot-root :
     copilot.toggle() ouvre #copilot-panel (DANS #copilot-root) → root doit rester
     affichable sinon le tap du bouton central (Vision) n'ouvre rien. */
  #copilot-btn { display: none !important; }
  /* Le panneau Vision/copilot en mobile = pleine largeur (au lieu de 400px bas-droite) */
  #copilot-root { bottom: 0 !important; right: 0 !important; left: 0 !important; }
  #copilot-panel { width: 100vw !important; max-width: 100vw !important; height: 80vh !important; right: 0 !important; bottom: 0 !important; border-radius: 18px 18px 0 0 !important; }

  /* Messagerie interne launcher (.tc-launcher) — masque sur mobile */
  .tc-launcher {
    display: none !important;
  }

  /* Bulle proactive 'Besoin d aide ?' — masque sur mobile */
  #copilot-tip {
    display: none !important;
  }

  /* ── Dashboard mobile : toolbar desktop cachée + polish widgets gridstack ── */
  .q-pagehead { display: none !important; }
  #view-subtitle { display: none !important; }  /* label "Layout · N widgets" desktop */
  #grid-container { padding: 12px 12px calc(var(--qm-tabbar-h, 78px) + 20px); overflow-x: hidden; }
  .space-y-6 { overflow-x: hidden; }

  /* Gridstack → VRAI 1-colonne : neutralise le positionnement absolu (immunisé au
     resize / à l'init en col=12). Chaque widget = pleine largeur, hauteur contenu. */
  #grid-container .grid-stack { height: auto !important; }
  #grid-container .grid-stack > .grid-stack-item {
    position: static !important; width: 100% !important; left: 0 !important; top: 0 !important;
    transform: none !important; height: auto !important; min-height: 0 !important; margin: 0 0 12px !important;
  }
  #grid-container .grid-stack > .grid-stack-item > .grid-stack-item-content {
    position: static !important; inset: auto !important; height: auto !important; min-height: 0 !important;
    overflow: visible !important;
    border-radius: var(--radius-card, 10px) !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
  }
  .dark #grid-container .grid-stack > .grid-stack-item > .grid-stack-item-content { border-color: rgba(255,255,255,0.08) !important; }

  /* Tabbar : au-dessus de tout (le <main> base.html peut empiler au-dessus) */
  .qm-tabbar { z-index: 200 !important; }

  /* ── RESPECT LARGEUR FENÊTRE (anti-débordement horizontal) ── */
  html, body { overflow-x: hidden !important; max-width: 100vw; }
  main, main.flex-1 { overflow-x: hidden !important; }

  /* Coupables overflow horizontal mobile (éléments globaux base.html, hors-écran droite) :
     - liquid-blob = déco fond, inutile mobile
     - panneaux slide messagerie/nouvelle-conv fermés = positionnés en offset réel
       (right ~868) → scroll horizontal. Neutralisés en mobile (flow non utilisé). */
  .liquid-blob { display: none !important; }
  #nc-panel, #nc-backdrop, #tc-panel, #tc-backdrop { display: none !important; }
  /* Garde-fou : tout slide-panel fermé ne doit pas déborder (transform visuel only) */
  .lg-slide-panel:not(.open) { transform: translateX(110%) !important; right: 0 !important; }
  #grid-container, .grid-stack, .space-y-6 {
    max-width: 100% !important; width: 100% !important; min-width: 0 !important; box-sizing: border-box;
  }
  /* Qloa AI Insights : padding gauche/droite + ne déborde pas */
  #ai-insights {
    margin-left: 12px !important; margin-right: 12px !important;
    max-width: calc(100% - 24px) !important; box-sizing: border-box; overflow: hidden;
  }

  /* Header mobile maquette (#dash-mobile-head) */
  #dash-mobile-head {
    display: block; position: sticky; top: 0; z-index: 40;
    background: rgba(245,245,247,0.85); backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0,0,0,0.06); padding-top: env(safe-area-inset-top, 0);
  }
  .dark #dash-mobile-head { background: rgba(20,20,22,0.85); border-bottom-color: rgba(255,255,255,0.08); }
  #dash-mobile-head .dash-header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
  #dash-mobile-head .dash-avatar-btn {
    width: 34px; height: 34px; border-radius: 50%; border: none; flex-shrink: 0;
    background: #000; color: #fff; font-size: 12px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .dark #dash-mobile-head .dash-avatar-btn { background: #fff; color: #000; }
  #dash-mobile-head .dash-header-title { flex: 1; min-width: 0; }
  #dash-mobile-head .dash-header-title strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -0.02em; color: #000; }
  .dark #dash-mobile-head .dash-header-title strong { color: #fff; }
  #dash-mobile-head .dash-header-title span { display: block; font-size: 11px; color: #6B7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #dash-mobile-head .qm-icon-btn {
    width: 34px; height: 34px; border-radius: 50%; border: none; flex-shrink: 0; cursor: pointer;
    background: rgba(0,0,0,0.05); color: #000; display: flex; align-items: center; justify-content: center; font-size: 14px;
  }
  .dark #dash-mobile-head .qm-icon-btn { background: rgba(255,255,255,0.08); color: #fff; }
  #dash-mobile-head .dash-period-chips {
    display: flex; gap: 6px; overflow-x: auto; padding: 0 14px 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  #dash-mobile-head .dash-period-chips::-webkit-scrollbar { display: none; }
  #dash-mobile-head .dash-period-chip {
    flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 6px 13px;
    border-radius: var(--radius-card, 10px); border: 1px solid rgba(0,0,0,0.1);
    background: transparent; color: #6B7280; cursor: pointer; white-space: nowrap;
  }
  .dark #dash-mobile-head .dash-period-chip { border-color: rgba(255,255,255,0.12); color: #9CA3AF; }
  #dash-mobile-head .dash-period-chip.active { background: #000; color: #fff; border-color: #000; }
  .dark #dash-mobile-head .dash-period-chip.active { background: #fff; color: #000; border-color: #fff; }

} /* fin @media (max-width: 768px) */

/* Header dashboard mobile — CACHÉ en desktop (min-width:769 pour ne pas écraser le @media mobile) */
@media (min-width: 769px) { #dash-mobile-head { display: none !important; } }

/* Bouton retour MOBILE (workspace immersif sans tabbar) */
@media (max-width: 768px) {
  .qm-back-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; border: none; flex-shrink: 0;
    background: rgba(0,0,0,0.05); color: #000; font-size: 16px; cursor: pointer;
  }
  .dark .qm-back-btn { background: rgba(255,255,255,0.08); color: #fff; }
}
@media (min-width: 769px) { .qm-back-btn { display: none !important; } }

/* ── Workspace mobile : safe-area (Dynamic Island) + masquer hints input ── */
@media (max-width: 768px) {
  #ws-header { padding-top: calc(env(safe-area-inset-top, 0px) + 4px) !important; }
  .ws-input-hints { display: none !important; }  /* /template @agent — inutile mobile */
}

/* ── Dashboard mobile : lignes du sheet "Plus d'actions" ── */
@media (max-width: 768px) {
  .dash-more-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; margin: 3px 0; background: rgba(0,0,0,0.025);
    border: none; border-radius: 12px; font-size: 14.5px; font-weight: 600;
    color: #000; cursor: pointer; text-align: left; text-decoration: none;
  }
  .dark .dash-more-row { color: #fff; background: rgba(255,255,255,0.045); }
  .dash-more-row > i:first-child {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px;
    background: rgba(0,0,0,0.06); color: #000;
    display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  }
  .dark .dash-more-row > i:first-child { background: rgba(255,255,255,0.1); color: #fff; }
  .dash-more-row > span { flex: 1; min-width: 0; }
  .dash-more-row::after {
    content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    color: #c7c7cc; font-size: 12px; margin-left: auto; flex-shrink: 0;
  }
  .dash-more-row:active { background: rgba(0,0,0,0.06); }
  .dark .dash-more-row:active { background: rgba(255,255,255,0.09); }
}

/* ── "Plus" = menu plein écran (vrai menu nav, distinct du sheet contextuel) ── */
@media (max-width: 768px) {
  .qm-sheet--full {
    height: 100% !important; max-height: 100% !important; border-radius: 0 !important;
    display: flex; flex-direction: column; padding: 0 !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }
  .qm-menu-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid rgba(0,0,0,0.06); flex-shrink: 0;
  }
  .dark .qm-menu-head { border-bottom-color: rgba(255,255,255,0.08); }
  .qm-menu-head strong { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: #000; }
  .dark .qm-menu-head strong { color: #fff; }
  .qm-menu-close {
    position: static !important; top: auto !important; right: auto !important;
    width: 36px; height: 36px; background: rgba(0,0,0,0.05) !important; color: #000 !important;
  }
  .dark .qm-menu-close { background: rgba(255,255,255,0.08) !important; color: #fff !important; }
  .qm-menu-scroll {
    flex: 1; overflow-y: auto;
    padding: 8px 12px calc(var(--qm-tabbar-h, 78px) + 24px);
  }
  .qm-menu-scroll .qm-sheet-section-label { margin: 16px 8px 6px; font-size: 13px; font-weight: 700; }
}

/* Détail conv/mail ouvert = immersif : cacher tabbar + FAB (body.qm-detail-open) */
body.qm-detail-open .qm-tabbar,
body.qm-detail-open .qm-fab,
body.qm-detail-open .qm-tabbar-spacer,
/* bandeau d'escalade global (liste) : ne doit pas déborder par-dessus le header du détail */
body.qm-detail-open #global-handoff-alert { display: none !important; }

/* Sheet d'ACTIONS (≠ menu nav Plus) : pas de chevron — ce sont des actions, pas de la navigation */
@media (max-width: 768px) {
  /* padding interne : ces sheets n'ont pas de wrapper scroll → ajouter ici */
  #qm-detail-actions .qm-sheet-section,
  #qm-chat-ai .qm-sheet-section {
    padding: 4px 16px calc(var(--qm-safe-bottom, 0px) + 14px);
    margin-bottom: 0;
  }
  #qm-detail-actions .qm-sheet-section-label,
  #qm-chat-ai .qm-sheet-section-label { margin: 4px 4px 8px; }
  #qm-detail-actions .dash-more-row::after,
  #qm-chat-ai .dash-more-row::after { display: none !important; }
  #qm-detail-actions .dash-more-row,
  #qm-chat-ai .dash-more-row { margin: 3px 0; }
  /* le menu IA a des sous-titres → aligner l'icône en haut */
  #qm-chat-ai .dash-more-row { align-items: flex-start; }
  #qm-chat-ai .dash-more-row > i:first-child { margin-top: 1px; }
  #qm-detail-actions .dash-more-row[data-act="delete"] > i:first-child {
    background: rgba(220,38,38,0.12); color: #dc2626;
  }
  /* Header détail email : pill "Archiver" desktop redondante avec le menu ⋮ → masquer */
  body.qm-detail-open .em-hdr-archive { display: none !important; }

  /* Barre Accepter/Refuser escalade (détail awaiting) — collée en bas */
  .qm-handoff-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1355;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 0.5px solid rgba(0,0,0,0.1);
    padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
  .dark .qm-handoff-bar { background: rgba(20,20,22,0.98); border-top-color: rgba(255,255,255,0.1); }
  .qm-handoff-bar-hint { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: #b45309; display: flex; align-items: center; gap: 6px; }
  .dark .qm-handoff-bar-hint { color: #f59e0b; }
  .qm-handoff-bar-btns { display: flex; gap: 10px; }
  .qm-handoff-bar-btns button {
    flex: 1; padding: 13px 0; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  }
  .qm-hb-accept { background: #16a34a; color: #fff; flex: 2 !important; }
  .qm-hb-refuse { background: rgba(0,0,0,0.06); color: #444; }
  .dark .qm-hb-refuse { background: rgba(255,255,255,0.1); color: #ddd; }

  /* Compose : sélecteur de canal */
  #qm-compose-channels {
    display: flex; gap: 6px; padding: 10px 12px 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  #qm-compose-channels::-webkit-scrollbar { display: none; }
  .qm-chanpick {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
    border: 1px solid rgba(0,0,0,0.12); background: #fff; color: #555; cursor: pointer;
  }
  .qm-chanpick.active { background: #111; color: #fff; border-color: #111; }
  .dark .qm-chanpick { background: rgba(255,255,255,0.06); color: #aaa; border-color: rgba(255,255,255,0.14); }
  .dark .qm-chanpick.active { background: #fff; color: #111; }

  /* Compose : dropdown autocomplete contacts CRM */
  .qm-ac-dd {
    position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 1380;
    background: var(--qm-bg-elev, #fff); border: 0.5px solid rgba(0,0,0,0.1);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.16); overflow: hidden; max-height: 260px; overflow-y: auto;
  }
  .dark .qm-ac-dd { background: #1c1c1e; border-color: rgba(255,255,255,0.1); }
  .qm-ac-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
  .qm-ac-row:active, .qm-ac-row:hover { background: rgba(0,0,0,0.04); }
  .dark .qm-ac-row:active, .dark .qm-ac-row:hover { background: rgba(255,255,255,0.06); }
  .qm-ac-av {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 999px; background: #2563eb; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  }
  .qm-ac-tx { display: flex; flex-direction: column; min-width: 0; }
  .qm-ac-tx strong { font-size: 14px; color: var(--qm-text, #000); }
  .qm-ac-tx span { font-size: 12px; color: var(--qm-text-2, #777); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dark .qm-ac-tx strong { color: #fff; } .dark .qm-ac-tx span { color: #999; }
  .qm-ac-create { padding: 11px 12px; font-size: 13.5px; color: #2563eb; cursor: pointer; display: flex; align-items: center; gap: 8px; }
  .qm-ac-create:active { background: rgba(37,99,235,0.08); }

  /* Bouton loupe header détail (même style que le bouton actions) */
  .qm-detail-search-btn {
    width: 36px; height: 36px; flex-shrink: 0; border: none; border-radius: 999px;
    background: rgba(0,0,0,0.05); color: #000; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
  }
  .dark .qm-detail-search-btn { background: rgba(255,255,255,0.08); color: #fff; }

  /* Barre de recherche dans la conversation : glisse sous le header */
  .qm-detail-search {
    position: fixed; left: 0; right: 0; z-index: 1360;
    top: calc(env(safe-area-inset-top, 0px) + 54px);  /* fallback ; JS ajuste sur le bas réel du header */
    padding: 8px 12px; background: var(--qm-bg-elev, #fff);
    border-bottom: 0.5px solid var(--qm-border, rgba(0,0,0,0.08));
    /* fermée : remontée hors écran (top dynamique → on translate de toute la hauteur viewport pour garantir l'effacement) + inerte */
    transform: translateY(-100vh); pointer-events: none; visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.32,0.72,0,1), visibility 0s linear 0.28s;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  }
  .dark .qm-detail-search { background: #1c1c1e; }
  body.qm-detail-searching .qm-detail-search {
    transform: translateY(0); pointer-events: auto; visibility: visible;
    transition: transform 0.28s cubic-bezier(0.32,0.72,0,1), visibility 0s;
  }
  .qm-detail-search .qm-search-wrap { display: flex; align-items: center; gap: 8px; }
  .qm-detail-search input {
    flex: 1; border: none; background: transparent; outline: none;
    font-size: 15px; color: var(--qm-text, #000); padding: 6px 0;
  }
  .qm-detail-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
  .qm-detail-search-close {
    width: 28px; height: 28px; border: none; border-radius: 999px;
    background: rgba(0,0,0,0.06); color: #666; cursor: pointer; flex-shrink: 0;
  }
  .dark .qm-detail-search-close { background: rgba(255,255,255,0.1); color: #aaa; }

  /* Résultats : estompe les non-correspondants, met en avant les hits */
  .qm-msg-dim { opacity: 0.32; transition: opacity 0.2s; }
  .qm-msg-hit { opacity: 1; }
  .qm-msg-hit .message-bubble, .qm-msg-hit.message-bubble {
    box-shadow: 0 0 0 2px rgba(37,99,235,0.45); border-radius: 14px;
  }
}

/* ============================================================================
   DÉTAIL CONVERSATION / MAIL — RENDU MOBILE NATIF
   Scope : body.qm-detail-open + @media (max-width: 768px)
   Sélecteurs : vrais ids/classes desktop (conversation-header, conversation-messages,
   handoff-response-zone, email-reply-zone, message-bubble, message-container…)
   Zéro régression desktop : tout est conditionnel à body.qm-detail-open
   ============================================================================ */
@media (max-width: 768px) {

  /* ── Layout .v3-inbox en overlay : flex colonne plein écran ── */
  body.qm-detail-open .v3-inbox {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    /* safe-area top : Dynamic Island / notch — intégré dans le padding du header */
    padding-top: 0 !important;
    height: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Masquer : filtres inbox, titre "Inbox", liste sessions, resizer, colonne contexte ── */
  body.qm-detail-open .v3-inbox .v3-filters,
  body.qm-detail-open .v3-inbox .page-title-h1,
  body.qm-detail-open .v3-inbox #chat-col-list,
  body.qm-detail-open .v3-inbox #inbox-resizer,
  body.qm-detail-open .v3-inbox .chat-col-context { display: none !important; }

  /* ── Zone principale .chat-workspace : flex row → flex colonne (session-list masquée) ── */
  body.qm-detail-open .v3-inbox .chat-workspace {
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
    /* Écraser le height calc() inline du desktop */
    height: 100% !important;
    min-height: 0 !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* La colonne conversation (glass-card flex-1) prend tout l'espace
     position:relative = anchor pour les composers position:absolute en bas */
  body.qm-detail-open .v3-inbox .flex-1.min-w-0.glass-card {
    position: relative !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #fff !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100% !important;
    min-height: 0 !important;
  }
  .dark body.qm-detail-open .v3-inbox .flex-1.min-w-0.glass-card {
    background: #0a0a0a !important;
  }

  /* ── HEADER DÉTAIL MOBILE : 56 px + safe-area top, avatar + nom + canal ── */
  body.qm-detail-open #conversation-header {
    /* Réinitialise les classes desktop */
    background: rgba(255,255,255,0.97) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-bottom: 0.5px solid rgba(0,0,0,0.12) !important;
    border-radius: 0 !important;
    flex-shrink: 0 !important;
    /* au-dessus de la barre de recherche (1360) → la barre glisse DERRIÈRE le header */
    position: relative !important; z-index: 1370 !important;
    /* safe-area top (Dynamic Island) en padding-top, corps = 8px haut 8px bas */
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px) !important;
    padding-bottom: 8px !important;
    padding-left: 8px !important;   /* back intégré dans le header, plus de flottant */
    padding-right: 6px !important;
    min-height: calc(56px + env(safe-area-inset-top, 0px)) !important;
    box-sizing: border-box !important;
    display: flex !important;
    /* row FORCÉ : la vue mail solo pose flex-col (Tailwind) sur ce header → back/titre/loupe/⋮
       s'empilaient verticalement (~183px de chrome). */
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    overflow: hidden !important;
  }
  /* Le bloc central (titre/ibar) prend l'espace restant sans pousser loupe/⋮ hors écran */
  body.qm-detail-open #conversation-header > div {
    flex: 1 1 auto; min-width: 0; overflow: hidden;
  }
  .dark body.qm-detail-open #conversation-header {
    background: rgba(10,10,10,0.97) !important;
    border-bottom-color: rgba(255,255,255,0.1) !important;
  }
  /* Bouton retour + actions INTÉGRÉS au header détail (pas flottant) */
  body.qm-detail-open #conversation-header .qm-detail-back,
  body.qm-detail-open #conversation-header .qm-detail-actions-btn {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: none;
    background: rgba(0,0,0,0.05); color: #000; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
  }
  body.qm-detail-open #conversation-header .qm-detail-actions-btn { margin-left: auto; }
  .dark body.qm-detail-open #conversation-header .qm-detail-back,
  .dark body.qm-detail-open #conversation-header .qm-detail-actions-btn { background: rgba(255,255,255,0.1); color: #fff; }

  /* v3-ibar : le container principal du header — flex:1 (PAS width:100% qui pousse loupe/⋮ hors écran) */
  body.qm-detail-open #conversation-header .v3-ibar {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }
  /* loupe + ⋮ toujours visibles à droite */
  body.qm-detail-open #conversation-header .qm-detail-search-btn,
  body.qm-detail-open #conversation-header .qm-detail-actions-btn { flex-shrink: 0 !important; }
  /* actions handoff (Accepter/Refuser) du header : écrasées en mobile → masquées (barre bas dédiée) */
  body.qm-detail-open #conversation-header #header-handoff-actions,
  body.qm-detail-open #conversation-header #v3-handoff-take-btn,
  body.qm-detail-open #conversation-header #handoff-timer { display: none !important; }

  /* Statut handoff : pas de pill → texte inline discret + TEINTE du header (canon demandé) */
  body.qm-detail-open #conversation-header .v3-handoff-badge {
    background: transparent !important; padding: 0 !important; border-radius: 0 !important;
    margin-left: 6px !important; font-size: 11px !important; font-weight: 700 !important;
    white-space: nowrap; flex-shrink: 0;
  }
  /* LIVE → header teinté vert ; ESCALADE → teinté orange (barre d'accent gauche + fond léger) */
  body.qm-handoff-live #conversation-header {
    background: rgba(22,163,74,0.10) !important;
    box-shadow: inset 3px 0 0 #16a34a !important;
  }
  body.qm-handoff-live #conversation-header .v3-handoff-badge--live { color: #15803d !important; }
  body.qm-handoff-pending #conversation-header {
    background: rgba(245,158,11,0.12) !important;
    box-shadow: inset 3px 0 0 #f59e0b !important;
  }
  .dark body.qm-handoff-live #conversation-header { background: rgba(22,163,74,0.16) !important; }
  .dark body.qm-handoff-pending #conversation-header { background: rgba(245,158,11,0.18) !important; }

  /* Avatar */
  body.qm-detail-open #conversation-header .v3-ibar-av {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 50% !important;
    background: #000 !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  /* Zone nom + meta : colonne, 1 ligne tronquée */
  body.qm-detail-open #conversation-header .v3-ibar-main {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
  }
  body.qm-detail-open #conversation-header .v3-ibar-row {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }
  body.qm-detail-open #conversation-header .v3-ibar-name {
    font-size: 14px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.15 !important;
    color: #000 !important;
  }
  .dark body.qm-detail-open #conversation-header .v3-ibar-name {
    color: #fff !important;
  }

  /* Ligne méta (email, canal…) : compact, 1 ligne max, ellipsis */
  body.qm-detail-open #conversation-header .v3-ibar-meta {
    font-size: 10.5px !important;
    color: #6b7280 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
  body.qm-detail-open #conversation-header .v3-ibar-meta > * {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  /* Masquer la 2e ligne méta (session id / messages count) trop technique sur mobile */
  body.qm-detail-open #conversation-header .v3-ibar-sub { display: none !important; }

  /* Masquer les actions desktop (fiche client, handoff, tickets…) — trop larges */
  body.qm-detail-open #conversation-header .v3-ibar-actions { display: none !important; }

  /* Masquer la barre d'action desktop (ctxbar : copilote, produits, handoff) */
  body.qm-detail-open #conversation-header .v3-ctxbar { display: none !important; }

  /* Badges inline : réduire */
  body.qm-detail-open #conversation-header .v3-ibar-badge {
    font-size: 8px !important;
    padding: 1px 5px !important;
    border-radius: 20px !important;
  }

  /* ── ZONE MESSAGES : scrollable, padding bas pour le composer collé ── */
  body.qm-detail-open #conversation-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 12px 14px 130px !important; /* 130px pour le composer en bas */
    background: #f8f8f8 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
  }
  .dark body.qm-detail-open #conversation-messages {
    background: #0d0d0d !important;
  }

  /* Mode thread email : même fond légèrement différent */
  body.qm-detail-open #conversation-messages.email-thread-view {
    background: #f6f8fa !important;
    padding: 12px 10px 160px !important;
  }
  .dark body.qm-detail-open #conversation-messages.email-thread-view {
    background: #0d0d0f !important;
  }

  /* ── BULLES CHAT ── */

  /* Container message : margin normal */
  body.qm-detail-open .message-container {
    margin-bottom: 6px !important;
    gap: 8px !important;
    animation: qmFadeIn 0.2s ease-out !important;
  }

  /* Avatar bot : taille mobile */
  body.qm-detail-open .msg-avatar {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    font-size: 10px !important;
    flex-shrink: 0 !important;
  }

  /* Colonne bulle + timestamp */
  body.qm-detail-open .msg-col {
    max-width: 82% !important;
  }

  /* Bulle assistant (gauche / customer) : blanc, border, radius bottom-left petit */
  body.qm-detail-open .message-bubble.assistant {
    background: #fff !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    border-radius: 18px 18px 18px 4px !important;
    padding: 10px 13px !important;
    font-size: 13.5px !important;
    line-height: 1.45 !important;
    color: #000 !important;
  }
  .dark body.qm-detail-open .message-bubble.assistant {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #fff !important;
  }

  /* Bulle user (droite / agent) : noir, radius bottom-right petit */
  body.qm-detail-open .message-bubble.user {
    background: #000 !important;
    color: #fff !important;
    border-radius: 18px 18px 4px 18px !important;
    padding: 10px 13px !important;
    font-size: 13.5px !important;
    line-height: 1.45 !important;
    border: none !important;
  }
  .dark body.qm-detail-open .message-bubble.user {
    background: #fff !important;
    color: #000 !important;
  }

  /* Timestamp sous bulle */
  body.qm-detail-open .message-time {
    font-size: 10px !important;
    color: #9ca3af !important;
    margin-top: 3px !important;
    padding: 0 4px !important;
  }

  /* Event marker système */
  body.qm-detail-open .event-marker {
    font-size: 11px !important;
    padding: 5px 10px !important;
    margin: 8px auto !important;
    border-radius: 8px !important;
    text-align: center !important;
    max-width: 90% !important;
  }

  /* ── COMPOSER CHAT (handoff-response-zone) : collé en bas ── */
  body.qm-detail-open #handoff-response-zone {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 200 !important;
    background: rgba(255,255,255,0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 0.5px solid rgba(0,0,0,0.1) !important;
    border-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    /* masquer les éléments non essentiels pour garder compact */
  }
  .dark body.qm-detail-open #handoff-response-zone {
    background: rgba(10,10,10,0.97) !important;
    border-top-color: rgba(255,255,255,0.1) !important;
  }

  /* Masquer les raccourcis clavier desktop (⌘/ ⌘↵) */
  body.qm-detail-open #handoff-response-zone .v3-kbd { display: none !important; }
  body.qm-detail-open #handoff-response-zone .px-4.pb-2.pt-0\.5 { display: none !important; }
  /* Masquer les pills de raccourcis (encombrent) — règle séparée pour éviter qu'un sélecteur échappé invalide tue le groupe */
  body.qm-detail-open #handoff-response-zone .v3-quickbar { display: none !important; }
  body.qm-detail-open #handoff-response-zone #quick-responses-bar { display: none !important; }
  /* Actions copilote flottantes (Envoyer/Modifier/Régénérer) sous le textarea : retirées en mobile
     → Envoyer = bouton toolbar ; Régénérer = menu IA (Suggérer) ; Modifier = édition directe du champ */
  body.qm-detail-open #handoff-response-zone #copilot-inline-actions { display: none !important; }

  /* Zone input : padding propre */
  body.qm-detail-open #handoff-active-input { padding: 8px 12px !important; }

  /* Textarea : rectangulaire (peu d'arrondi), pas de gros padding droit (les actions passent en toolbar) */
  body.qm-detail-open #handoff-message-input {
    font-size: 15px !important;
    padding: 11px 14px !important;
    border-radius: 12px !important;
    border: 1px solid rgba(0,0,0,0.14) !important;
    background: #fff !important;
  }
  .dark body.qm-detail-open #handoff-message-input { border-color: rgba(255,255,255,0.16) !important; background: rgba(255,255,255,0.06) !important; }

  /* Le groupe de boutons inline (mic/IA/Envoyer) sort du textarea → barre d'outils sous le champ */
  body.qm-detail-open #handoff-active-input .absolute {
    position: static !important; margin-top: 8px !important;
    display: flex !important; align-items: center !important; gap: 8px !important;
    right: auto !important; bottom: auto !important;
  }
  /* Icônes toolbar : MÊME design que la réponse mail (.qec-sched) — 34px, radius 9, bordure, fond blanc translucide */
  body.qm-detail-open #handoff-active-input .absolute > button {
    width: 34px !important; height: 34px !important; padding: 0 !important;
    border-radius: 9px !important; border: 1px solid rgba(0,0,0,0.1) !important;
    background: rgba(255,255,255,0.6) !important; color: #444 !important;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px !important;
  }
  .dark body.qm-detail-open #handoff-active-input .absolute > button {
    background: rgba(255,255,255,0.06) !important; color: #bbb !important; border-color: rgba(255,255,255,0.12) !important;
  }
  /* Envoyer : identique à .qec-send du mail (radius 10, bg #000, sans bordure, fs 12/700, gap 6) */
  body.qm-detail-open #handoff-active-input .absolute > button:last-child {
    margin-left: auto !important; width: auto !important; padding: 0 16px !important; height: 34px !important;
    background: #000 !important; color: #fff !important; border: none !important; border-radius: 10px !important;
    font-size: 12px !important; font-weight: 700 !important; gap: 6px !important;
  }
  body.qm-detail-open #handoff-active-input .absolute > button:last-child i { margin-right: 6px !important; }
  .dark body.qm-detail-open #handoff-active-input .absolute > button:last-child { background: #fff !important; color: #000 !important; }

  /* Product search : masqué par défaut, révélé par le bouton 🛍️ (.qm-products-open) ; style mobile */
  body.qm-detail-open #handoff-response-zone .px-4.pt-2.pb-1 { display: none !important; }
  body.qm-detail-open.qm-products-open #handoff-response-zone .px-4.pt-2.pb-1 { display: block !important; padding: 8px 12px !important; }

  /* ── COMPOSER EMAIL (email-reply-zone) : collé en bas ── */
  body.qm-detail-open #email-reply-zone {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 200 !important;
    background: #fff !important;
    border-top: 0.5px solid rgba(0,0,0,0.1) !important;
    border-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    max-height: 55vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .dark body.qm-detail-open #email-reply-zone {
    background: #0a0a0a !important;
    border-top-color: rgba(255,255,255,0.1) !important;
  }
  /* Variante C : le reply-zone vit DANS la sheet .composer-col — l'absolute bottom ci-dessus
     (pensé pour l'ancien placement dans le fil) créait un TROU au milieu de la sheet.
     En sheet → flux normal, la sheet (max-height:85vh) gère le scroll. Validé Chrome 2026-07-17. */
  body.qm-detail-open .composer-col #email-reply-zone {
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* ── Indicateur "client écrit…" ── */
  body.qm-detail-open #customer-typing-indicator {
    flex-shrink: 0 !important;
    padding: 4px 14px !important;
  }

  /* ── Animation entrée bulles ── */
  @keyframes qmFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

} /* END @media (max-width: 768px) */

/* Dictée vocale (STT) — micro INTÉGRÉ aux barres composer (email .qec-mic, chat #handoff-mic-btn).
   État enregistrement = rouge + pulse. Écrit en direct dans la zone (interimResults). */
/* Rouge pendant l'enregistrement. Le SCALE + glow sont pilotés en JS (vu-mètre voix
   temps réel via _startMeter) → pas d'animation régulière (module avec l'amplitude). */
/* Générique : tout bouton de dictée (email .qec-mic, chat #handoff-mic-btn, et futurs via aria-label) */
.qec-mic.rec, #handoff-mic-btn.rec, [aria-label="Dictée vocale"].rec, .qm-mic.rec {
  background: #dc2626 !important; color: #fff !important;
  transition: transform 0.06s linear, box-shadow 0.06s linear;
}
