        /* ── Accessibilité (WCAG 2.1 AA) ───────────────────────────── */
        /* Texte visible uniquement par les lecteurs d'écran */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        /* Focus visible accessible (anneau visible au clavier) */
        :focus-visible {
            outline: 2px solid var(--accent-hover, #7b2cff);
            outline-offset: 2px;
        }
        /* Respect des préférences utilisateur de réduction de mouvement */
        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }
        }

        /* ── Reset & Variables ──────────────────────────────────────── */
        *,
        *::before,
        *::after {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        :root {
            /* ── Charte alignée sur le site vitrine (~/Documents/izia_vitrine/src/index.css) ──
               Décision Mehdi 2026-05-28 : identité de marque unifiée site ↔ app.
               - VERT (#19f05e) = CTA primaire (boutons d'action) — comme le vitrine.
               - VIOLET (#660ff2) = accent d'interface (focus, sélection, liens, badges).
               Le vert reste réservé aux actions pour éviter la surcharge visuelle. */
            --bg-primary: #0f0f1e;
            --bg-secondary: #16162a;
            --bg-tertiary: #2a2a40;
            --bg-input: #16162a;
            --section-bg: #43426b;
            /* Surfaces « légèrement au-dessus du fond » — trois intensités. Elles étaient
               écrites en dur en rgba(255,255,255,0.0X) à onze endroits : sur fond clair, du
               blanc translucide sur du blanc ne produit rien. `--surface-elevated` existait
               déjà ici, déclarée et jamais utilisée. */
            --surface-elevated: rgba(255, 255, 255, 0.03);
            --surface-hover: rgba(255, 255, 255, 0.06);
            --surface-sunken: rgba(255, 255, 255, 0.08);
            /* Surfaces translucides composées (dégradés) : elles portaient les valeurs de la
               palette SOMBRE recopiées littéralement, donc restaient noires en mode clair —
               panneau latéral, barre de saisie, cartes de suggestion. La translucidité fait
               partie du rendu (elles se superposent au contenu), d'où des dégradés complets
               en variables plutôt que des couleurs isolées. */
            --composer-bg: linear-gradient(180deg, rgba(22, 22, 42, 0.96), rgba(18, 18, 32, 0.96));
            --chat-bar-bg: linear-gradient(180deg, rgba(22, 22, 42, 0.84), rgba(22, 22, 42, 0.98));
            --card-bg: linear-gradient(180deg, rgba(42, 42, 64, 0.92), rgba(26, 26, 42, 0.96));
            --gate-bg: rgba(22, 22, 42, 0.82);
            --avatar-bot-bg: linear-gradient(135deg, #1e1e2a, #2a2a3e);
            /* Bleu d'information (badge multi-agent) : #93c5fd est lisible sur fond sombre
               et tombe à 1,64:1 sur clair. Même patron que --accent-text / --green-text. */
            --info-text: #93c5fd;
            /* Surface d'une carte posée sur la page. L'élévation ne se code pas de la même
               façon dans les deux thèmes : en sombre une surface surélevée S'ÉCLAIRCIT, en
               clair elle BLANCHIT sur une page légèrement grise. Employer `--bg-tertiary`
               des deux côtés donnait donc, en clair, des cartes plus FONCÉES que la page. */
            --surface-card: #2a2a40;
            /* Bulle du message utilisateur : une surface translucide, pas un aplat de marque,
               et la MÊME variable des deux côtés — c'est celle du champ de recherche des
               conversations, pris comme référence.
               Le violet à 80 % avait été essayé d'abord : sur un fond déjà très sombre, 80 %
               d'opacité d'un violet donne un violet à peine plus sombre (rgb(102,49,196) contre
               rgb(124,58,237)) — un changement réel mais invisible à l'œil.
               `--surface-hover` (6 %) plutôt que `--surface-elevated` (3 %) : mesuré, 3 % ne
               détache la bulle du fond qu'à 1,06:1, contre 1,14:1 à 6 % — soit la même présence
               qu'en clair (1,12:1). Une bulle qu'on ne distingue pas du fond fait perdre la
               structure de la conversation. */
            --user-bubble-bg: var(--surface-hover);
            --user-bubble-text: #ffffff;
            /* Survol d'un lien : `--green-hover` est fait pour un FOND de bouton et tombe à
               2,05:1 en texte sur fond clair. Un lien qui devient illisible au survol est pire
               qu'un lien terne — d'où cette variante, lisible des deux côtés. */
            --green-text-hover: #15cc4f;
            /* Alias historique employé 20 fois (bordures de séparation des connecteurs) et
               JAMAIS déclaré : `var(--border-color)` ne résolvait rien, donc ces bordures ne
               s'affichaient pas du tout — dans les deux thèmes. */
            --border-color: #2a2a40;
            --text-primary: #f0f2f5;
            --text-secondary: #b0b0c5;
            --text-muted: rgba(255, 255, 255, 0.77);
            /* Accent d'interface = violet (focus, sélection, liens, badges) */
            --accent: #660ff2;
            --accent-hover: #7b2cff;
            /* Violet lisible pour TEXTE/liens — WCAG AA ≥4.5 sur fonds sombres (#660ff2 échoue à 2.63) */
            --accent-text: #a78bfa;
            --accent-glow: rgba(102, 15, 242, 0.15);
            --accent-soft: rgba(123, 44, 255, 0.10);
            --purple: #660ff2;
            --periwinkle: #6b7fd7;
            --pale-cyan: #bcedf6;
            /* CTA primaire = vert (boutons d'action principaux) */
            --green: #19f05e;
            --green-hover: #15cc4f;
            /* Vert lisible pour TEXTE/liens — même patron que --accent-text : le vert de marque
               est fait pour être un FOND (texte #000 dessus, 11,7:1), pas une couleur de texte.
               Sur fond clair il tombe à 1,54:1. */
            --green-text: #19f05e;
            --success: #19f05e;
            --success-hover: #15cc4f;
            --warning: #fbbf24;
            --error: #f87171;
            --border: #2a2a40;
            --border-hover: #3a3a5a;
            /* Bordure translucide façon vitrine pour les surfaces glassmorphism (navbar) */
            --border-translucent: rgba(255, 255, 255, 0.18);
            --radius: 12px;
            --radius-sm: 8px;
            --radius-lg: 16px;
            --radius-full: 9999px;
            --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
            --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.15);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.12);
            --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
            --shadow-premium: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
            --navy: #292857;
            --navy-light: #393668;
            --navbar-bg: rgba(22, 22, 42, 0.88);
            --nav-height: 64px;
            --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
            --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
            --sidebar-width: 280px;
            /* Indique au NAVIGATEUR quels contrôles natifs dessiner : cases à cocher, boutons
               radio, listes déroulantes, ascenseurs, sélecteurs de date. Sans cette
               déclaration par thème, l'unique `<meta name="color-scheme" content="dark">` de
               la page les gardait sombres même en mode clair — des cases à cocher noires sur
               fond blanc. Une propriété CSS l'emporte sur la balise meta. */
            color-scheme: dark;
        }

        /* Pictogrammes line-art (lucide) — remplacent les emojis pour un rendu pro */
        .ic-svg {
            width: 1.05em;
            height: 1.05em;
            vertical-align: -0.16em;
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
            display: inline-block;
            flex-shrink: 0;
        }

        /* Pastille de statut colorée (remplace 🟢🔴🟡⚪⚫) */
        .ic-dot {
            width: 0.7em;
            height: 0.7em;
            vertical-align: 0.04em;
            display: inline-block;
            flex-shrink: 0;
        }

        html {
            font-size: 15px;
            scroll-behavior: smooth;
        }

        /* Les contrôles de formulaire n'héritent PAS de `font-family` : les navigateurs leur
           imposent leur propre police d'interface. Sans cette règle, `body` a beau porter
           Montserrat, chaque champ, bouton, liste déroulante et zone de texte s'affiche dans
           la police système — visible à l'œil dès qu'un libellé jouxte un champ.
           Seule la FAMILLE est héritée : reprendre `font: inherit` emporterait aussi la taille
           et casserait des dimensionnements de contrôles. Les blocs de code gardent
           `--font-mono`, leur règle étant plus spécifique. */
        input,
        button,
        select,
        textarea,
        optgroup {
            font-family: inherit;
        }

        body {
            font-family: var(--font-sans);
            background: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            min-height: 100dvh;
            height: 100vh;
            height: 100dvh;
            display: flex;
            overflow: hidden;
        }

        body.sidebar-open {
            overflow: hidden;
            touch-action: none;
        }

        button:focus-visible,
        select:focus-visible,
        input:focus-visible,
        a:focus-visible {
            outline: 2px solid var(--accent-hover, #7b2cff); /* WCAG 1.4.11 : l'alpha 0.65 tombait à 2,03:1 (seuil 3:1) */
            outline-offset: 2px;
        }

        textarea:focus-visible {
            outline: none;
        }

        /* ══════════════════════════════════════════════════════════
           SIDEBAR
        ══════════════════════════════════════════════════════════ */
        .sidebar {
            width: var(--sidebar-width);
            min-width: var(--sidebar-width);
            /* Les deux teintes étaient les valeurs SOMBRES recopiées littéralement
               (#16162a et #0f0f1e) : le panneau restait noir en mode clair. */
            background: linear-gradient(180deg, var(--bg-secondary), var(--bg-primary));
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
            transition: transform var(--transition);
            z-index: 100;
        }

        .sidebar-backdrop {
            position: fixed;
            inset: 0;
            background: rgba(3, 6, 18, 0.58);
            backdrop-filter: blur(2px);
            opacity: 0;
            pointer-events: none;
            transition: opacity var(--transition);
            z-index: 90;
        }

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

        .sidebar-header {
            padding: 14px 16px;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 2px;
        }

        .logo-icon {
            width: 36px;
            height: 36px;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            overflow: hidden;
        }

        .logo-icon img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: var(--radius-sm);
        }

        .logo-text {
            font-size: 1rem;
            font-weight: 700;
            letter-spacing: -0.02em;
        }

        .logo-sub {
            font-size: 0.68rem;
            color: var(--text-muted);
        }

        /* ── Navigation principale ──────────────────────────────── */
        .sidebar-nav {
            padding: 10px 10px 0;
            flex-shrink: 0;
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            padding: 9px 12px;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-secondary);
            font-size: 0.84rem;
            font-weight: 500;
            cursor: pointer;
            transition: all var(--transition);
            text-align: left;
            margin-bottom: 2px;
        }

        .nav-item:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
            transform: translateX(2px);
        }

        /* Page active mise en avant par un simple contour (choix Mehdi) */
        .nav-item.active {
            background: transparent;
            color: var(--accent-text);
            border: 1px solid var(--accent-hover);
        }

        .nav-item.active:hover {
            background: var(--accent-soft);
        }

        .nav-item .nav-icon {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }

        .nav-item .nav-icon svg {
            width: 16px !important;
            height: 16px !important;
            max-width: 16px;
            max-height: 16px;
            stroke: currentColor;
            transition: stroke var(--transition);
            flex-shrink: 0;
        }

        .nav-item.active .nav-icon svg {
            stroke: #cbb2ff;
        }

        .nav-badge {
            margin-left: auto;
            font-size: 0.68rem;
            background: var(--green-hover);
            color: #2a2a40;
            padding: 1px 6px;
            border-radius: 10px;
            font-weight: 600;
        }

        /* Compteur de fichiers indexés = information, pas une notification :
           pas de pastille colorée (évite la confusion avec un badge de notif) */
        #files-badge {
            background: transparent;
            color: var(--text-muted);
            padding: 0;
            font-size: 0.72rem;
        }

        /* ── Séparateur ─────────────────────────────────────────── */
        .sidebar-sep {
            height: 1px;
            background: var(--border);
            margin: 10px 10px;
            flex-shrink: 0;
        }

        /* ── Login Gate (plein écran quand non connecté) ───────── */
        .login-gate {
            position: fixed;
            inset: 0;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-primary);
            overflow: hidden;
        }

        /* Animated orbs background */
        .login-gate::before {
            content: '';
            position: absolute;
            inset: 0;
            background:
                radial-gradient(ellipse 70% 60% at 15% 25%, rgba(102, 15, 242, 0.22) 0%, transparent 55%),
                radial-gradient(ellipse 55% 65% at 85% 75%, rgba(123, 44, 255, 0.16) 0%, transparent 55%),
                radial-gradient(ellipse 45% 45% at 55% 5%, rgba(168, 100, 255, 0.1) 0%, transparent 60%),
                radial-gradient(ellipse 40% 50% at 90% 20%, rgba(80, 200, 255, 0.06) 0%, transparent 55%);
            animation: loginOrbShift 10s ease-in-out infinite alternate;
            pointer-events: none;
        }

        @keyframes loginOrbShift {
            0%   { transform: scale(1) rotate(0deg); opacity: 0.8; }
            50%  { opacity: 1; }
            100% { transform: scale(1.08) rotate(3deg); opacity: 0.85; }
        }

        /* Fine noise texture overlay */
        .login-gate::after {
            content: '';
            position: absolute;
            inset: 0;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
            pointer-events: none;
            opacity: 0.4;
        }

        .login-gate.hidden,
        html.noryzia-auth .login-gate {
            display: none;
        }

        .login-gate-box {
            position: relative;
            z-index: 1;
            width: 400px;
            max-width: 92vw;
            background: var(--gate-bg);
            backdrop-filter: blur(28px) saturate(1.6);
            -webkit-backdrop-filter: blur(28px) saturate(1.6);
            border: 1px solid var(--border);
            border-radius: 20px;
            padding: 40px 36px 32px;
            box-shadow:
                0 0 0 1px rgba(102, 15, 242, 0.14),
                0 32px 80px -16px rgba(0, 0, 0, 0.65),
                0 8px 24px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
            text-align: center;
        }

        .login-gate-box .logo-lg {
            height: 48px;
            margin: 0 auto 20px;
            display: block;
        }

        .login-gate-box h2 {
            margin-bottom: 8px;
            font-size: 1.3rem;
            color: var(--text-primary);
        }

        .login-gate-box p {
            margin-bottom: 20px;
            font-size: 0.88rem;
            color: var(--text-secondary);
        }

        .login-gate-box .modal-field {
            width: 100%;
            margin-bottom: 10px;
        }

        .login-gate-box .btn-primary {
            width: 100%;
            margin-top: 6px;
        }

        .login-gate-box .gate-switch {
            margin-top: 14px;
            font-size: 0.82rem;
            color: var(--text-muted);
        }

        .login-gate-box .gate-switch a {
            color: var(--accent-text);
            cursor: pointer;
            text-decoration: underline;
        }

        .login-gate-box .gate-error {
            color: var(--error);
            font-size: 0.82rem;
            margin-bottom: 10px;
            min-height: 1.2em;
        }

        .gate-forgot-link {
            display: block;
            text-align: right;
            font-size: 0.78rem;
            color: var(--text-muted);
            cursor: pointer;
            margin: -4px 0 8px;
            text-decoration: underline;
        }
        .gate-forgot-link:hover { color: var(--accent-text); }

        /* Lien placé SOUS le bouton : la marge négative de .gate-forgot-link (pensée pour un lien
           au-dessus du bouton) le faisait chevaucher « Se connecter ». */
        .gate-forgot-link.gate-lien-sous-bouton {
            text-align: center;
            margin: 12px 0 0;
        }

        .gate-sso { margin-top: 16px; }
        .gate-sso[hidden], .gate-sso-btn[hidden] { display: none; }

        .gate-separateur {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
            font-size: 0.8rem;
            color: var(--text-muted);
        }
        .gate-separateur::before,
        .gate-separateur::after {
            content: "";
            flex: 1;
            height: 1px;
            background: var(--border);
        }

        .login-gate-box .gate-sso-btn {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        .login-gate-box .gate-sso-btn + .gate-sso-btn { margin-top: 8px; }

        .gate-success {
            color: var(--success);
            font-size: 0.82rem;
            margin-bottom: 10px;
            min-height: 1.2em;
        }

        .verify-code-input {
            font-size: 1.8rem;
            font-weight: 700;
            letter-spacing: 0.5rem;
            text-align: center;
            width: 100%;
            padding: 14px 8px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--accent-text);
        }
        .verify-code-input:focus { border-color: var(--accent); outline: none; }

        /* ── Auth / User bar ────────────────────────────────────── */
        .auth-bar {
            padding: 10px;
            display: flex;
            gap: 6px;
            flex-shrink: 0;
        }

        .auth-bar .btn-auth {
            flex: 1;
            padding: 7px 0;
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
            background: var(--bg-tertiary);
            color: var(--text-primary);
            font-size: 0.78rem;
            cursor: pointer;
            transition: all var(--transition);
        }

        .auth-bar .btn-auth:hover {
            border-color: var(--accent);
        }

        .auth-bar .btn-auth.primary {
            background: var(--green);
            border-color: var(--green-text);
            color: #000;
            font-weight: 600;
        }

        .auth-bar .btn-auth.primary:hover {
            background: var(--green-hover);
            border-color: var(--green-hover);
        }

        .user-bar {
            padding: 8px 10px;
            position: relative;
            flex-shrink: 0;
        }

        .user-menu-trigger {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            background: none;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            cursor: pointer;
            padding: 5px 7px;
            color: var(--text-primary);
            transition: background var(--transition), border-color var(--transition);
            font-size: 0.82rem;
            text-align: left;
        }

        .user-menu-trigger:hover,
        .user-menu-trigger[aria-expanded="true"] {
            background: var(--bg-hover, rgba(255,255,255,0.06));
            border-color: var(--border);
        }

        .user-avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            /* Pastille de profil en vert de marque (demande Mehdi, 2026-09-09). L'initiale
               passe du blanc au gris de charte : sur ce vert, le blanc tombe à 2,05:1 —
               illisible — quand `#2a2a40` tient 6,8:1. C'est la même teinte que le texte
               courant et que le `fill` de `logo-noir.svg`. */
            background: var(--green-hover);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.72rem;
            color: white;
            font-weight: 700;
            flex-shrink: 0;
        }

        .user-menu-info {
            flex: 1;
            min-width: 0;
            overflow: hidden;
        }

        .user-name {
            font-weight: 600;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .user-status {
            font-size: 0.65rem;
            color: var(--text-muted);
        }

        /* P5 — Badge plan tarifaire */
        .plan-badge {
            display: inline-block;
            font-size: 0.6rem;
            font-weight: 700;
            text-transform: uppercase;
            padding: 2px 6px;
            border-radius: 4px;
            margin-left: 4px;
            letter-spacing: 0.05em;
            vertical-align: middle;
        }
        .plan-badge--free       { background:#3f3f46; color:#e2e8f0; }
        .plan-badge--essentiel  { background:#0ea5e9; color:#fff; }
        .plan-badge--business   { background:#7b2cff; color:#fff; }
        .plan-badge--pro        { background:#f59e0b; color:#1f1700; }
        .plan-badge--citadelle { background:linear-gradient(135deg,#facc15,#f43f5e); color:#fff; }

        /* P5 — Bloc quota tokens dans le dropdown user */
        .user-quota-block {
            padding: 10px 12px;
            font-size: 0.7rem;
            color: var(--text-muted);
            border-bottom: 1px solid var(--border);
        }
        .user-quota-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 4px;
        }
        .user-quota-row strong {
            color: var(--text-primary);
            font-weight: 600;
        }
        .user-quota-bar {
            height: 4px;
            background: var(--surface-sunken);
            border-radius: 2px;
            overflow: hidden;
            margin-top: 2px;
        }
        .user-quota-bar > span {
            display: block;
            height: 100%;
            background: var(--accent, #7b2cff);
            transition: width 0.3s ease, background 0.3s ease;
        }
        .user-quota-bar > span.warn   { background: #f59e0b; }
        .user-quota-bar > span.danger { background: #ef4444; }

        .files-capacity {
            margin: 0 0 14px;
            padding: 10px 12px;
            background: var(--surface-2, rgba(127,127,127,0.06));
            border: 1px solid var(--border);
            border-radius: var(--radius-sm, 8px);
            font-size: 0.78rem;
            color: var(--text-muted);
        }
        .files-capacity-row {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 6px 10px;
            flex-wrap: wrap;
            margin-bottom: 6px;
        }
        .files-capacity-row strong { color: var(--text-primary); font-weight: 600; margin-left: auto; }
        .files-capacity-row .storage-details-toggle { flex-shrink: 0; }
        .files-capacity .user-quota-bar { height: 6px; background: var(--border); }

        /* ── Panneau de répartition du stockage (Phase 1) ─────────────── */
        .btn-link.storage-details-toggle {
            background: none;
            border: none;
            color: var(--accent-text, #a78bfa);
            font-size: 0.74rem;
            cursor: pointer;
            padding: 0 0 0 12px;
            text-decoration: underline;
        }
        .btn-link.storage-details-toggle:hover { color: var(--accent-hover, #7b2cff); }
        .btn-link.storage-details-toggle:focus-visible { outline: 2px solid var(--accent-hover, #7b2cff); outline-offset: 2px; border-radius: 3px; }

        .storage-panel {
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid var(--border);
            /* Borne la hauteur : le panneau scrolle en interne au lieu d'écraser
               la liste de fichiers. Plafond absolu pour laisser de la place sur
               les grands écrans aussi. */
            max-height: min(38vh, 360px);
            overflow-y: auto;
        }
        .storage-panel-loading { color: var(--text-muted); font-size: 0.76rem; padding: 6px 0; }
        .storage-panel-grid {
            display: flex;
            gap: 18px;
            align-items: center;
            flex-wrap: wrap;
        }
        .storage-donut-wrap { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
        .storage-donut {
            width: 108px; height: 108px; border-radius: 50%;
            background: var(--border);
            /* le conic-gradient est injecté inline en JS */
            -webkit-mask: radial-gradient(circle 33px at center, transparent 98%, #000 100%);
                    mask: radial-gradient(circle 33px at center, transparent 98%, #000 100%);
        }
        .storage-donut-center {
            position: absolute; inset: 0;
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            pointer-events: none; text-align: center;
        }
        .storage-donut-center strong { color: var(--text-primary); font-size: 0.82rem; }
        .storage-donut-center span { color: var(--text-muted); font-size: 0.62rem; }

        .storage-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; }
        .storage-legend li {
            display: flex; align-items: center; gap: 8px;
            font-size: 0.74rem; padding: 3px 0;
        }
        .storage-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
        .storage-legend .lg-name { color: var(--text-primary); text-transform: capitalize; }
        .storage-legend .lg-size { margin-left: auto; color: var(--text-muted); }

        .storage-index-line {
            margin-top: 10px; padding: 7px 10px;
            background: var(--accent-soft, rgba(123,44,255,0.10));
            border-radius: 6px; font-size: 0.73rem; color: var(--text-muted);
        }
        .storage-index-line strong { color: var(--text-primary); }

        .storage-age { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
        .storage-age .age-chip {
            flex: 1; min-width: 88px;
            background: var(--surface-2, rgba(127,127,127,0.06));
            border: 1px solid var(--border); border-radius: 6px;
            padding: 6px 8px; font-size: 0.7rem; color: var(--text-muted);
        }
        .storage-age .age-chip strong { display: block; color: var(--text-primary); font-size: 0.82rem; }

        .storage-top { margin-top: 12px; }
        .storage-top-title { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .03em; }
        .storage-top-list { list-style: none; margin: 0; padding: 0; }
        .storage-top-list li {
            display: flex; align-items: center; gap: 8px;
            font-size: 0.74rem; padding: 3px 0; color: var(--text-primary);
        }
        .storage-top-list .tf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .storage-top-list .tf-size { margin-left: auto; color: var(--text-muted); flex-shrink: 0; }

        .storage-cleanup { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
        .storage-cleanup-result { margin-top: 10px; font-size: 0.74rem; color: var(--text-muted); }
        .cleanup-summary { color: var(--text-primary); margin-bottom: 6px; }
        .cleanup-row {
            display: flex; align-items: center; justify-content: space-between; gap: 10px;
            margin: 4px 0; flex-wrap: wrap;
        }
        .cleanup-list { list-style: none; margin: 4px 0 8px; padding: 0; }
        .cleanup-list li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
        .cleanup-note { color: var(--text-muted); margin: 3px 0; }

        @media (max-width: 640px) {
            .storage-panel-grid { justify-content: center; }
            .storage-legend { min-width: 100%; }
            /* Écran court : panneau plus compact pour préserver la liste. */
            .storage-panel { max-height: 46vh; }
        }

        .user-menu-chevron {
            font-size: 0.65rem;
            color: var(--text-muted);
            transition: transform 0.15s ease;
            flex-shrink: 0;
        }

        .user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
            transform: rotate(180deg);
        }

        .user-dropdown {
            position: absolute;
            top: calc(100% - 2px);
            left: 10px;
            right: 10px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: 0 8px 24px rgba(0,0,0,0.35);
            z-index: 500;
            overflow: hidden;
            padding: 4px 0;
        }

        .user-dropdown[hidden] { display: none; }

        .user-dropdown-item {
            display: flex;
            align-items: center;
            gap: 9px;
            width: 100%;
            padding: 8px 14px;
            background: none;
            border: none;
            color: var(--text-primary);
            font-size: 0.82rem;
            cursor: pointer;
            text-decoration: none;
            transition: background var(--transition);
            text-align: left;
            box-sizing: border-box;
        }

        .user-dropdown-item svg {
            flex-shrink: 0;
            opacity: 0.7;
        }

        .user-dropdown-item:hover svg { opacity: 1; }

        .user-dropdown-item:hover {
            background: var(--bg-hover, rgba(255,255,255,0.06));
        }

        .user-dropdown-item--danger { color: var(--error, #e05252); }
        .user-dropdown-item--accent { color: var(--accent-text); }

        .user-dropdown-sep {
            border: none;
            border-top: 1px solid var(--border);
            margin: 4px 0;
        }

        /* ── Sidebar chat (conversations) ───────────────────────── */
        .sidebar-chat-section {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 8px 10px;
            min-height: 0;
        }

        /* Le label, le bouton "Nouvelle discussion" et la recherche restent figés ;
           seule la liste des conversations défile. */
        .sidebar-chat-section > .section-label,
        .sidebar-chat-section > .btn-new-chat,
        .sidebar-chat-section > .conv-search-wrap {
            flex-shrink: 0;
        }

        #conv-list {
            flex: 1;
            overflow-y: auto;
            min-height: 0;
        }

        .section-label {
            font-size: 0.66rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-muted);
            font-weight: 600;
            padding: 4px 4px 8px;
        }

        .conv-search-wrap {
            position: relative;
            margin-bottom: 8px;
        }

        .conv-search-input {
            width: 100%;
            padding: 7px 26px 7px 30px;
            background: var(--surface-hover);
            border: 1px solid transparent;
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 0.78rem;
            outline: none;
            box-sizing: border-box;
            transition: border-color var(--transition), background var(--transition);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: 9px center;
        }

        .conv-search-input:hover {
            background-color: var(--surface-sunken);
            border-color: var(--border-hover);
        }

        .conv-search-input:focus {
            border-color: var(--accent);
            background-color: rgba(102, 15, 242, 0.06);
        }

        .conv-search-input::placeholder {
            color: var(--text-muted);
        }

        .conv-search-input::-webkit-search-cancel-button {
            -webkit-appearance: none;
            display: none;
        }

        .conv-search-clear {
            position: absolute;
            right: 8px;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.7rem;
            padding: 2px 4px;
            line-height: 1;
            display: none;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: color var(--transition);
        }

        .conv-search-clear:hover {
            color: var(--text-primary);
        }

        .search-highlight {
            background: rgba(102, 15, 242, 0.25);
            color: var(--text-primary);
            border-radius: 2px;
            padding: 0 1px;
            font-style: normal;
        }

        .conv-empty-search {
            font-size: 0.75rem;
            color: var(--text-muted);
            text-align: center;
            padding: 16px 8px;
        }

        .btn-new-chat {
            width: 100%;
            padding: 10px 12px;
            background: var(--green-hover);
            color: #2a2a40;
            border: none;
            border-radius: var(--radius-full);
            font-size: 0.82rem;
            font-weight: 700;
            cursor: pointer;
            transition: all var(--transition);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 7px;
            margin-bottom: 10px;
            box-shadow: 0 10px 24px rgba(25, 240, 94, 0.22);
        }

        .btn-new-chat:hover {
            background: var(--green);
            transform: translateY(-1px);
            box-shadow: 0 12px 28px rgba(25, 240, 94, 0.3);
        }

        .conv-item {
            padding: 9px 10px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            border: 1px solid transparent;
            transition: all var(--transition);
            margin-bottom: 4px;
            position: relative;
        }

        .conv-item:hover {
            background: var(--surface-elevated);
            border-color: var(--border);
            transform: translateY(-1px);
        }

        .conv-item.active {
            background: linear-gradient(90deg, rgba(102, 15, 242, 0.12), rgba(102, 15, 242, 0.04));
            border-color: rgba(108, 99, 255, 0.24);
            box-shadow: inset 2px 0 0 var(--accent);
        }

        .conv-title {
            font-size: 0.8rem;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-right: 22px;
        }

        .conv-meta {
            font-size: 0.68rem;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .conv-del {
            position: absolute;
            top: 6px;
            right: 6px;
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.78rem;
            padding: 2px 4px;
            border-radius: 4px;
            opacity: 0;
            transition: opacity var(--transition), color var(--transition);
        }

        .conv-item:hover .conv-del,
        .conv-item:hover .conv-share {
            opacity: 1;
        }

        .conv-del:hover {
            color: var(--error);
        }

        .conv-share {
            position: absolute;
            top: 6px;
            right: 28px;
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-muted);
            font-size: 0.82rem;
            padding: 2px 4px;
            border-radius: 4px;
            opacity: 0;
            transition: opacity var(--transition), color var(--transition);
        }

        .conv-share:hover {
            color: var(--accent-text);
        }

        /* ── Sidebar status (mini) ──────────────────────────────── */
        .sidebar-status {
            padding: 12px 10px 12px;
            flex-shrink: 0;
            border-top: 1px solid var(--border);
        }

        .sidebar-version {
            /* La séparation border-top a été retirée avec les status-rows :
               la version est maintenant seule dans .sidebar-status, pas besoin
               de border-top intermédiaire (le container porte déjà sa propre
               border-top en haut). */
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
            font-size: 0.66rem;
            color: var(--text-muted);
            opacity: 0.75;
            user-select: text;
            cursor: help;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .sidebar-version:hover {
            opacity: 1;
            color: var(--text-secondary);
        }

        .sidebar-controls {
            padding: 0 10px 10px;
            flex-shrink: 0;
        }

        .sidebar-control-card {
            padding: 10px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
        }

        .sidebar-control-label {
            display: block;
            font-size: 0.72rem;
            color: var(--text-secondary);
            line-height: 1.45;
            margin-bottom: 8px;
        }

        .sidebar-select {
            width: 100%;
            max-width: none;
            border: 1px solid var(--border);
        }

        .sidebar-select:focus {
            border-color: var(--accent);
            color: var(--text-primary);
        }

        .status-row {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.72rem;
            color: var(--text-muted);
            margin-bottom: 4px;
        }

        .status-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            flex-shrink: 0;
            animation: pulse-dot 2s ease-in-out infinite;
        }

        .status-dot.ok {
            background: var(--success);
        }

        .status-dot.warn {
            background: var(--warning);
            animation: none;
        }

        .status-dot.err {
            background: var(--error);
            animation: none;
        }

        @keyframes pulse-dot {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.4;
            }
        }

        /* ══════════════════════════════════════════════════════════
           MAIN CONTENT — PAGES
        ══════════════════════════════════════════════════════════ */
        .main {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        .page {
            display: none;
            flex: 1;
            flex-direction: column;
            overflow: hidden;
        }

        .page.active {
            display: flex;
        }

        /* ── Page header commun ─────────────────────────────────── */
        .page-header {
            padding: 10px 28px;
            min-height: var(--nav-height);
            border-bottom: 1px solid var(--border-translucent);
            flex-shrink: 0;
            background: var(--navbar-bg);
            -webkit-backdrop-filter: blur(20px);
            backdrop-filter: blur(20px);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .page-title {
            font-size: 1rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .page-subtitle {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .page-header-meta {
            min-width: 0;
        }

        /* Header de la page chat : épuré — uniquement les actions (Exporter /
           Réinitialiser), alignées à droite (plus de titre ni badge modèle). */
        .page-header-chat {
            justify-content: flex-end;
        }

        /* Logo de marque dans le header — affiché en mobile à la place du titre texte */
        .page-title-logo {
            display: none;
            height: 30px;
            width: auto;
        }

        .page-header-actions {
            display: flex;
            gap: 8px;
            align-items: center;
            justify-content: flex-end;
            flex-wrap: wrap;
        }

        #chat-model-badge {
            white-space: nowrap;
        }

        /* ══════════════════════════════════════════════════════════
           PAGE : CHAT
        ══════════════════════════════════════════════════════════ */
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px;
            display: flex;
            flex-direction: column;
            gap: 16px;
            background:
                radial-gradient(ellipse 80% 50% at 50% -10%, rgba(102, 15, 242, 0.09) 0%, transparent 60%),
                radial-gradient(ellipse 50% 40% at 90% 80%, rgba(123, 44, 255, 0.05) 0%, transparent 60%),
                var(--bg-primary);
        }

        /* Bienvenue */
        .welcome {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            text-align: center;
            padding: 40px;
            gap: 14px;
            color: var(--text-muted);
        }

        .welcome-logo-wrap {
            position: relative;
            width: 72px;
            height: 72px;
            margin-bottom: 4px;
        }

        .welcome-logo {
            /* Le pictogramme est un ROND blanc sur transparence. Le cadre carré venait de
               l'habillage : une `box-shadow` épouse la BOÎTE, pas la silhouette — appliquée
               à un carré de 72×72 arrondi à 18px, elle dessinait un carré arrondi derrière
               un logo rond. `border-radius` et `box-shadow` sont donc retirés tous les deux ;
               le halo `.welcome-logo-glow`, lui, est circulaire et suit la forme. */
            width: 72px;
            height: 72px;
            position: relative;
            z-index: 1;
        }

        .welcome-logo-glow {
            position: absolute;
            inset: -8px;
            background: radial-gradient(circle, rgba(102, 15, 242, 0.28) 0%, transparent 70%);
            border-radius: 50%;
            animation: logoGlow 3s ease-in-out infinite alternate;
            z-index: 0;
        }

        @keyframes logoGlow {
            from { opacity: 0.6; transform: scale(0.95); }
            to   { opacity: 1;   transform: scale(1.05); }
        }

        .welcome h2 {
            font-size: 1.35rem;
            font-weight: 700;
            background: linear-gradient(135deg, var(--text-primary) 0%, #cbb2ff 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .welcome p {
            font-size: 0.85rem;
            max-width: 400px;
            line-height: 1.65;
            color: var(--text-secondary);
        }

        .welcome-chips {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: -2px;
        }

        .welcome-chip {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            background: rgba(102, 15, 242, 0.1);
            border: 1px solid rgba(102, 15, 242, 0.22);
            border-radius: 20px;
            font-size: 0.72rem;
            color: var(--accent-text);
            font-weight: 500;
        }

        .welcome-chip svg {
            opacity: 0.8;
        }

        /* Messages */
        /* Colonne de conversation centrée (style ChatGPT/Gemini) : question ET réponse
           vivent dans une même colonne centrée ; la question s'aligne à droite de la
           colonne (row-reverse), la réponse occupe toute la largeur de la colonne. */
        .message {
            display: flex;
            gap: 12px;
            width: 100%;
            max-width: 820px;
            align-self: center;
            animation: fadeInUp 0.2s ease;
        }

        .message.user {
            flex-direction: row-reverse;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(8px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .msg-avatar {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            font-weight: 700;
        }

        .message.user .msg-avatar {
            /* Pastille de profil en vert de marque (demande Mehdi, 2026-09-09). L'initiale
               passe du blanc au gris de charte : sur ce vert, le blanc tombe à 2,05:1 —
               illisible — quand `#2a2a40` tient 6,8:1. C'est la même teinte que le texte
               courant et que le `fill` de `logo-noir.svg`. */
            background: var(--green-hover);
            color: white;
        }

        .message.assistant .msg-avatar {
            background: var(--avatar-bot-bg);
            border: 1px solid var(--border);
            font-size: 0.9rem;
        }

        .msg-bubble {
            padding: 13px 16px;
            border-radius: var(--radius);
            font-size: 0.875rem;
            line-height: 1.68;
            max-width: 680px;
            box-shadow: none;
            /* Containment horizontal : une chaîne insécable (adresse email, URL,
               token) ne doit jamais élargir la bulle au-delà de l'écran. Critique
               sur mobile et pour les réponses EMAIL_SEARCH (From/sujets longs). */
            min-width: 0;
            overflow-wrap: anywhere;
        }

        /* Le wrapper flex (frère de .msg-avatar) doit pouvoir rétrécir, sinon
           overflow-x:auto sur <pre>/<table> n'engage pas et la bulle déborde. */
        .message > div:not(.msg-avatar) {
            min-width: 0;
            max-width: 100%;
        }

        /* Tableaux markdown : scroll horizontal interne au lieu de déborder. */
        .msg-bubble table {
            display: block;
            max-width: 100%;
            overflow-x: auto;
        }

        .message.user .msg-bubble {
            background: var(--user-bubble-bg);
            color: var(--user-bubble-text);
            border-bottom-right-radius: 4px;
            position: relative;
            /* Sans ombre (choix Mehdi, 2026-09-09) : la bulle se distingue par son fond, pas
               par un relief. L'ombre violette dessinait par ailleurs un halo carré autour
               d'une bulle arrondie, très visible sur fond clair. */
            box-shadow: none;
            /* Préserve newlines + espaces multiples saisis par l'utilisateur sans
               injecter de <br> côté JS. pre-wrap respecte aussi le word-wrap, donc
               les longues lignes se cassent normalement. Ciblé user uniquement —
               côté assistant, le rendu HTML markdown gère déjà les paragraphes. */
            white-space: pre-wrap;
            overflow-wrap: anywhere;
        }

        /* Boutons actions message utilisateur — dans le msg-meta, pas en absolu */
        .btn-copy-prompt,
        .btn-edit-msg {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-muted);
            opacity: 0;
            transition: opacity 0.15s, color 0.15s;
            padding: 3px 4px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            flex-shrink: 0;
        }

        .message.user:hover .btn-copy-prompt,
        .message.user:hover .btn-edit-msg {
            opacity: 0.6;
        }

        .btn-copy-prompt:hover,
        .btn-edit-msg:hover {
            opacity: 1 !important;
            color: var(--accent-text);
        }

        .msg-meta-user {
            justify-content: flex-end;
            flex-wrap: nowrap;
        }

        .btn-copy-prompt svg,
        .btn-edit-msg svg,
        .btn-copy-code svg {
            width: 13px;
            height: 13px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .btn-retry-msg {
            background: none;
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 4px 10px;
            cursor: pointer;
            font-size: 0.75rem;
            color: var(--text-muted);
            transition: all var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 4px;
            margin-top: 6px;
        }

        .btn-retry-msg:hover {
            border-color: var(--accent);
            color: var(--accent-text);
            background: rgba(108, 99, 255, 0.08);
        }

        .btn-retry-msg svg {
            width: 13px;
            height: 13px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* Réponse sans bulle (style ChatGPT/Gemini) : pleine largeur de lecture,
           pas de fond/bordure/ombre. La question utilisateur garde sa bulle. */
        .message.assistant .msg-bubble {
            background: none;
            color: var(--text-primary);
            border: none;
            box-shadow: none;
            padding: 2px 0 0;
            max-width: none;
        }

        .msg-bubble code {
            font-family: var(--font-mono);
            background: rgba(0, 0, 0, 0.3);
            padding: 1px 5px;
            border-radius: 4px;
            font-size: 0.82em;
        }

        /* Liens dans les réponses LLM — visibles, accessibles, sans casser le contraste */
        .msg-bubble a {
            /* Vert de marque (demande Mehdi). `--green-text` et non `--green-hover` : ce
               dernier vaut #13d151 en clair, soit 2,05:1 sur fond blanc — illisible. Même
               couleur de marque, déclinée pour rester lisible sur les deux fonds (5,46:1 en
               clair, 12,34:1 en sombre), sur le patron déjà en place pour `--accent-text`. */
            color: var(--green-text);
            text-decoration: underline;
            text-underline-offset: 2px;
            text-decoration-thickness: 1px;
            word-break: break-word;
        }
        .msg-bubble a:hover { color: var(--green-text-hover); text-decoration-thickness: 2px; }
        .msg-bubble a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
        /* Côté user (bulle accent foncée) — garder le lien lisible sur fond coloré */
        .message.user .msg-bubble a { color: var(--user-bubble-text); text-decoration-color: currentColor; }
        .message.user .msg-bubble a:hover { text-decoration-thickness: 2px; }

        /* Wrapper positionnel pour les blocs de code (header + pre) */
        .code-block-wrap {
            position: relative;
            margin: 12px 0;
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            font-size: 0.8em;
        }

        .code-block-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 4px 10px;
            background: #161620;
            border-bottom: 1px solid var(--border);
        }

        .code-lang-label {
            font-family: var(--font-mono);
            font-size: 0.75em;
            color: var(--text-muted);
            text-transform: lowercase;
        }

        .btn-copy-code {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 0.75em;
            color: var(--text-muted);
            padding: 2px 6px;
            border-radius: 4px;
            transition: color var(--transition);
        }

        .btn-copy-code:hover {
            color: var(--accent-text);
        }

        .code-block-wrap pre {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin: 0;
            padding: 14px 16px;
            font-size: 0.82rem;
            line-height: 1.6;
        }

        .code-block-wrap pre code {
            white-space: pre;
            word-break: normal;
            overflow-wrap: normal;
            background: none;
            padding: 0;
            font-family: var(--font-mono, 'Fira Code', monospace);
        }

        .msg-bubble pre {
            background: #0d0d14;
            margin: 0;
            overflow-x: auto;
            max-width: 100%;
            line-height: 1.5;
        }

        .msg-bubble pre code.hljs {
            background: #0d0d14 !important;
            padding: 12px 14px !important;
            font-family: var(--font-mono) !important;
            font-size: 1em !important;
            border-radius: 0 !important;
        }

        .msg-bubble pre code {
            background: transparent;
            padding: 0;
            white-space: pre;
            word-break: normal;
            overflow-wrap: normal;
        }

        /* Curseur clignotant pendant le streaming */
        .streaming-bubble::after {
            content: '▋';
            display: inline-block;
            animation: blink-cursor 0.8s step-end infinite;
            color: var(--accent-text);
            margin-left: 1px;
        }

        @keyframes blink-cursor {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0;
            }
        }

        /* Disclaimer LLM libre */
        .msg-bubble .llm-disclaimer {
            display: block;
            margin-top: 10px;
            padding: 8px 10px;
            background: rgba(251, 191, 36, 0.08);
            border: 1px solid rgba(251, 191, 36, 0.25);
            border-radius: var(--radius-sm);
            font-size: 0.76rem;
            color: var(--warning);
            line-height: 1.5;
        }

        /* Metadata message */
        .msg-meta {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 5px;
            display: flex;
            gap: 10px;
            align-items: center;
            flex-wrap: wrap;
        }

        .msg-badge {
            padding: 2px 7px;
            border-radius: 10px;
            font-size: 0.68rem;
            font-weight: 600;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
        }

        .msg-badge.factual {
            background: rgba(52, 211, 153, 0.1);
            color: var(--success);
            border-color: rgba(52, 211, 153, 0.2);
        }

        /* Badge périmètre fichiers (réponse limitée à N fichiers) */
        .msg-badge.scope-badge {
            background: var(--accent-soft);
            color: var(--accent);
            border-color: var(--accent);
        }

        .msg-badge.general {
            background: rgba(108, 99, 255, 0.1);
            color: var(--accent-text);
            border-color: rgba(108, 99, 255, 0.2);
        }

        .msg-badge.code_gen {
            background: rgba(251, 191, 36, 0.1);
            color: var(--warning);
            border-color: rgba(251, 191, 36, 0.2);
        }

        .msg-badge.translation {
            background: rgba(129, 140, 248, 0.1);
            color: var(--accent-text);
            border-color: rgba(129, 140, 248, 0.2);
        }

        .msg-badge.model {
            background: rgba(108, 99, 255, 0.08);
            color: var(--text-secondary);
            border-color: rgba(108, 99, 255, 0.15);
            font-family: var(--font-mono);
            font-size: 0.66rem;
        }

        .msg-badge.search-engine {
            background: rgba(251, 146, 60, 0.1);
            color: var(--warning);
            border-color: rgba(251, 146, 60, 0.2);
            font-family: var(--font-mono);
            font-size: 0.66rem;
        }

        .msg-badge.multi_agent {
            background: rgba(59, 130, 246, 0.12);
            color: var(--info-text);
            border-color: rgba(59, 130, 246, 0.24);
        }

        /* Multi-agent : sans bulle, on indique via un accent latéral (pas de halo flottant). */
        .message.assistant.multi-agent-active .msg-bubble {
            border-left: 2px solid rgba(59, 130, 246, 0.45);
            padding-left: 12px;
            box-shadow: none;
        }

        .multi-agent-banner {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            margin: 0 0 12px;
            padding: 8px 10px;
            border-radius: 10px;
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(102, 15, 242, 0.14));
            border: 1px solid rgba(96, 165, 250, 0.28);
            color: var(--info-text);
            font-size: 0.76rem;
            font-weight: 700;
        }

        .multi-agent-banner .multi-agent-steps {
            padding: 2px 7px;
            border-radius: 999px;
            background: rgba(15, 23, 42, 0.35);
            border: 1px solid rgba(147, 197, 253, 0.22);
            font-size: 0.68rem;
            font-weight: 700;
            color: var(--info-text);
        }

        .msg-time {
            color: var(--text-muted);
            font-size: 0.68rem;
            margin-left: auto;
        }

        /* Sources */
        .msg-sources {
            margin-top: 10px;
            overflow: hidden;
            max-width: 100%;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 4px 14px;
        }

        /* La liste des sources occupe sa propre ligne (sous le toggle + l'action scope) */
        .msg-sources .sources-list {
            flex-basis: 100%;
        }

        /* Action « Limiter à ces sources » (à côté du toggle sources) */
        .sources-scope-btn {
            font-size: 0.72rem;
            color: var(--accent);
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            transition: opacity var(--transition);
        }

        .sources-scope-btn:hover {
            text-decoration: underline;
        }

        .sources-toggle {
            font-size: 0.72rem;
            color: var(--text-muted);
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: color var(--transition);
        }

        .sources-toggle:hover {
            color: var(--accent-text);
        }

        .sources-list {
            display: none;
            margin-top: 6px;
            max-width: 100%;
            overflow: hidden;
        }

        .sources-list.open {
            display: block;
        }

        .source-item {
            padding: 6px 10px;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            margin-bottom: 4px;
            font-size: 0.72rem;
            color: var(--text-muted);
            overflow: hidden;
            word-break: break-word;
            overflow-wrap: break-word;
        }

        .source-item .source-name {
            color: var(--accent-text);
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 6px;
            overflow-wrap: break-word;
            word-break: break-word;
            min-width: 0;
        }

        .source-page {
            background: var(--accent);
            color: var(--bg-primary);
            font-size: 0.65rem;
            padding: 1px 6px;
            border-radius: 8px;
            font-weight: 600;
            white-space: nowrap;
        }

        /* Date du contenu d'un document cité. Discrète : elle situe la source sans rivaliser
           avec son nom, mais reste lisible — c'est elle qui dit « cette réponse vient d'un
           document de mai ». */
        .source-date {
            font-size: 0.72rem;
            font-weight: 500;
            color: var(--text-muted, #7a7a85);
            white-space: nowrap;
            margin-left: 0.25rem;
        }

        .sources-extra {
            font-size: 0.65rem;
            color: var(--text-muted);
            font-weight: 400;
            margin-left: 4px;
        }

        .citation-ref-muted {
            font-size: 0.72rem;
            color: var(--text-muted);
            font-weight: 500;
        }

        .source-snippet {
            margin-top: 5px;
            font-size: 0.72rem;
            line-height: 1.55;
            color: var(--text-secondary);
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        mark.source-highlight {
            background: rgba(108, 99, 255, 0.18);
            color: var(--accent-text);
            border-radius: 2px;
            padding: 0 2px;
            font-weight: 600;
        }

        /* Citation links [N] dans le corps de la réponse */
        a.citation-link {
            display: inline-block;
            font-size: 0.72rem;
            font-weight: 700;
            color: var(--accent-text);
            background: rgba(108, 99, 255, 0.12);
            border: 1px solid rgba(108, 99, 255, 0.3);
            border-radius: 4px;
            padding: 0 4px;
            margin: 0 1px;
            text-decoration: none;
            vertical-align: super;
            line-height: 1;
            transition: background 0.15s, color 0.15s;
            cursor: pointer;
        }

        a.citation-link:hover {
            background: rgba(108, 99, 255, 0.28);
            text-decoration: none;
        }

        /* Toggle "Détails" OFF : masque les pastilles [N] inline, le panneau
           "▶ X sources", la durée, le badge modèle, le type de requête (routeur)
           et la confiance. Préférence stockée en localStorage et appliquée via
           body[data-citations="off"]. CSS pur — pas de re-render. Reste visible :
           l'heure du message. */
        body[data-citations="off"] a.citation-link,
        body[data-citations="off"] .msg-sources,
        body[data-citations="off"] .msg-duration,
        body[data-citations="off"] .msg-badge.model,
        body[data-citations="off"] .query-type-badge,
        body[data-citations="off"] .confidence-badge {
            display: none;
        }

        /* Source card mise en évidence lors du clic sur une citation */
        .source-item-highlighted {
            background: rgba(108, 99, 255, 0.15) !important;
            border-color: var(--accent) !important;
            transition: background 0.2s, border-color 0.2s;
        }

        /* Confidence badge */
        .confidence-badge {
            position: relative;
            cursor: default;
            padding: 2px 7px;
            border-radius: 10px;
            font-size: 0.68rem;
            font-weight: 600;
            border: 1px solid var(--border);
        }

        .confidence-badge.low {
            background: rgba(239, 68, 68, 0.1);
            color: var(--error);
            border-color: rgba(239, 68, 68, 0.25);
        }

        .confidence-badge.medium {
            background: rgba(251, 191, 36, 0.1);
            color: var(--warning);
            border-color: rgba(251, 191, 36, 0.25);
        }

        .confidence-badge.high {
            background: rgba(52, 211, 153, 0.1);
            color: var(--success);
            border-color: rgba(52, 211, 153, 0.25);
        }

        /* « Calculé » — pas un quatrième niveau de confiance, mais une autre NATURE de
           réponse : les chiffres sont lus dans le fichier, pas rédigés. Repris du violet
           d'accent plutôt que du vert de réussite, pour qu'il ne se lise pas comme un
           « encore mieux que Élevé » sur la même échelle. */
        .confidence-badge.computed {
            background: var(--accent-soft);
            color: var(--accent-text);
            border-color: var(--accent-glow);
            font-weight: 700;
        }

        .confidence-badge .conf-tooltip {
            position: absolute;
            bottom: calc(100% + 6px);
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 6px 10px;
            font-size: 0.68rem;
            white-space: nowrap;
            color: var(--text-primary);
            font-weight: 400;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.15s;
            z-index: 10;
            box-shadow: var(--shadow-md);
        }

        .confidence-badge:hover .conf-tooltip {
            opacity: 1;
        }

        /* Feedback 👍/👎 */
        .msg-feedback {
            display: flex;
            gap: 6px;
            margin-top: 6px;
            align-items: center;
        }

        /* Champ « qu'est-ce qui n'allait pas ? », affiché après un avis négatif.
           Discret par construction : il apparaît sous la réponse concernée, sans modale
           ni superposition — on demande une précision, on n'interrompt pas la personne. */
        .fb-comment {
            margin-top: 8px;
            padding: 10px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--surface-elevated, var(--bg-input));
            max-width: 560px;
        }

        .fb-comment-label {
            display: block;
            font-size: 0.82rem;
            color: var(--text-secondary);
            margin-bottom: 6px;
        }

        .fb-optional {
            color: var(--text-muted);
            font-weight: 400;
        }

        .fb-comment-input {
            width: 100%;
            box-sizing: border-box;
            padding: 8px 10px;
            font: inherit;
            font-size: 0.88rem;
            color: inherit;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm, 6px);
            resize: vertical;
            min-height: 44px;
        }

        .fb-comment-input:focus {
            outline: 2px solid var(--accent-hover);
            outline-offset: 1px;
            border-color: var(--accent-text);
        }

        /* `.btn-sm` n'existait pas — les boutons du champ auraient hérité de la taille
           pleine et déséquilibré un bloc qui doit rester discret. */
        .btn-sm {
            padding: 6px 12px;
            font-size: 0.85rem;
        }

        .fb-comment-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 8px;
        }

        /* Mobile : les actions passent pleine largeur — une cible de 44 px reste
           atteignable au pouce, ce qu'une paire de petits boutons alignés à droite
           ne garantit pas. */
        @media (max-width: 640px) {
            .fb-comment { max-width: none; }
            .fb-comment-actions { flex-direction: column-reverse; }
            .fb-comment-actions button { width: 100%; min-height: 44px; }
        }

        .btn-feedback {
            background: none;
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 2px 9px;
            cursor: pointer;
            font-size: 0.78rem;
            color: var(--text-muted);
            transition: all var(--transition);
            line-height: 1.5;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .btn-feedback svg { stroke: currentColor; flex-shrink: 0; }

        .btn-fb-copy {
            padding: 2px 6px;
        }

        .btn-fb-docx {
            border-color: var(--accent);
            color: var(--accent-text);
            font-weight: 500;
        }

        .btn-fb-docx:hover {
            background: rgba(108, 99, 255, 0.15);
        }

        .btn-fb-explain {
            font-size: .9rem;
            line-height: 1;
        }

        .btn-fb-explain:hover {
            background: rgba(108, 99, 255, 0.12);
            border-color: var(--accent);
        }

        .btn-feedback:hover {
            border-color: var(--accent);
            color: var(--accent-text);
            background: rgba(108, 99, 255, 0.08);
        }

        /* L800 — Empty state NOT_FOUND guidé */
        .not-found-guide {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 8px;
            padding: 8px 12px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.82rem;
            color: var(--text-muted);
        }
        .not-found-guide-txt {
            flex: 1;
        }
        .btn-not-found-files {
            background: transparent;
            color: #fff;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 4px 12px;
            font-size: 0.78rem;
            cursor: pointer;
            white-space: nowrap;
            transition: opacity 0.15s;
        }
        .btn-not-found-files:hover {
            background: var(--bg-tertiary);
        }
        .btn-not-found-web {
            background: var(--info, #3b82f6);
            color: #fff;
            border: none;
            border-radius: var(--radius-sm);
            padding: 4px 12px;
            font-size: 0.78rem;
            cursor: pointer;
            white-space: nowrap;
            transition: opacity 0.15s;
        }
        .btn-not-found-web:hover {
            opacity: 0.85;
        }

        .btn-feedback.voted {
            border-color: var(--success);
            color: var(--success);
            background: rgba(52, 211, 153, 0.08);
        }

        .btn-feedback.voted-neg {
            border-color: var(--error);
            color: var(--error);
            background: rgba(239, 68, 68, 0.08);
        }

        .btn-feedback:disabled {
            cursor: default;
            opacity: 0.8;
        }

        /* Thinking block (debug mode) */
        .thinking-block {
            margin-top: 10px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: rgba(108, 99, 255, 0.04);
            font-size: 0.82rem;
        }

        .thinking-block summary {
            cursor: pointer;
            padding: 8px 12px;
            color: var(--text-muted);
            font-weight: 500;
            user-select: none;
        }

        .thinking-block summary:hover {
            color: var(--accent-text);
        }

        .thinking-content {
            padding: 8px 14px 12px;
            border-top: 1px solid var(--border);
            color: var(--text-muted);
            line-height: 1.6;
            white-space: pre-wrap;
        }

        /* Thinking indicator */
        .thinking {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 13px 16px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            font-size: 0.85rem;
            color: var(--text-muted);
            border-bottom-left-radius: 4px;
            animation: thinking-pulse 2.4s ease-in-out infinite;
        }

        .thinking-dots span {
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--accent);
            animation: thinking-bounce 1.1s ease-in-out infinite;
        }

        .thinking-dots span:nth-child(2) {
            animation-delay: 0.18s;
        }

        .thinking-dots span:nth-child(3) {
            animation-delay: 0.36s;
        }

        .thinking-step {
            transition: opacity 0.3s ease;
        }

        .thinking-step.fade-out {
            opacity: 0;
        }

        @keyframes thinking-bounce {
            0%, 60%, 100% {
                transform: translateY(0);
                opacity: 0.35;
            }
            30% {
                transform: translateY(-5px);
                opacity: 1;
            }
        }

        @keyframes thinking-pulse {
            0%, 100% { border-color: var(--border); }
            50% { border-color: rgba(108, 99, 255, 0.45); }
        }

        /* ── Input bar ──────────────────────────────────────────── */
        .chat-input-bar {
            padding: 16px 28px 20px;
            border-top: 1px solid var(--border);
            background: var(--chat-bar-bg);
            backdrop-filter: blur(10px);
            flex-shrink: 0;
        }

        /* Bouton de repli de la zone de saisie — masqué par défaut (desktop & paysage),
           visible uniquement en portrait sur mobile/tablette (cf. media query plus bas). */
        .btn-toggle-input {
            display: none;
        }

        .input-row {
            display: flex;
            flex-direction: column;
            gap: 4px;
            background: var(--composer-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 12px 8px 8px 16px;
            transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
        }

        .input-actions {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            gap: 2px;
        }

        .input-row:focus-within {
            border-color: var(--accent-hover); /* WCAG 2.4.7 : identique au repos = aucun focus visible */
        }

        .chat-textarea {
            /* Pas de flex:1 — sinon flex-basis:0 force le textarea à hauteur 0
               dans le parent flex-column, et la hauteur inline posée par
               autoResize() est ignorée. On laisse la hauteur naturelle dictée
               par min-height + scrollHeight via le JS autoResize. */
            flex: 0 0 auto;
            width: 100%;
            box-sizing: border-box;
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 0.9rem;
            font-family: var(--font-sans);
            resize: none;
            outline: none;
            overflow-y: auto;
            padding: 10px 0;
            min-height: 44px;
            max-height: 200px;
            line-height: 1.5;
        }

        .chat-textarea::placeholder {
            color: var(--text-muted);
        }

        .btn-attach {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 8px 6px;
            cursor: pointer;
            border-radius: var(--radius);
            transition: color var(--transition), background var(--transition);
            flex-shrink: 0;
            line-height: 1;
            display: flex;
            align-items: center;
        }
        .btn-attach svg { stroke: currentColor; }
        .btn-attach:hover {
            color: var(--accent-text);
            background: var(--accent-soft);
        }
        .btn-attach.uploading {
            animation: spin 0.8s linear infinite;
            pointer-events: none;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        .btn-mic {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 8px 6px;
            cursor: pointer;
            border-radius: var(--radius);
            transition: color var(--transition), background var(--transition);
            flex-shrink: 0;
            line-height: 1;
            display: flex;
            align-items: center;
        }
        .btn-mic svg { stroke: currentColor; }
        .btn-mic:hover {
            color: var(--accent-text);
            background: var(--accent-soft);
        }
        .btn-mic--recording {
            color: var(--error);
            animation: mic-pulse 1.2s ease-in-out infinite;
        }
        .btn-mic--recording svg { stroke: #ef4444; }
        @keyframes mic-pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }
        .btn-mic:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .btn-send {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            background: var(--green-hover);
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition);
            flex-shrink: 0;
            margin: 2px;
            box-shadow: 0 4px 16px rgba(25, 240, 94, 0.28);
        }

        .btn-send svg { stroke: #000; }

        .btn-send:hover {
            background: var(--green);
            transform: scale(1.06);
            box-shadow: 0 6px 20px rgba(25, 240, 94, 0.38);
        }

        .btn-send:disabled {
            opacity: 0.4;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .reasoning-mode-select {
            background: var(--bg-secondary);
            color: var(--text-secondary);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 6px 10px;
            font-size: 0.75rem;
            cursor: pointer;
            outline: none;
            flex-shrink: 0;
            min-width: 0;
            max-width: 180px;
        }
        .reasoning-mode-select:focus {
            color: var(--text-primary);
            border-color: var(--accent);
        }
        #router-mode.router-forced {
            border-color: var(--accent);
            color: var(--accent-text);
            font-weight: 600;
        }
        /* Chrome propage `color` et `font-weight` du `<select>` à TOUTES les options de sa
           liste déroulante : dès qu'une action était choisie, la liste entière virait au
           violet et au gras. L'accent doit marquer le CHAMP — qu'un traitement est imposé —
           pas les choix qu'il propose. Rétabli explicitement sur les options et les groupes. */
        #router-mode.router-forced option {
            color: var(--text-primary);
            font-weight: 400;
        }
        #router-mode.router-forced optgroup {
            color: var(--text-secondary);
            font-weight: 600;
        }

        /* ── Toggle switch (style iOS / Linear) ─────────────────────────
           Utilisé pour les préférences booléennes inline dans la barre
           d'options du chat (ex: afficher/masquer les références [N]).
           Sémantique : role="switch" + aria-checked pour les lecteurs d'écran. */
        .toggle-switch {
            position: relative;
            width: 32px;
            height: 18px;
            border-radius: 999px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            cursor: pointer;
            padding: 0;
            transition: background 0.18s ease, border-color 0.18s ease;
            flex-shrink: 0;
            outline: none;
        }
        .toggle-switch:hover {
            border-color: var(--accent);
        }
        .toggle-switch:focus-visible {
            border-color: var(--accent);
            box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.35);
        }
        .toggle-switch-thumb {
            position: absolute;
            top: 1px;
            left: 1px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: var(--text-muted);
            transition: transform 0.18s ease, background 0.18s ease;
        }
        /* État ON (aria-checked=true) — gradient accent + pouce blanc déplacé */
        .toggle-switch[aria-checked="true"] {
            background: var(--green-hover);
            border-color: transparent;
        }
        .toggle-switch[aria-checked="true"] .toggle-switch-thumb {
            transform: translateX(14px);
            background: #fff;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
        }

        /* ── Tables markdown ── */
        /* Pleine largeur (style ChatGPT) : la table remplit la bulle ; overflow-x:auto
           → scroll horizontal si le contenu dépasse (tables larges). */
        .table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
        .md-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
        /* display:table OBLIGATOIRE : annule le display:block hérité de `.msg-bubble
           table` qui, même à width:100%, faisait rétrécir la table à son contenu dans
           un wrapper pleine largeur (→ espace vide à droite). Spécificité (0,3,0) >
           `.msg-bubble table` (0,1,1). `.table-wrap` gère seul l'overflow. */
        .msg-bubble .table-wrap .md-table { display: table; }
        /* Rendu moderne : filets horizontaux uniquement (pas de grille intégrale),
           en-tête affirmé, plus d'air. */
        .md-table th, .md-table td {
            padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border);
            /* .msg-bubble impose overflow-wrap:anywhere (hérité) → réduit la min-content
               à 1 caractère et fait s'effondrer une colonne étroite (label vertical).
               break-word casse uniquement les mots trop longs sans écraser la colonne. */
            overflow-wrap: break-word; word-break: normal;
        }
        .md-table th { background: var(--bg-secondary); font-weight: 600; border-bottom: 2px solid var(--border); }
        .md-table tbody tr:last-child td { border-bottom: none; }
        .md-table tbody tr:nth-child(even) { background: var(--bg-secondary); }

        /* Titres & listes rendus par markdown-it (HTML standard h1-h6/ul/ol, plus de
           styles inline). Scopés à la bulle de réponse — compacts pour le chat. */
        .msg-bubble h1, .msg-bubble h2, .msg-bubble h3,
        .msg-bubble h4, .msg-bubble h5, .msg-bubble h6 {
            margin: 14px 0 6px; line-height: 1.3; font-weight: 700;
        }
        .msg-bubble h1 { font-size: 1.15em; }
        .msg-bubble h2 { font-size: 1.05em; }
        .msg-bubble h3 { font-size: 1em; }
        .msg-bubble h4 { font-size: 0.95em; font-weight: 600; }
        .msg-bubble h5, .msg-bubble h6 { font-size: 0.9em; font-weight: 600; color: var(--accent); }
        .msg-bubble ul, .msg-bubble ol { margin: 6px 0; padding-left: 22px; }
        .msg-bubble li { margin: 2px 0; }
        .msg-bubble blockquote {
            margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--border);
            color: var(--text-secondary);
        }
        .msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

        /* Desktop (≥1024px) : surfaces de LECTURE plus grandes pour le confort —
           le contenu lu (réponses RAG, tableaux) est la valeur produit. Les layouts
           denses (sidebar, admin, badges) restent inchangés pour ne pas casser. */
        @media (min-width: 1024px) {
            .msg-bubble { font-size: 0.95rem; }
            .md-table { font-size: 0.9rem; }
        }

        /* Table clé/valeur (détails d'un message : type, modèle, confiance…) —
           même langage que .md-table : filets horizontaux, padding aéré. */
        .detail-kv { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
        .detail-kv td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
        .detail-kv tr:last-child td { border-bottom: none; }
        .detail-kv .kv-label { color: var(--text-secondary); white-space: nowrap; width: 1%; }

        /* ── Mermaid / Knowledge graph ── */
        .knowledge-graph-wrap { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-secondary); }
        .mermaid-diagram { overflow-x: auto; overflow-y: hidden; display: block; padding: 12px 0; max-width: 100%; box-sizing: border-box; }
        .mermaid-diagram svg { min-width: 0; max-width: none; height: auto; display: block; }
        .mermaid-diagram .label { font-family: 'Montserrat', sans-serif !important; }
        .knowledge-graph-wrap .code-block-header { border-bottom: 1px solid var(--border); padding: 6px 12px; display: flex; align-items: center; justify-content: space-between; }
        .btn-graph-fullscreen { background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); font-size: 0.75rem; padding: 2px 8px; cursor: pointer; }
        .btn-graph-fullscreen:hover { background: var(--bg-primary); color: var(--text-primary); }
        /* Modal plein écran graphe */
        .graph-modal-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.85); align-items: center; justify-content: center; }
        .graph-modal-overlay.open { display: flex; }
        .graph-modal-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 95vw; max-height: 90vh; overflow: auto; padding: 24px; position: relative; }
        .graph-modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--text-secondary); font-size: 1.4rem; cursor: pointer; line-height: 1; z-index: 2; }
        /* Barre de zoom du diagramme plein écran */
        .graph-zoom-bar { position: absolute; top: 10px; left: 14px; display: flex; gap: 6px; z-index: 2; }
        .graph-zoom-btn { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; color: var(--text-secondary); font-size: 0.9rem; font-weight: 600; min-width: 32px; height: 30px; padding: 0 8px; cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
        .graph-zoom-btn:hover { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--accent); }
        .graph-zoom-reset { min-width: 52px; font-size: 0.78rem; }
        /* Viewport plein écran : clippe le SVG, le zoom/pan se fait par transform */
        #graph-modal-content { width: 86vw; height: 78vh; max-width: 1400px; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; }
        #graph-modal-content.grabbing { cursor: grabbing; }
        /* Cible UNIQUEMENT le graphe plein écran — pas les icônes des modales (.ic-svg)
           ni le contenu de la modale d'explication qui partage la classe .graph-modal-box */
        #graph-modal-content svg { min-width: 0; max-width: 100%; max-height: 100%; height: auto; transform-origin: center center; will-change: transform; }

        .input-hints {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 8px;
            display: flex;
            /* `gap` dissocié : l'espacement vertical entre deux lignes enroulées n'a pas de
               raison d'égaler l'espacement horizontal. */
            gap: 8px 10px;
            flex-wrap: wrap;
            align-items: center;
            max-width: 100%;
        }

        .input-hints span,
        .input-hints label {
            display: flex;
            align-items: center;
            gap: 3px;
        }

        /* Puce de périmètre fichiers (scope) dans la barre d'indices */
        .scope-chip {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 3px 10px;
            border: 1px solid var(--bg-tertiary);
            border-radius: 999px;
            background: var(--bg-secondary);
            color: var(--text-secondary);
            font-size: 0.72rem;
            cursor: pointer;
            transition: border-color var(--transition), color var(--transition);
        }

        .scope-chip:hover {
            border-color: var(--accent);
            color: var(--text-primary);
        }

        /* Périmètre actif (des fichiers sont sélectionnés) → accent visible */
        .scope-chip.scope-active {
            border-color: var(--accent);
            color: var(--accent);
            background: var(--accent-soft);
        }

        /* Bouton « × » de réinitialisation du périmètre (visible si scope actif) */
        .scope-clear {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            margin-left: -4px;
            border: none;
            border-radius: 50%;
            background: none;
            color: var(--text-secondary);
            cursor: pointer;
        }

        .scope-clear:hover {
            background: var(--accent-soft);
            color: var(--accent);
        }

        /* Arbre de sélection des fichiers (modale scope) */
        .scope-folder {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            font-size: 0.86rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .scope-toggle {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 0;
            display: flex;
            align-items: center;
            transition: transform 0.15s ease;
        }

        .scope-toggle.collapsed {
            transform: rotate(-90deg);
        }

        .scope-folder-name {
            display: flex;
            align-items: center;
            gap: 6px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: default;
        }

        .scope-folder-name svg {
            color: var(--accent);
            flex-shrink: 0;
        }

        .scope-row {
            display: flex;
            align-items: center;
            gap: 9px;
            padding: 6px 10px;
            cursor: pointer;
            font-size: 0.86rem;
        }

        .scope-row:hover,
        .scope-folder:hover {
            background: var(--accent-soft);
        }

        .scope-file-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .scope-folder-chk,
        .scope-row .scope-chk {
            width: 15px;
            height: 15px;
            flex-shrink: 0;
            cursor: pointer;
            accent-color: var(--accent);
        }

        .reasoning-label {
            color: var(--text-secondary);
            font-weight: 600;
        }

        .hint-spacer {
            margin-left: auto;
        }

        kbd {
            padding: 1px 5px;
            border-radius: 4px;
            border: 1px solid var(--border);
            background: var(--bg-tertiary);
            font-family: var(--font-mono);
            font-size: 0.72em;
        }

        /* ══════════════════════════════════════════════════════════
           PAGE : FICHIERS
        ══════════════════════════════════════════════════════════ */
        .files-layout {
            display: grid;
            grid-template-columns: 260px 1fr;
            gap: 0;
            flex: 1;
            overflow: hidden;
        }

        .files-sidebar {
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background: var(--bg-secondary);
        }

        .files-sidebar-header {
            padding: 16px 16px 12px;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .files-sidebar-header h3 {
            font-size: 0.8rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: var(--text-muted);
            margin-bottom: 10px;
        }

        .btn-new-folder {
            width: 100%;
            padding: 7px 10px;
            background: transparent;
            border: 1px dashed var(--border);
            border-radius: var(--radius-full);
            color: var(--text-secondary);
            font-size: 0.78rem;
            cursor: pointer;
            transition: all var(--transition);
            display: flex;
            align-items: center;
            gap: 6px;
            justify-content: center;
        }

        .btn-new-folder:hover {
            border-color: var(--accent);
            color: var(--accent-text);
        }

        .folder-tree {
            flex: 1;
            overflow-y: auto;
            padding: 8px;
        }

        .folder-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 7px 10px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 0.82rem;
            transition: all var(--transition);
            border: 1px solid transparent;
        }

        .folder-item:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .folder-item.active {
            background: var(--accent-glow);
            color: var(--accent-text);
            border-color: rgba(108, 99, 255, 0.2);
        }

        .folder-share-btn {
            flex-shrink: 0;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 3px;
            border-radius: 4px;
            opacity: 0;
            transition: opacity var(--transition), color var(--transition), background var(--transition);
        }
        .folder-item:hover .folder-share-btn { opacity: 1; }
        .folder-share-btn:hover { color: var(--accent); background: var(--bg-tertiary); }
        .folder-share-btn:focus-visible { opacity: 1; outline: 2px solid var(--accent); }

        .share-scope-group { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
        .share-scope-option {
            display: flex; align-items: center; gap: 8px;
            padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
            cursor: pointer; font-size: 0.85rem; color: var(--text-secondary);
            transition: border-color var(--transition), background var(--transition);
        }
        .share-scope-option:hover { border-color: var(--accent); }
        .share-scope-option:has(input:checked) {
            border-color: var(--accent); background: var(--accent-glow); color: var(--text-primary);
        }
        .file-share-row {
            display: flex; align-items: center; gap: 10px;
            padding: 8px 10px; margin-bottom: 6px;
            background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
        }
        .shared-with-me-item {
            display: flex; align-items: center; gap: 8px;
            padding: 6px 10px; margin-bottom: 4px;
            border-radius: var(--radius-sm); color: var(--text-secondary);
            border: 1px dashed var(--border);
        }

        .files-main {
            display: flex;
            flex-direction: column;
            min-height: 0;
            /* Secours : si zone d'upload + panneau stockage + liste dépassent la
               hauteur dispo (mobile, panneau ouvert), toute la colonne scrolle
               → la liste reste toujours atteignable (au lieu d'être clippée). */
            overflow-y: auto;
        }

        /* Upload zone */
        .upload-zone {
            margin: 20px 24px 0;
            border: 2px dashed rgba(255,255,255,0.1);
            border-radius: var(--radius);
            padding: 28px 20px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
            background: rgba(102, 15, 242, 0.03);
            position: relative;
            overflow: hidden;
        }

        .upload-zone::before {
            content: '';
            position: absolute;
            inset: 0;
            background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(102,15,242,0.08) 0%, transparent 70%);
            opacity: 0;
            transition: opacity 0.2s ease;
            pointer-events: none;
        }

        .upload-zone:hover,
        .upload-zone.dragging {
            border-color: rgba(102, 15, 242, 0.5);
            background: rgba(102, 15, 242, 0.06);
        }

        .upload-zone:hover::before,
        .upload-zone.dragging::before {
            opacity: 1;
        }

        .upload-zone-icon {
            margin-bottom: 10px;
            opacity: 0.5;
            display: flex;
            justify-content: center;
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        .upload-zone:hover .upload-zone-icon {
            opacity: 0.8;
            transform: translateY(-2px);
        }

        .upload-zone-icon svg { stroke: var(--accent); }

        .upload-zone-text {
            font-size: 0.85rem;
            color: var(--text-secondary);
            font-weight: 500;
        }

        .upload-zone-hint {
            font-size: 0.72rem;
            color: var(--text-muted);
            margin-top: 4px;
        }

        .upload-zone input {
            display: none;
        }

        /* Files toolbar */
        .files-toolbar {
            padding: 12px 24px;
            display: flex;
            align-items: center;
            gap: 10px;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .files-categories {
            padding: 10px 24px 0;
            flex-shrink: 0;
        }

        .cat-btn {
            padding: 4px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: 20px;
            color: var(--text-muted);
            font-size: 0.78rem;
            cursor: pointer;
            transition: all var(--transition);
            white-space: nowrap;
        }

        .cat-btn:hover {
            border-color: var(--accent);
            color: var(--text-primary);
        }

        .cat-btn.active {
            background: var(--accent-soft);
            border-color: var(--accent-hover);
            /* `--accent-soft` est une teinte à 7 % : sur fond clair, du blanc dessus disparaît. */
            color: var(--accent-text);
            font-weight: 600;
        }

        .files-search {
            flex: 1;
            padding: 7px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.82rem;
            outline: none;
            transition: border-color var(--transition);
        }

        .files-search:focus {
            border-color: var(--accent);
        }

        .files-search::placeholder {
            color: var(--text-muted);
        }

        .files-select {
            padding: 7px 10px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.78rem;
            outline: none;
            cursor: pointer;
            transition: border-color var(--transition);
        }
        .files-select:focus { border-color: var(--accent); }

        /* ── Page Stock (Q&A déterministe) ────────────────────────────── */
        .stock-layout {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px;
            display: flex;
            flex-direction: column;
            gap: 16px;
            max-width: 860px;
        }
        .stock-import-zone {
            border: 2px dashed var(--border);
            border-radius: var(--radius, 12px);
            padding: 28px 20px;
            text-align: center;
            cursor: pointer;
            transition: border-color var(--transition), background var(--transition);
            background: var(--surface-elevated, rgba(255,255,255,0.03));
        }
        .stock-import-zone:hover,
        .stock-import-zone:focus-visible {
            border-color: var(--accent-hover, #7b2cff);
            outline: none;
        }
        .stock-import-zone.loading { opacity: .6; pointer-events: none; }
        .stock-import-zone p { margin: 8px 0 4px; color: var(--text-primary); font-size: .9rem; }
        .stock-hint { color: var(--text-muted); font-size: .76rem; }

        .stock-status {
            padding: 10px 14px;
            background: var(--accent-soft, rgba(123,44,255,0.10));
            border-radius: 8px;
            font-size: .82rem;
            color: var(--text-muted);
        }
        .stock-status code { color: var(--accent-text, #a78bfa); }

        .stock-ask-row { display: flex; gap: 10px; align-items: stretch; }
        .stock-ask-row .files-search { flex: 1; }
        .stock-answer {
            margin-top: 12px;
            padding: 14px 16px;
            border-radius: 8px;
            font-size: .9rem;
            line-height: 1.5;
            border-left: 3px solid var(--border);
            background: var(--surface-elevated, rgba(255,255,255,0.03));
            color: var(--text-primary);
            white-space: pre-wrap;
        }
        .stock-answer.found { border-left-color: #22c55e; }        /* exact = vert (confiance) */
        .stock-answer.not-found { border-left-color: #f59e0b; }    /* non trouvé = ambre */
        .stock-answer.loading { border-left-color: var(--accent); color: var(--text-muted); }

        .stock-drive-connect { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
        .stock-drive-picker { width: 100%; margin-top: 8px; }
        .stock-drive-list {
            max-height: 220px; overflow-y: auto;
            border: 1px solid var(--border); border-radius: 8px;
        }
        .stock-drive-row {
            display: flex; align-items: center; gap: 8px;
            padding: 7px 10px; border-bottom: 1px solid var(--border);
            font-size: 0.8rem; cursor: pointer;
        }
        .stock-drive-row:last-child { border-bottom: none; }
        .stock-drive-row:hover { background: var(--surface-elevated, rgba(255,255,255,0.03)); }
        .stock-drive-row .tf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .stock-db-form { width: 100%; margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
        .stock-db-form .files-search { flex: 1; min-width: 200px; }

        @media (max-width: 640px) {
            .stock-layout { padding: 16px 14px; }
            .stock-ask-row { flex-direction: column; }
        }

        /* ── Jurisprudence (recherche juridique citée verbatim) ──── */
        .legal-results { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
        .legal-results.loading, .legal-results.not-found {
            padding: 14px 16px; border-radius: 8px; font-size: .9rem; line-height: 1.5;
            border-left: 3px solid var(--accent);
            background: var(--surface-elevated, rgba(255,255,255,0.03));
            color: var(--text-muted); white-space: pre-wrap;
        }
        .legal-results.not-found { border-left-color: #f59e0b; color: var(--text-primary); }
        .legal-card {
            padding: 14px 16px; border-radius: 8px;
            border: 1px solid var(--border);
            border-left: 3px solid #22c55e;                /* source officielle vérifiable = vert */
            background: var(--surface-elevated, rgba(255,255,255,0.03));
        }
        .legal-card-head { font-size: .92rem; line-height: 1.4; color: var(--text-primary); }
        .legal-idx { color: var(--accent-text, #a78bfa); font-weight: 600; }
        .legal-meta { margin-top: 4px; font-size: .78rem; color: var(--text-muted); }
        .legal-src { opacity: .8; }
        .legal-link {
            display: inline-block; margin-top: 6px; font-size: .78rem;
            color: var(--accent-text, #a78bfa); word-break: break-all; text-decoration: none;
        }
        .legal-link:hover { text-decoration: underline; }
        .legal-excerpt {
            margin: 8px 0 0; padding: 8px 12px;
            border-left: 2px solid var(--border);
            font-size: .84rem; line-height: 1.55; color: var(--text-primary);
            font-style: italic;
        }
        .legal-disclaimer { margin: 4px 0 0; font-size: .76rem; color: var(--warning); }
        /* Veille : état dit en clair (nouveautés, derniers parus, aucun texte, source muette). */
        .legal-watch-note { margin: 8px 0 0; font-size: .82rem; line-height: 1.5; color: var(--text-muted); }
        .legal-watch-warn {
            color: var(--text-primary); padding: 6px 10px; border-radius: 4px;
            border-left: 3px solid #f59e0b; background: rgba(245, 158, 11, 0.08);
        }
        .legal-watch-feed { margin: 6px 0 0; padding-left: 18px; }
        .legal-watch-feed li { margin: 4px 0; font-size: .84rem; line-height: 1.45; }
        .legal-watch-feed .legal-link { display: inline; margin-top: 0; font-size: .84rem; word-break: normal; overflow-wrap: anywhere; }
        .legal-card.legal-card-alerte { border-left-color: #f59e0b; }
        .legal-watch-feed small { color: var(--text-muted); }

        /* Filtre par source (chips) */
        .legal-filters { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
        .legal-chip {
            padding: 5px 12px; border-radius: 999px; cursor: pointer;
            font-size: .78rem; border: 1px solid var(--border);
            background: transparent; color: var(--text-muted);
            transition: background .15s, color .15s, border-color .15s;
        }
        .legal-chip:hover { color: var(--text-primary); }
        .legal-chip.active {
            background: var(--accent-soft, rgba(123,44,255,0.12));
            color: var(--accent-text, #a78bfa);
            border-color: var(--accent, #7b2cff);
        }
        #legal-sort { margin-top: 8px; align-items: center; }
        .legal-sort-label { font-size: .78rem; color: var(--text-muted); }

        /* Pont doc→droit dans le chat : références citées → verbatim officiel à la demande */
        .legal-refs-box { margin-top: 8px; }
        .legal-refs-btn {
            padding: 5px 12px; border-radius: 8px; cursor: pointer;
            font-size: .78rem; font-weight: 600;
            border: 1px solid var(--border);
            background: var(--accent-soft, rgba(123,44,255,0.10));
            color: var(--accent-text, #a78bfa);
        }
        .legal-refs-btn:hover { border-color: var(--accent, #7b2cff); }
        .legal-refs-btn:disabled { opacity: .5; cursor: default; }
        .legal-refs-panel { margin-top: 8px; }
        .legal-refs-panel .legal-results { margin-top: 0; }

        /* Pagination */
        .legal-pager {
            display: flex; align-items: center; justify-content: center; gap: 14px;
            margin-top: 14px;
        }
        .legal-pager .btn-secondary { padding: 6px 14px; font-size: .8rem; }
        .legal-pager .btn-secondary:disabled { opacity: .4; cursor: default; }
        .legal-page-label { font-size: .8rem; color: var(--text-muted); min-width: 64px; text-align: center; }

        /* ── Recherche connecteurs (bandeau pleine largeur) ──── */
        .connector-search-wrap {
            display: flex;
            flex-direction: column;
            gap: 12px;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border);
        }

        .connector-search-field {
            position: relative;
            display: flex;
            align-items: center;
        }

        .connector-search-icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            pointer-events: none;
            transition: color var(--transition);
        }

        .connector-search-input {
            width: 100%;
            box-sizing: border-box;
            padding: 10px 38px 10px 40px;
            font-size: 0.85rem;
            border-radius: var(--radius-sm);
        }

        /* Masque la croix native (incohérente selon navigateurs) au profit du bouton custom */
        .connector-search-input::-webkit-search-cancel-button {
            -webkit-appearance: none;
            appearance: none;
        }

        .connector-search-field:focus-within .connector-search-icon {
            color: var(--accent);
        }

        .connector-search-clear {
            position: absolute;
            right: 8px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
            padding: 0;
            border: none;
            border-radius: var(--radius-full);
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            transition: background var(--transition), color var(--transition);
        }

        .connector-search-clear:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        /* Chips de filtre par statut / catégorie */
        .connector-filters {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
        }

        .connector-chip {
            padding: 5px 12px;
            font-size: 0.76rem;
            font-weight: 600;
            line-height: 1;
            color: var(--text-muted);
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
            cursor: pointer;
            white-space: nowrap;
            transition: all var(--transition);
        }

        .connector-chip:hover {
            color: var(--text-primary);
            border-color: var(--border-hover);
        }

        .connector-chip.is-active {
            color: #fff;
            background: var(--accent);
            border-color: var(--accent);
        }

        .connector-count {
            margin-left: auto;
            font-size: 0.74rem;
            color: var(--text-muted);
            white-space: nowrap;
        }

        /* Surlignage du terme recherché */
        mark.connector-hl {
            background: rgba(102, 15, 242, 0.28);
            color: inherit;
            border-radius: 3px;
            padding: 0 1px;
        }

        /* Message « aucun résultat » sur toute la largeur de la grille */
        #connectors-section .config-body > #connector-search-empty {
            grid-column: 1 / -1;
            background: transparent !important;
            border: none !important;
            padding: 24px 12px !important;
            font-size: 0.84rem;
            color: var(--text-muted);
            text-align: center;
        }

        .btn-reprocess {
            padding: 7px 14px;
            background: rgba(25, 240, 94, 0.10);
            color: var(--green-text);
            border: 1px solid var(--green);
            border-radius: var(--radius-full);
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition);
            display: flex;
            align-items: center;
            gap: 6px;
            white-space: nowrap;
        }

        .btn-reprocess:hover {
            background: rgba(25, 240, 94, 0.16);
            border-color: var(--green-hover);
        }

        .btn-reprocess:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Échec d'indexation non résolu (onglet Fichiers) — rouge = état, vert = action. */
        .indexation-echec {
            display: flex;
            flex-wrap: wrap;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
            margin: 12px 24px 0;
            padding: 12px 14px;
            border: 1px solid var(--error);
            border-left-width: 4px;
            border-radius: var(--radius-sm);
            background: color-mix(in srgb, var(--error) 10%, var(--bg-secondary));
            color: var(--text-primary);
        }

        .indexation-echec[hidden] {
            display: none;
        }

        .indexation-echec-texte {
            flex: 1 1 240px;
            min-width: 0;
        }

        .indexation-echec-titre {
            color: var(--error);
            font-size: 0.86rem;
        }

        .indexation-echec p {
            margin: 4px 0 0;
            font-size: 0.8rem;
            line-height: 1.45;
        }

        .indexation-echec-reprise {
            color: var(--text-secondary);
        }

        .indexation-echec-fichiers {
            margin: 6px 0 0;
            padding-left: 18px;
            max-height: 7.5em;
            overflow-y: auto;
            font-size: 0.78rem;
            color: var(--text-secondary);
            overflow-wrap: anywhere;
        }

        .indexation-echec-action {
            flex: 0 0 auto;
        }

        .indexation-echec-action[aria-busy="true"] {
            cursor: progress;
        }

        .file-badge-echec {
            margin-left: 6px;
            padding: 1px 6px;
            border: 1px solid var(--error);
            border-radius: 4px;
            background: color-mix(in srgb, var(--error) 12%, var(--bg-secondary));
            color: var(--error);
            font-size: 0.7rem;
            font-weight: 600;
        }

        @media (max-width: 640px) {
            .indexation-echec {
                margin: 10px 12px 0;
            }

            .indexation-echec-action {
                width: 100%;
            }
        }

        /* File list */
        .file-list {
            flex: 1;
            overflow-y: auto;
            padding: 12px 24px 20px;
            /* Garantit une hauteur utilisable même quand le panneau stockage est
               ouvert : la liste ne se contracte jamais sous ce seuil. */
            min-height: 180px;
        }

        .file-list-empty {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px;
            color: var(--text-muted);
            font-size: 0.85rem;
            gap: 10px;
            text-align: center;
        }

        .file-list-empty span {
            font-size: 2.5rem;
            opacity: 0.3;
        }

        .file-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 14px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            margin-bottom: 6px;
            background: var(--bg-tertiary);
            transition: all var(--transition);
        }

        .file-item:hover {
            border-color: var(--border-hover);
        }

        .file-icon {
            flex-shrink: 0;
            display: flex;
            align-items: center;
        }

        .file-ext-badge {
            font-size: 0.6rem;
            font-weight: 700;
            padding: 2px 5px;
            border-radius: 4px;
            border: 1px solid;
            letter-spacing: 0.03em;
            font-family: var(--font-mono);
            white-space: nowrap;
        }

        .file-info {
            flex: 1;
            min-width: 0;
        }

        .file-name {
            font-size: 0.84rem;
            color: var(--text-primary);
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .file-meta {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .btn-file-del {
            padding: 5px 7px;
            border: 1px solid transparent;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            transition: all var(--transition);
            flex-shrink: 0;
            display: flex;
            align-items: center;
        }

        .btn-file-del svg { stroke: currentColor; }

        .btn-file-del:hover {
            border-color: var(--error);
            color: var(--error);
            background: rgba(248, 113, 113, 0.06);
        }

        /* Action non destructive sur une ligne de fichier (découpage de liasse) : même
           gabarit que .btn-file-del, mais survol accent — le rouge annonce une suppression. */
        .btn-file-action:hover {
            border-color: var(--accent-hover);
            color: var(--accent-text);
            background: var(--accent-soft);
        }

        .btn-file-action[aria-busy="true"] {
            opacity: 0.55;
            cursor: progress;
        }

        .btn-file-action[aria-busy="true"] svg {
            animation: split-spin 900ms linear infinite;
            transform-origin: 50% 50%;
        }

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

        @media (prefers-reduced-motion: reduce) {
            .btn-file-action[aria-busy="true"] svg { animation: none; }
        }

        /* Résultat du découpage — pensé pour être lu de loin, en visioconférence. */
        .split-summary {
            display: flex;
            flex-wrap: wrap;
            gap: 8px 18px;
            padding: 10px 12px;
            margin-bottom: 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: var(--bg-tertiary);
        }

        .split-summary strong {
            display: block;
            font-size: 1.15rem;
            color: var(--accent-text);
            line-height: 1.2;
        }

        .split-summary span { font-size: 0.72rem; color: var(--text-muted); }

        .split-table-wrap { overflow-x: auto; max-height: 46vh; overflow-y: auto; }

        .split-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.78rem;
            min-width: 380px;
        }

        .split-table th {
            text-align: left;
            font-weight: 600;
            color: var(--text-muted);
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            padding: 6px 8px;
            border-bottom: 1px solid var(--border);
            position: sticky;
            top: 0;
            background: var(--bg-secondary, var(--bg-tertiary));
        }

        .split-table td {
            padding: 7px 8px;
            border-bottom: 1px solid var(--border);
            color: var(--text-secondary);
            vertical-align: top;
        }

        .split-table td.split-file { color: var(--text-primary); word-break: break-all; }

        /* Ouvrir une source ou une facture produite : le lien doit se voir comme un lien, sans
           casser la densité de la carte. Souligné au survol seulement — une liste de sources
           entièrement soulignée devient illisible. */
        .split-open,
        .source-open {
            color: inherit;
            text-decoration: none;
            border-bottom: 1px dotted var(--text-muted, #8a8a9a);
            cursor: pointer;
        }
        .split-open:hover,
        .source-open:hover,
        .split-open:focus-visible,
        .source-open:focus-visible {
            color: var(--accent, #6b46c1);
            border-bottom-style: solid;
            text-decoration: none;
        }
        .split-table td.split-pages { white-space: nowrap; font-family: var(--font-mono); }

        .split-notice {
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--bg-tertiary);
            font-size: 0.82rem;
            color: var(--text-secondary);
            line-height: 1.5;
        }

        .split-notice.is-warning { border-color: var(--warning, #fbbf24); }

        @media (max-width: 560px) {
            .split-summary { gap: 6px 12px; }
            .split-table th:nth-child(3), .split-table td:nth-child(3) { display: none; }
        }

        /* Upload progress */
        .upload-progress-list {
            padding: 0 24px;
            flex-shrink: 0;
        }

        .upload-progress-item {
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 8px 12px;
            margin-bottom: 6px;
            font-size: 0.78rem;
        }

        .upload-progress-name {
            color: var(--text-primary);
            margin-bottom: 4px;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.82rem;
        }

        .upload-progress-bar-wrap {
            height: 4px;
            background: var(--bg-primary);
            border-radius: 2px;
            overflow: hidden;
        }

        .upload-progress-bar {
            height: 100%;
            background: var(--accent);
            border-radius: 2px;
            width: 0%;
            transition: width 0.3s ease;
        }

        .upload-progress-bar.done {
            background: var(--success);
            width: 100%;
        }

        .upload-progress-bar.error {
            background: var(--error);
        }

        /* Files stats bar */
        .files-stats {
            padding: 8px 24px 16px;
            display: flex;
            gap: 20px;
            flex-shrink: 0;
            border-top: 1px solid var(--border);
        }

        .files-stat {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .files-stat strong {
            color: var(--accent-text);
        }

        /* ══════════════════════════════════════════════════════════
           PAGE : CONFIGURATION
        ══════════════════════════════════════════════════════════ */
        .config-layout {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px;
        }

        .config-sections {
            max-width: 960px;
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .config-section {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            overflow: hidden;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

        .config-section:hover {
            border-color: var(--border-hover);
            box-shadow: var(--shadow-sm);
        }

        .config-section-header {
            padding: 18px 22px;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .config-section-icon {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(102, 15, 242, 0.1);
            border: 1px solid rgba(102, 15, 242, 0.18);
            border-radius: var(--radius-sm);
            flex-shrink: 0;
        }

        .config-section-icon svg {
            stroke: #a07aff;
            flex-shrink: 0;
        }

        .config-section-title {
            font-size: 0.92rem;
            font-weight: 700;
            letter-spacing: -0.01em;
        }

        .config-section-desc {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 2px;
            line-height: 1.4;
        }

        .config-body {
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .config-row {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 16px;
        }

        .config-row-label {
            flex: 1;
        }

        .config-row-label strong {
            font-size: 0.85rem;
            display: block;
        }

        .config-row-label span {
            font-size: 0.75rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .config-row-control {
            flex-shrink: 0;
            min-width: 200px;
        }

        .config-select {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.84rem;
            outline: none;
            cursor: pointer;
            transition: border-color var(--transition);
        }

        .config-select:focus {
            border-color: var(--accent);
        }

        .config-input {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.84rem;
            outline: none;
            transition: border-color var(--transition);
        }

        .config-input:focus {
            border-color: var(--accent);
        }

        .config-divider {
            height: 1px;
            background: var(--border);
        }

        /* ── Connector Grid (Intégrations externes) ─────────── */
        #connectors-section .config-body {
            display: grid;
            /* minmax(0, 1fr) au lieu de 1fr : `1fr` = minmax(auto, 1fr) → le minimum vaut
               min-content, donc une carte au contenu large (boutons « Parcourir mes fichiers »,
               « Rafraîchir les dossiers surveillés » quand connectée) déborde son 1fr et rétrécit
               la colonne voisine (grid blowout). minmax(0, …) force des colonnes strictement égales. */
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 16px;
            padding: 16px 20px;
        }

        #connectors-section .config-divider {
            display: none;
        }

        #connectors-section .config-body > div:not(.config-divider) {
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 20px !important;
            border-top: none !important;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            gap: 10px;
            /* La carte est un item de grille en colonne flex : min-width:0 l'empêche de dépasser
               sa piste (sinon un enfant à contenu large — rangée de boutons — force sa largeur). */
            min-width: 0;
        }

        #connectors-section .config-body > div:not(.config-divider):hover {
            border-color: var(--success);
            transform: translateY(-3px);
            box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
        }

        #connectors-section .connector-status {
            padding: 4px 14px !important;
            border-radius: var(--radius-full) !important;
            font-weight: 600 !important;
            letter-spacing: 0.02em;
            white-space: nowrap;
            border: 1px solid var(--border);
            font-size: 0.72rem !important;
        }

        #connectors-section .modal-field {
            border-radius: var(--radius-sm);
            transition: all var(--transition);
        }

        #connectors-section .modal-field:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(102, 15, 242, 0.1);
        }

        #connectors-section .btn-primary,
        #connectors-section .btn-secondary {
            border-radius: var(--radius-full) !important;
            font-weight: 600;
        }

        /* Boutons connecteurs : contour vert, intérieur peu saturé (choix Mehdi) */
        #connectors-section .btn-primary {
            /* Contour vert, intérieur peu saturé (choix Mehdi). Le texte était `#fff` : sur
               fond clair, du blanc sur un vert à 10 % posé sur du blanc donne ~1,1:1 —
               le bouton devenait illisible. `--text-primary` porte exactement cette
               intention (texte principal sur une surface proche du fond) dans les deux thèmes. */
            background: rgba(25, 240, 94, 0.10);
            border: 1px solid var(--green);
            color: var(--text-primary);
        }

        #connectors-section .btn-primary:hover {
            background: rgba(25, 240, 94, 0.16);
            border-color: var(--green-hover);
            color: var(--text-primary);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(25, 240, 94, 0.18);
        }

        #connectors-section .btn-secondary:hover {
            border-color: var(--success);
            color: var(--success);
        }

        /* ── Sélecteur de fichiers OneDrive / SharePoint ─────────────────── */
        .od-picker {
            margin-top: 10px;
            border: 1px solid var(--border);
            border-radius: var(--radius);
            background: var(--bg-secondary);
            box-shadow: var(--shadow-md);
            overflow: hidden;
        }

        .od-picker__head {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
        }

        .od-picker__title {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 7px;
            font-size: 0.82rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .od-picker__title svg {
            color: var(--accent-text);
            flex-shrink: 0;
        }

        .od-chip {
            padding: 3px 11px;
            font-size: 0.7rem;
            font-weight: 600;
            line-height: 1.4;
            color: var(--text-secondary);
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
            cursor: pointer;
            transition: all var(--transition);
        }

        .od-chip:hover {
            color: var(--text-primary);
            border-color: var(--border-hover);
        }

        .od-picker__close {
            display: inline-flex;
            padding: 4px;
            border: none;
            background: none;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: all var(--transition);
        }

        .od-picker__close:hover {
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .od-picker__close svg {
            width: 16px;
            height: 16px;
        }

        .od-picker__source {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-bottom: 1px solid var(--border);
        }

        .od-picker__source-label {
            font-size: 0.68rem;
            font-weight: 700;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: .5px;
        }

        .od-select {
            flex: 1;
            min-width: 0;
            padding: 6px 10px;
            font-size: 0.78rem;
            color: var(--text-primary);
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: border-color var(--transition), box-shadow var(--transition);
        }

        .od-select:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-glow);
        }

        .od-picker__search {
            position: relative;
            padding: 8px 12px;
            border-bottom: 1px solid var(--border);
        }

        .od-search {
            width: 100%;
            box-sizing: border-box;
            padding: 7px 10px 7px 32px;
            font-size: 0.78rem;
            color: var(--text-primary);
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            transition: border-color var(--transition), box-shadow var(--transition);
        }

        .od-search::placeholder {
            color: var(--text-muted);
        }

        .od-search:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-glow);
        }

        .od-search__icon {
            position: absolute;
            left: 22px;
            top: 50%;
            transform: translateY(-50%);
            width: 14px;
            height: 14px;
            color: var(--text-muted);
            pointer-events: none;
        }

        .od-breadcrumb {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 4px;
            padding: 8px 12px;
            font-size: 0.74rem;
            border-bottom: 1px solid var(--border);
            background: var(--bg-tertiary);
        }

        .od-crumb {
            color: var(--accent-text);
            cursor: pointer;
            border-radius: 4px;
            padding: 1px 5px;
            transition: all var(--transition);
        }

        .od-crumb:hover {
            background: var(--accent-soft);
        }

        .od-crumb--current {
            color: var(--text-primary);
            font-weight: 600;
            cursor: default;
        }

        .od-crumb--current:hover {
            background: none;
        }

        .od-breadcrumb__sep {
            color: var(--text-muted);
            opacity: .5;
        }

        .od-list {
            max-height: 260px;
            overflow-y: auto;
        }

        .od-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 9px 12px;
            border-bottom: 1px solid var(--border);
            transition: background var(--transition);
        }

        .od-row:last-child {
            border-bottom: none;
        }

        .od-row:hover {
            background: var(--accent-soft);
        }

        .od-row--file {
            cursor: pointer;
        }

        .od-row__nav {
            display: flex;
            align-items: center;
            gap: 10px;
            flex: 1;
            min-width: 0;
            cursor: pointer;
        }

        .od-row__icon {
            flex-shrink: 0;
            display: inline-flex;
            color: var(--text-muted);
        }

        .od-row--folder .od-row__icon {
            color: var(--accent-text);
        }

        .od-row__name {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 0.8rem;
            color: var(--text-primary);
        }

        .od-row--folder .od-row__name {
            font-weight: 600;
        }

        .od-row__chevron {
            flex-shrink: 0;
            color: var(--text-muted);
        }

        .od-row__chk {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            accent-color: var(--accent);
            cursor: pointer;
        }

        .od-badge {
            flex-shrink: 0;
            font-size: 0.62rem;
            font-weight: 600;
            letter-spacing: .3px;
            padding: 2px 6px;
            border-radius: 5px;
            background: var(--bg-tertiary);
            color: var(--text-muted);
        }

        .od-row__size {
            flex-shrink: 0;
            font-size: 0.68rem;
            color: var(--text-muted);
            font-variant-numeric: tabular-nums;
        }

        .od-picker__foot {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 12px;
            border-top: 1px solid var(--border);
            background: var(--bg-tertiary);
        }

        .od-picker__count {
            flex: 1;
            font-size: 0.76rem;
            color: var(--text-secondary);
        }

        .od-state {
            padding: 24px 12px;
            text-align: center;
            font-size: 0.78rem;
            color: var(--text-muted);
        }

        .od-state--error {
            color: var(--error);
        }

        .od-spin {
            display: inline-block;
            margin-right: 6px;
            animation: spin 1s linear infinite;
        }

        @media (max-width: 768px) {
            #connectors-section .config-body {
                /* minmax(0, 1fr) : évite qu'une carte connectée dépasse la largeur du viewport
                   (débordement horizontal mobile) — même raison que la grille 2 colonnes. */
                grid-template-columns: minmax(0, 1fr);
            }
        }

        .config-save-row {
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .btn-config-save {
            padding: 8px 20px;
            background: var(--green-hover);
            color: #000;
            border: none;
            border-radius: var(--radius-full);
            font-size: 0.84rem;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition);
        }

        .btn-config-save:hover {
            background: var(--green);
        }

        /* Sources toggles */
        .sources-grid {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .source-toggle-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: all var(--transition);
        }

        .source-toggle-item:hover {
            border-color: var(--border-hover);
        }

        .source-toggle-item.active {
            border-color: rgba(52, 211, 153, 0.3);
            background: rgba(52, 211, 153, 0.04);
        }

        .source-toggle-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .source-toggle-icon {
            font-size: 1rem;
            width: 20px;
            text-align: center;
        }

        .source-toggle-name {
            font-size: 0.84rem;
            font-weight: 500;
        }

        .source-toggle-count {
            font-size: 0.72rem;
            color: var(--text-muted);
            margin-top: 1px;
        }

        .toggle-switch {
            position: relative;
            width: 36px;
            height: 20px;
            flex-shrink: 0;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            inset: 0;
            border-radius: 10px;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            transition: all var(--transition);
            cursor: pointer;
        }

        .toggle-slider::before {
            content: '';
            position: absolute;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: var(--text-muted);
            top: 2px;
            left: 2px;
            transition: all var(--transition);
        }

        .toggle-switch input:checked+.toggle-slider {
            background: var(--success);
            border-color: var(--success);
        }

        .toggle-switch input:checked+.toggle-slider::before {
            background: #fff;
            transform: translateX(16px);
        }

        /* Health status cards */
        .health-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 10px;
        }

        .health-card {
            padding: 12px 14px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
        }

        .health-card-title {
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: var(--text-muted);
            margin-bottom: 6px;
        }

        .health-card-value {
            font-size: 0.88rem;
            font-weight: 600;
        }

        .health-card-value.ok {
            color: var(--success);
        }

        .health-card-value.warn {
            color: var(--warning);
        }

        .health-card-value.err {
            color: var(--error);
        }

        /* ══════════════════════════════════════════════════════════
           MODALS
        ══════════════════════════════════════════════════════════ */
        .modal {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            z-index: 2000;
            align-items: center;
            justify-content: center;
        }

        /* Modal reset password : doit s'afficher au-dessus du login-gate (z-index 9999)
           car elle peut être déclenchée depuis l'écran de login (lien email avec ?reset_token=). */
        .modal#reset-password-modal {
            z-index: 10001;
        }

        .modal.active {
            display: flex;
        }

        .modal-box {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 28px;
            width: min(420px, 90vw);
            box-shadow: var(--shadow-lg);
        }

        .modal-box h2 {
            font-size: 1.1rem;
            margin-bottom: 4px;
        }

        .modal-box .modal-sub {
            font-size: 0.78rem;
            color: var(--text-secondary);
            margin-bottom: 18px;
        }

        .modal-field {
            display: block;
            width: 100%;
            box-sizing: border-box;
            padding: 9px 12px;
            background: var(--bg-tertiary, var(--bg-secondary));
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 0.875rem;
            margin-bottom: 10px;
            outline: none;
            transition: border-color 0.15s, box-shadow 0.15s;
        }

        .modal-field:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
        }

        .modal-field::placeholder {
            color: var(--text-muted);
        }

        /* ── Bouton "œil" afficher/masquer mot de passe ─────────────────
           Wrapper appliqué automatiquement à tous les <input type="password">
           par _initPasswordToggles() au DOMContentLoaded. Le wrapper s'aligne
           verticalement avec le margin-bottom natif de l'input pour ne pas
           casser les layouts existants. */
        .pw-wrapper {
            position: relative;
            margin-bottom: 10px;
        }
        .pw-wrapper > input {
            /* Réserver de la place pour le bouton à droite */
            padding-right: 38px !important;
            margin-bottom: 0 !important;
        }
        .pw-toggle {
            position: absolute;
            right: 6px;
            top: 50%;
            transform: translateY(-50%);
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0;
            transition: background 0.15s, color 0.15s;
        }
        .pw-toggle:hover {
            background: rgba(108, 99, 255, 0.10);
            color: var(--text-primary);
        }
        .pw-toggle:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 1px;
        }
        .pw-toggle svg {
            width: 16px;
            height: 16px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .modal-field-readonly {
            display: block;
            width: 100%;
            box-sizing: border-box;
            padding: 9px 12px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 0.875rem;
            margin-bottom: 10px;
            cursor: default;
            user-select: text;
        }

        .modal-error {
            color: var(--error);
            font-size: 0.78rem;
            margin-bottom: 10px;
            display: none;
        }

        .modal-error.show {
            display: block;
        }

        .modal-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 4px;
        }

        /* ── Section changement de mot de passe (modal profil) ── */
        .profile-pwd-section {
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
        }

        .profile-pwd-toggle {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            background: var(--bg-secondary);
            border: none;
            padding: 10px 14px;
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 0.85rem;
            font-weight: 500;
            text-align: left;
            transition: background 0.15s, color 0.15s;
            box-sizing: border-box;
        }

        .profile-pwd-toggle:hover {
            background: var(--bg-card-hover, rgba(255,255,255,0.06));
            color: var(--text-primary);
        }

        .profile-pwd-toggle[aria-expanded="true"] {
            color: var(--text-primary);
            border-bottom: 1px solid var(--border);
        }

        .profile-pwd-chevron {
            margin-left: auto;
            transition: transform 0.2s ease;
            flex-shrink: 0;
        }

        .profile-pwd-toggle[aria-expanded="true"] .profile-pwd-chevron {
            transform: rotate(180deg);
        }

        .profile-pwd-fields {
            padding: 12px 14px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            background: transparent;
        }

        .profile-pwd-hint {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin: 0;
            padding: 6px 8px;
            background: color-mix(in srgb, var(--text-muted) 8%, transparent);
            border-radius: 5px;
            line-height: 1.4;
        }

        /* ── Modal profil : layout modernisé ── */
        .profile-header {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 16px 0 20px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 20px;
        }

        .profile-avatar {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            /* Pastille de profil en vert de marque (demande Mehdi, 2026-09-09). L'initiale
               passe du blanc au gris de charte : sur ce vert, le blanc tombe à 2,05:1 —
               illisible — quand `#2a2a40` tient 6,8:1. C'est la même teinte que le texte
               courant et que le `fill` de `logo-noir.svg`. */
            background: var(--green-hover);
            color: #2a2a40;
            font-size: 1.3rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            text-transform: uppercase;
        }

        .profile-header-name {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .profile-header-role {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 2px;
            text-transform: capitalize;
        }

        .profile-fields {
            display: flex;
            flex-direction: column;
            gap: 14px;
            margin-bottom: 16px;
        }

        .profile-field-group {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .profile-field-label {
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--text-secondary);
            letter-spacing: 0.01em;
        }

        .profile-footer-links {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            margin: 14px 0 4px;
            padding-top: 12px;
            border-top: 1px solid var(--border);
        }

        .profile-link-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            background: none;
            border: none;
            padding: 0;
            cursor: pointer;
            font-size: 0.78rem;
            color: var(--text-muted);
            transition: color 0.15s;
        }

        .profile-link-btn:hover {
            color: var(--text-secondary);
        }

        .btn-primary {
            padding: 9px 20px;
            background: var(--green-hover);
            color: #2a2a40;
            border: none;
            border-radius: var(--radius-full);
            font-size: 0.84rem;
            font-weight: 600;
            cursor: pointer;
            transition: all var(--transition);
        }

        .btn-primary:hover {
            background: var(--green);
            transform: translateY(-1px);
            box-shadow: 0 10px 20px rgba(25, 240, 94, 0.2);
        }

        .btn-primary:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn-secondary {
            padding: 9px 16px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
            color: var(--text-primary);
            font-size: 0.84rem;
            cursor: pointer;
            transition: all var(--transition);
        }

        .btn-secondary:hover {
            border-color: var(--border-hover);
            color: var(--text-primary);
            transform: translateY(-1px);
        }

        /* ── Auth tabs ──────────────────────────────────────────── */
        .auth-tabs {
            display: flex;
            gap: 0;
            margin-bottom: 18px;
            border-bottom: 1px solid var(--border);
        }

        .auth-tab {
            flex: 1;
            padding: 9px 0;
            text-align: center;
            cursor: pointer;
            font-size: 0.84rem;
            font-weight: 500;
            color: var(--text-muted);
            border-bottom: 2px solid transparent;
            margin-bottom: -1px;
            transition: all var(--transition);
            background: none;
            border-top: none;
            border-left: none;
            border-right: none;
        }

        .auth-tab.active {
            color: var(--accent-text);
            border-bottom-color: var(--accent);
        }

        /* ── Toast ──────────────────────────────────────────────── */
        #toast-container {
            position: fixed;
            bottom: 24px;
            right: 24px;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .toast {
            padding: 10px 16px;
            border-radius: var(--radius-sm);
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            font-size: 0.82rem;
            color: var(--text-primary);
            box-shadow: var(--shadow);
            animation: slideIn 0.2s ease;
            max-width: 320px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .toast-ic {
            display: inline-flex;
            flex-shrink: 0;
        }
        .toast.success .toast-ic { color: var(--success); }
        .toast.error .toast-ic { color: var(--error); }

        /* ── Onboarding "spotlight" (tour guidé) ──────────────────────── */
        .tour-layer { position: fixed; z-index: 9998; }
        .tour-mask { inset: 0; background: rgba(0,0,0,0.72); pointer-events: auto; transition: background .2s ease; }
        .tour-spotlight {
            z-index: 9999; border-radius: 10px; pointer-events: none;
            box-shadow: 0 0 0 9999px rgba(0,0,0,0.72), 0 0 0 2px var(--accent);
            transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
            animation: tourPulse 1.7s ease-in-out infinite;
        }
        @keyframes tourPulse {
            0%, 100% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.72), 0 0 0 2px var(--accent); }
            50%      { box-shadow: 0 0 0 9999px rgba(0,0,0,0.72), 0 0 0 6px rgba(102,15,242,0.40); }
        }
        .tour-bubble {
            z-index: 10000; pointer-events: auto;
            width: min(400px, calc(100vw - 28px));
            background: var(--bg-secondary, #16162a); border: 1px solid var(--border);
            border-radius: 16px; padding: 30px 28px 24px;
            box-shadow: 0 14px 48px rgba(0,0,0,0.48);
            animation: tourBubbleIn .22s ease;
        }
        @keyframes tourBubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
        .tour-icon { color: var(--accent-text); margin-bottom: 14px; line-height: 0; }
        .tour-title { font-size: 1.22rem; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
        .tour-text { font-size: 0.95rem; line-height: 1.65; color: var(--text-secondary); }
        .tour-text strong { color: var(--text-primary); }
        .tour-dots { display: flex; gap: 7px; margin: 22px 0 18px; }
        .tour-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); transition: all .2s; }
        .tour-dot.active { background: var(--accent); width: 20px; border-radius: 4px; }
        .tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
        .tour-skip { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; font-family: inherit; padding: 8px 6px; }
        .tour-skip:hover { color: var(--text-secondary); }
        .tour-next { background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 11px 20px; font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
        .tour-next:hover { background: var(--accent-hover); }
        .tour-close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; line-height: 0; }
        .tour-close:hover { color: var(--text-primary); }
        @media (prefers-reduced-motion: reduce) { .tour-spotlight { animation: none; } }

        .toast.success {
            border-color: var(--success);
            background: rgba(52, 211, 153, 0.08);
            color: var(--success);
        }

        .toast.error {
            border-color: var(--error);
            background: rgba(248, 113, 113, 0.08);
            color: var(--error);
        }

        /* Fichiers écartés par le plafond de l'offre, sous le résultat d'une synchronisation. */
        .sync-ignores {
            margin-top: 8px;
            font-size: 0.85rem;
            color: var(--text-primary);
        }
        .sync-ignores summary {
            cursor: pointer;
            color: var(--warning);
            font-weight: 600;
        }
        .sync-ignores summary:focus-visible {
            outline: 2px solid var(--warning);
            outline-offset: 2px;
        }
        .sync-ignores ul {
            margin: 6px 0;
            padding-left: 18px;
            overflow-wrap: anywhere;
        }
        .sync-ignores p {
            margin: 0;
            color: var(--text-muted);
        }

        .toast.warn {
            border-color: var(--warning);
            background: rgba(251, 191, 36, 0.08);
            color: var(--warning);
        }

        .toast.info {
            border-color: var(--accent);
            background: rgba(99, 102, 241, 0.08);
            color: var(--accent-text);
        }

        /* ── Toast "Nouvelle version disponible" — persistant, actionnable ── */
        .sw-update-toast {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            padding: 11px 12px 11px 16px;
            max-width: 380px;
            background: var(--bg-tertiary);
            border: 1px solid var(--accent);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
        }

        .sw-update-toast .sw-update-msg {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--text-primary);
            font-size: 0.83rem;
            line-height: 1.2;
        }

        .sw-update-toast .sw-update-icon {
            color: var(--accent-text);
            font-size: 1.05rem;
            font-weight: 700;
            line-height: 1;
        }

        .sw-update-toast .sw-update-actions {
            display: flex;
            align-items: center;
            gap: 4px;
            transition: opacity 0.2s ease;
        }

        .sw-update-toast .sw-update-btn-primary {
            background: var(--green);
            color: #000;
            border: none;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 0.76rem;
            font-weight: 500;
            cursor: pointer;
            transition: filter 0.15s ease, transform 0.05s ease;
        }

        .sw-update-toast .sw-update-btn-primary:hover {
            filter: brightness(1.1);
        }

        .sw-update-toast .sw-update-btn-primary:active {
            transform: scale(0.97);
        }

        .sw-update-toast .sw-update-btn-close {
            background: transparent;
            border: none;
            color: var(--text-muted);
            font-size: 0.85rem;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 4px;
            transition: color 0.15s ease, background 0.15s ease;
        }

        .sw-update-toast .sw-update-btn-close:hover {
            color: var(--text-primary);
            background: var(--surface-hover);
        }

        /* ── Toggle audience CHANGELOG (Utilisateur / Détails techniques) ── */
        .changelog-audience-toggle {
            display: inline-flex;
            gap: 2px;
            padding: 3px;
            border-radius: 8px;
            background: var(--surface-elevated);
            border: 1px solid var(--border);
        }

        .changelog-tab {
            padding: 5px 14px;
            background: transparent;
            border: none;
            color: var(--text-muted);
            font-size: 0.78rem;
            cursor: pointer;
            border-radius: 6px;
            transition: background 0.15s ease, color 0.15s ease;
            font-family: inherit;
        }

        .changelog-tab:hover:not(.active) {
            color: var(--text-secondary);
            background: var(--surface-elevated);
        }

        .changelog-tab.active {
            background: var(--accent);
            color: #ffffff;
            font-weight: 500;
        }

        /* ── Ligne fichier dans le picker gdrive (template dynamique) ──
           Remplace les anciens onmouseover/onmouseout inline (incident CSP 2026-05-27). */
        .gdrive-file-row:hover {
            background: var(--bg-tertiary);
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(20px);
            }

            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        /* ── Centre de notifications ─────────────────────────── */
        .notif-bell-btn {
            position: relative;
        }

        .notif-panel {
            position: fixed;
            left: calc(var(--sidebar-width) + 8px);
            bottom: 70px;
            width: 340px;
            max-height: 480px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: 0 8px 32px rgba(0,0,0,0.4);
            z-index: 1200;
            display: flex;
            flex-direction: column;
            animation: slideIn 0.18s ease;
            overflow: hidden;
        }

        .notif-panel[hidden] { display: none !important; }

        .notif-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px 8px;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
        }

        .notif-panel-title {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 7px;
        }

        .notif-panel-actions {
            display: flex;
            gap: 6px;
        }

        .notif-panel-btn {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 0.72rem;
            cursor: pointer;
            padding: 2px 6px;
            border-radius: 4px;
            transition: background var(--transition);
        }

        .notif-panel-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .notif-list {
            overflow-y: auto;
            flex: 1;
            padding: 6px 0;
        }

        .notif-empty {
            padding: 32px 16px;
            text-align: center;
            color: var(--text-muted);
            font-size: 0.82rem;
        }

        .notif-item {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 8px 14px;
            border-bottom: 1px solid rgba(255,255,255,0.04);
            transition: background var(--transition);
            cursor: default;
        }

        .notif-item:last-child { border-bottom: none; }

        .notif-item:hover { background: var(--bg-tertiary); }

        .notif-item.unread {
            background: rgba(102, 15, 242, 0.06);
        }

        .notif-item.unread:hover {
            background: rgba(102, 15, 242, 0.1);
        }

        .notif-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
            margin-top: 5px;
        }

        .notif-dot.success { background: var(--success); }
        .notif-dot.error   { background: var(--error); }
        .notif-dot.warn    { background: var(--warning); }
        .notif-dot.info    { background: var(--accent-text); } /* --accent (#660ff2) tombe à 2,47:1 sur fond sombre : une pastille d'état doit rester perceptible (WCAG 1.4.11, seuil 3:1). --accent-text est la variante prévue pour ça. */

        .notif-body {
            flex: 1;
            min-width: 0;
        }

        .notif-msg {
            font-size: 0.81rem;
            color: var(--text-primary);
            line-height: 1.4;
            word-break: break-word;
        }

        .notif-time {
            font-size: 0.68rem;
            color: var(--text-muted);
            margin-top: 2px;
        }

        @media (max-width: 768px) {
            .notif-panel {
                left: 0;
                right: 0;
                bottom: 0;
                width: 100%;
                max-height: 70vh;
                border-radius: var(--radius) var(--radius) 0 0;
            }
        }

        /* ── Scrollbars ─────────────────────────────────────────── */
        ::-webkit-scrollbar {
            width: 5px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--border-hover);
        }

        /* ── Light Theme ─────────────────────────────────────────── */
        [data-theme="light"] {
            /* Mode clair — mêmes RÔLES que le sombre, mêmes couleurs de marque.
               Le violet #660ff2 et le vert #19f05e sont conservés à l'identique : ils sont
               l'identité, ils ne se déclinent pas. Ce qui change, ce sont les surfaces et les
               teintes de TEXTE, qui doivent rester lisibles sur fond clair.

               Chaque valeur ci-dessous est vérifiée par
               `tests/security/test_contraste_themes.py` (WCAG 2.1 AA : 4,5:1 pour le texte,
               3:1 pour les indicateurs graphiques porteurs d'information). */

            /* Surfaces */
            --bg-primary: #f4f4f9;
            --bg-secondary: #ffffff;
            --bg-tertiary: #e9e9f2;
            --bg-input: #ffffff;
            --surface-elevated: rgba(20, 20, 43, 0.03);
            --surface-hover: rgba(20, 20, 43, 0.06);
            --surface-sunken: rgba(20, 20, 43, 0.07);
            --composer-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 246, 251, 0.97));
            --chat-bar-bg: linear-gradient(180deg, rgba(244, 244, 249, 0.86), rgba(244, 244, 249, 0.98));
            --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 240, 247, 0.98));
            --gate-bg: rgba(255, 255, 255, 0.92);
            --avatar-bot-bg: linear-gradient(135deg, #e4e4ef, #d5d5e4);
            --info-text: #1d4ed8;
            --surface-card: #ffffff;
            --user-bubble-bg: var(--surface-hover);
            --user-bubble-text: #2a2a40;
            --green-text-hover: #095f28;
            color-scheme: light;
            --border-color: #d9d9e6;

            /* Texte — `--text-muted` est la plus utilisée de toute la feuille (424 usages) :
               en sombre elle vaut du blanc à 77 %, donc invisible sur clair. */
            --text-primary: #2a2a40;
            --text-secondary: #454560;
            --text-muted: #5b5b74;

            /* Accent violet — la couleur de marque passe telle quelle (7,2:1 sur blanc) ;
               seuls le survol et la variante texte sont assombris. */
            --accent-hover: #5409cc;
            --accent-text: #5a0dd6;
            --accent-glow: rgba(102, 15, 242, 0.12);
            --accent-soft: rgba(102, 15, 242, 0.07);

            /* CTA vert : le fond reste le vert de marque (texte #000 dessus, 11,7:1).
               Seule la variante TEXTE est assombrie. */
            --green-hover: #13d151;
            --green-text: #0b7a33;

            /* États — en sombre, `--success` vaut le vert vif ; sur blanc il tombe à 1,54:1,
               et ses surfaces sont des pastilles d'état et des barres de progression, donc des
               objets graphiques porteurs d'information (WCAG 1.4.11, seuil 3:1). Les assombrir
               les rend lisibles ET visibles. */
            --success: #0b7a33;
            --success-hover: #0a6a2c;
            --warning: #8f5400;
            --error: #c1272d;

            /* Bordures et reliefs */
            --border: #d9d9e6;
            --border-hover: #b4b4c9;
            --border-translucent: rgba(20, 20, 43, 0.14);
            --navbar-bg: rgba(255, 255, 255, 0.88);
            --shadow: 0 4px 24px rgba(20, 20, 43, 0.08);
            --shadow-sm: 0 1px 3px 0 rgba(20, 20, 43, 0.06);
            --shadow-md: 0 4px 6px -1px rgba(20, 20, 43, 0.08), 0 2px 4px -1px rgba(20, 20, 43, 0.05);
            --shadow-lg: 0 8px 40px rgba(20, 20, 43, 0.12);
            --shadow-premium: 0 20px 40px -10px rgba(20, 20, 43, 0.14);
        }

        /* ── Logo selon le thème ─────────────────────────────────────
           Deux balises, une seule affichée. `display:none` retire l'élément de l'arbre
           d'accessibilité : les deux peuvent donc porter le même `alt`, un seul étant
           annoncé. La bascule est en CSS et non en JS parce que `data-theme` est posé
           AVANT le premier rendu — aucun clignotement de logo au chargement.

           `!important` est nécessaire, pas décoratif : trois des quatre balises portent un
           `display:block` EN LIGNE, qui l'emporte sur une règle de feuille de style. */
        .logo-theme--clair { display: none !important; }
        [data-theme="light"] .logo-theme--sombre { display: none !important; }
        [data-theme="light"] .logo-theme--clair { display: block !important; }

        /* Le dégradé du titre d'accueil finit sur `#cbb2ff`, un violet pâle lisible sur
           fond sombre mais qui s'efface sur fond clair — la seconde moitié du texte
           disparaissait. En clair, une seule couleur, pleine. */
        [data-theme="light"] .welcome h2 {
            background: none;
            -webkit-text-fill-color: var(--text-primary);
            color: var(--text-primary);
        }

        [data-theme="light"] .msg-bubble pre,
        [data-theme="light"] .msg-bubble pre code.hljs {
            background: #1e1e2a !important;
        }


        /* ── Avatar Logo ─────────────────────────────────────────── */
        .avatar-logo {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 50%;
        }

        .message.assistant .msg-avatar {
            padding: 0;
            overflow: hidden;
        }

        /* ── Welcome Suggestions ────────────────────────────────── */
        .welcome-suggestions {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            max-width: 560px;
            width: 100%;
            margin-top: 8px;
        }

        .suggestion-card {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 13px 16px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            cursor: pointer;
            transition: all 0.18s ease;
            text-align: left;
            font-size: 0.82rem;
            color: var(--text-secondary);
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
            position: relative;
            overflow: hidden;
        }

        .suggestion-card::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, rgba(102,15,242,0.1) 0%, transparent 60%);
            opacity: 0;
            transition: opacity 0.18s ease;
        }

        .suggestion-card:hover::before {
            opacity: 1;
        }

        .suggestion-card:hover {
            border-color: rgba(102, 15, 242, 0.35);
            color: var(--text-primary);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102,15,242,0.15), 0 2px 8px rgba(0,0,0,0.2);
        }

        .suggestion-icon-wrap {
            flex-shrink: 0;
            width: 34px;
            height: 34px;
            border-radius: 10px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(102, 15, 242, 0.12);
            border: 1px solid rgba(102, 15, 242, 0.2);
            position: relative;
            z-index: 1;
        }

        .suggestion-icon-wrap svg {
            width: 16px;
            height: 16px;
            stroke: #a07aff;
        }

        .suggestion-card > span:last-child {
            position: relative;
            z-index: 1;
        }

        /* ── Export Button ───────────────────────────────────────── */
        .btn-export {
            padding: 6px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-secondary);
            font-size: 0.78rem;
            cursor: pointer;
            transition: all var(--transition);
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .btn-export svg, .btn-icon-text svg {
            flex-shrink: 0;
        }

        .btn-export:hover {
            border-color: var(--accent);
            color: var(--accent-text);
        }

        .btn-icon-text {
            padding: 6px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-secondary);
            font-size: 0.78rem;
            cursor: pointer;
            transition: all var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }

        .btn-icon-text:hover {
            border-color: var(--accent);
            color: var(--accent-text);
        }

        /* ── Hamburger menu (mobile) ─────────────────────────────── */
        .btn-hamburger {
            display: none;
            position: fixed;
            top: 12px;
            left: 12px;
            z-index: 200;
            width: 40px;
            height: 40px;
            padding: 8px;
            background: none;
            border: none;
            cursor: pointer;
            align-items: center;
            justify-content: center;
            color: var(--text-primary);
            transition: color var(--transition);
        }

        .btn-hamburger:hover {
            color: var(--green-text);
        }

        .btn-hamburger svg {
            width: 24px;
            height: 24px;
            display: block;
        }

        /* Bascule Menu ↔ X selon l'état de la sidebar (façon vitrine) */
        .btn-hamburger .icon-close {
            display: none;
        }

        body.sidebar-open .btn-hamburger .icon-menu {
            display: none;
        }

        body.sidebar-open .btn-hamburger .icon-close {
            display: block;
        }

        /* ── Responsive ─────────────────────────────────────────── */
        @media (max-width: 1024px) {
            :root {
                --sidebar-width: 248px;
            }

            .message {
                max-width: 100%;
            }

            /* Mobile + tablette : masquer les avatars (logo Noryzia côté assistant,
               rond à initiale côté user) pour libérer de l'espace horizontal — la
               bulle occupe alors toute la largeur disponible. */
            .msg-avatar {
                display: none;
            }
            .message {
                gap: 0;
            }
        }

        @media (max-width: 900px) {
            .page-header {
                align-items: flex-start;
                flex-wrap: wrap;
            }

            .page-header-actions {
                width: 100%;
                justify-content: flex-start;
            }

            .files-toolbar {
                flex-wrap: wrap;
            }

            .files-search {
                min-width: 0;
                width: 100%;
            }
        }

        /* ── Tablette portrait + mobile : sidebar overlay (≤ 768px) ── */
        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                bottom: 0;
                width: min(86vw, 320px);
                min-width: min(86vw, 320px);
                transform: translateX(-100%);
                box-shadow: var(--shadow-lg);
                z-index: 100;
                /* Mobile : le MENU ENTIER est l'unique zone scrollable (pas de scroll
                   interne riquiqui pour les conversations qui faisait passer l'historique
                   derrière la vignette carbone). */
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }

            /* La liste de conversations coule en hauteur naturelle : c'est la sidebar
               qui scrolle, donc tout l'historique + la vignette carbone restent
               atteignables et cliquables. */
            .sidebar-chat-section {
                flex: 0 0 auto;
            }

            #conv-list {
                flex: 0 0 auto;
                overflow-y: visible;
            }

            .sidebar.open {
                transform: translateX(0);
            }

            .btn-hamburger {
                display: flex;
            }

            /* Décale le logo pour qu'il ne soit pas sous le burger (38px + 2×9px padding) */
            .sidebar-header {
                padding-left: 56px;
            }

            .page-header {
                padding: 0 12px 0 60px; /* 60px = burger 38px + 12px gap + 10px margin */
                min-height: 56px;
                align-items: center;
                flex-wrap: nowrap;
                gap: 8px;
            }

            .page-header-meta {
                flex: 1;
                min-width: 0;
            }

            .page-title {
                font-size: 0.95rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .page-header-actions {
                gap: 4px;
                flex-shrink: 0;
                flex-wrap: nowrap;
                width: auto; /* override 900px rule qui force width:100% */
            }

            /* Cacher le badge modèle et la page-subtitle sur mobile */
            #chat-model-badge {
                display: none;
            }

            .page-subtitle {
                display: none;
            }

            /* Mobile : logo de marque à la place du titre texte (page chat) */
            #page-chat .page-title-logo {
                display: block;
            }

            #page-chat .page-title {
                display: none;
            }

            /* Boutons header : icône seule sur mobile (font-size:0 masque le texte direct) */
            .btn-export,
            .btn-icon-text {
                font-size: 0;
                padding: 6px 8px;
                gap: 0;
            }

            .btn-export svg,
            .btn-icon-text svg {
                display: block;
            }

            .files-layout {
                grid-template-columns: 1fr;
                grid-template-rows: auto minmax(0, 1fr);
            }

            /* Mobile : arborescence des dossiers visible en bandeau compact (au lieu de masquée) */
            .files-sidebar {
                max-height: 168px;
                border-right: none;
                border-bottom: 1px solid var(--border);
            }

            .welcome {
                padding: 24px 16px;
            }

            .welcome-suggestions {
                grid-template-columns: 1fr;
            }

            .chat-messages {
                padding: 16px 14px;
                gap: 12px;
            }

            .message {
                max-width: 100%;
            }

            .msg-bubble {
                max-width: 100%;
                padding: 12px 14px;
            }

            .msg-meta {
                gap: 6px;
            }

            /* Boutons actions user : toujours visibles sur touch */
            .btn-copy-prompt,
            .btn-edit-msg {
                opacity: 0.5;
            }

            .chat-input-bar {
                padding: 12px 14px 16px;
            }

            .btn-attach,
            .btn-mic,
            .btn-send {
                margin: 0;
            }

            /* Touch target minimum 44px */
            .btn-attach,
            .btn-mic {
                min-height: 44px;
                min-width: 44px;
                padding: 8px;
                justify-content: center;
            }

            #btn-templates {
                min-height: 44px;
                min-width: 44px;
                padding: 8px;
                justify-content: center;
            }

            /* Mermaid : conteneur scrollable horizontalement */
            .mermaid-diagram svg {
                min-width: 0;
                max-width: none;
            }

            /* Catégories fichiers : scroll horizontal et wrap */
            .files-categories {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                flex-wrap: nowrap;
                padding: 8px 14px 0;
            }

            /* Config : réduire le padding */
            .config-layout {
                padding: 16px 14px;
            }

            .config-sections {
                max-width: 100%;
                gap: 16px;
            }

            /* Config row : réduire le min-width du contrôle pour éviter l'écrasement du label */
            .config-row-control {
                min-width: 160px;
            }

            /* Description secondaire masquée sur tablet/mobile — libère de l'espace */
            .config-row-label span {
                display: none;
            }

            .source-snippet {
                font-size: 0.7rem;
            }

            .msg-badge,
            .confidence-badge {
                font-size: 0.65rem;
                padding: 1px 5px;
            }
        }

        /* ── Smartphone (≤ 480px) : layout ultra-compact ─────────── */
        @media (max-width: 480px) {
            .page-title {
                font-size: 0.92rem;
            }

            .page-subtitle {
                font-size: 0.74rem;
            }

            .page-header {
                padding: 0 10px 0 60px;
                min-height: 52px;
            }

            /* Cible tactile ≥ 44px, centrée dans le header 52px : (52-44)/2 */
            .btn-hamburger {
                top: 4px;
                width: 44px;
                height: 44px;
            }

            .page-header-actions > * {
                flex-shrink: 1;
            }

            .input-row {
                padding: 10px 8px 8px 12px;
                gap: 4px;
            }

            .chat-textarea {
                min-height: 48px;
            }

            .chat-textarea::placeholder {
                font-size: 0.8rem;
            }

            .input-hints {
                gap: 6px 8px;
                align-items: center;
                /* `nowrap` forçait la barre sur une seule ligne : en dessous de ~400 px, la
                   pastille de sources, les deux sélecteurs et l'interrupteur « Détails » ne
                   tiennent pas et débordaient horizontalement. On laisse passer à la ligne,
                   et chaque élément peut rétrécir (`min-width: 0`). */
                flex-wrap: wrap;
            }

            /* Rien ne doit dépasser la largeur de la barre. */
            .input-hints > * {
                min-width: 0;
                max-width: 100%;
            }

            /* Labels masqués sur petit écran : sélects côte à côte */
            .reasoning-label {
                display: none;
            }

            .input-hints .reasoning-mode-select {
                /* Base 120 px : deux sélecteurs tiennent côte à côte dès ~260 px de barre,
                   et passent l'un sous l'autre en dessous — au lieu d'être compressés à
                   l'illisible ou de pousser la barre hors de l'écran. */
                flex: 1 1 120px;
                min-width: 0;
                max-width: none;
                font-size: 0.65rem;
            }

            .hint-spacer,
            #session-id-hint {
                display: none;
            }

            /* Chat messages plus compactes */
            .chat-messages {
                padding: 12px 10px;
                gap: 10px;
            }

            .chat-input-bar {
                padding: 8px 10px 10px;
            }

            /* Modaux : bottom-sheet sur téléphone */
            .modal {
                align-items: flex-end;
            }

            .modal-box {
                width: 100%;
                max-width: 100%;
                border-radius: var(--radius-lg) var(--radius-lg) 0 0;
                max-height: 92dvh;
                overflow-y: auto;
                padding: 24px 20px;
            }

            /* Login gate padding réduit */
            .login-gate-box {
                padding: 28px 20px 24px;
            }

            /* Meta assistant : badges empilés en colonne sur petit écran */
            .message.assistant .msg-meta {
                flex-direction: column;
                align-items: flex-start;
                gap: 4px;
            }

            /* Meta user : reste en ligne, aligné à droite */
            .msg-meta-user {
                flex-direction: row;
                justify-content: flex-end;
                flex-wrap: nowrap;
            }

            .msg-time {
                margin-left: 0;
            }

            .upload-zone {
                margin: 12px 12px 0;
                padding: 16px 14px;
            }

            .files-toolbar {
                padding: 10px 12px;
            }

            .source-toggle-item {
                align-items: flex-start;
                gap: 8px;
            }

            .source-toggle-left {
                min-width: 0;
            }

            .source-toggle-name {
                overflow-wrap: anywhere;
            }

            /* Boutons d'action : cible tactile ≥ 44px */
            .btn-primary,
            .btn-auth,
            .nav-item,
            .btn-config-save {
                min-height: 44px;
            }

            .msg-bubble {
                font-size: 0.85rem;
                padding: 10px 12px;
            }

            .source-snippet {
                -webkit-line-clamp: 2;
            }

            /* Config row : empilement vertical sur petit écran */
            .config-row {
                flex-direction: column;
                gap: 10px;
            }

            /* flex-basis: 0% hérité de flex:1 causerait height:0 en mode colonne */
            .config-row-label {
                flex: 0 0 auto;
            }

            .config-row-control {
                min-width: 0;
                width: 100%;
            }

            /* Modal actions : wrap sur petit écran */
            .modal-actions {
                flex-wrap: wrap;
            }

            .modal-actions > * {
                flex: 1 1 auto;
            }

            /* Mermaid : scroll horizontal sur très petit écran */
            .mermaid-diagram svg {
                min-width: 0 !important;
                max-width: none !important;
            }

        }

        /* ── Très petits écrans (≤ 400px) ────────────────────────── */
        @media (max-width: 400px) {
            html {
                font-size: 14px;
            }

            .sidebar {
                width: 92vw;
                min-width: 92vw;
            }

            .suggestion-card {
                padding: 10px 12px;
                font-size: 0.78rem;
            }

            .input-hints .reasoning-mode-select {
                font-size: 0.72rem;
            }

            /* Toast pleine largeur */
            #toast-container {
                left: 8px;
                right: 8px;
                bottom: 8px;
            }

            .toast {
                max-width: none;
            }

            /* Health grid 1 colonne */
            .health-grid {
                grid-template-columns: 1fr;
            }

            .login-gate-box {
                padding: 24px 16px 20px;
                border-radius: 14px;
            }
        }

        /* ── iPhone notch / Dynamic Island (safe-area) ──────────── */
        @supports (padding-bottom: env(safe-area-inset-bottom)) {
            .chat-input-bar {
                padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
            }

            @media (max-width: 480px) {
                .chat-input-bar {
                    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
                }
            }

            .sidebar {
                padding-bottom: env(safe-area-inset-bottom, 0px);
            }
        }

        @keyframes spin {
            from {
                transform: rotate(0deg);
            }

            to {
                transform: rotate(360deg);
            }
        }

/* ── Template Library Modal ─────────────────────────────────────────── */
.template-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.72);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.template-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 720px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.template-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.template-modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.template-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.template-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.template-search-wrap {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.template-search-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.template-search-input:focus {
    border-color: var(--accent);
}

.template-modal-body {
    overflow-y: auto;
    padding: 16px 20px 20px;
    flex: 1;
}

.template-sector {
    margin-bottom: 20px;
}

.template-sector-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.template-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    text-align: left;
}

.template-card:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.template-card:active {
    transform: translateY(0);
}

.template-card-label {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.template-card-preview {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.template-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 32px 0;
}


@media (max-width: 600px) {
    .template-grid {
        grid-template-columns: 1fr;
    }

    .template-modal {
        max-height: 92vh;
    }
}

/* ── Bannière d'annonce (header) ───────────────────────────────────────── */
.announcement-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    row-gap: 6px;
    padding: 10px 16px;
    margin: 0 0 4px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.35;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.announcement-banner .ann-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.announcement-banner .ann-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.announcement-banner .ann-cta {
    flex: 0 0 auto;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent);
    white-space: nowrap;
}

.announcement-banner .ann-cta:hover {
    text-decoration: underline;
}

.announcement-banner .ann-dismiss {
    flex: 0 0 auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 6px;
}

.announcement-banner .ann-dismiss:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

/* ≤768px : décale la bannière SOUS le hamburger (fixe en haut à gauche, ~52px)
   pour que son cadre ne passe plus derrière le bouton. */
@media (max-width: 768px) {
    .announcement-banner {
        margin-top: 54px;
    }
}

/* Mobile : croix fixée en haut à droite, texte avec marge, CTA sur sa propre ligne. */
@media (max-width: 600px) {
    .announcement-banner {
        position: relative;
        padding: 8px 34px 8px 12px;
        gap: 8px;
        font-size: 0.82rem;
    }

    .announcement-banner .ann-cta {
        order: 3;
        flex-basis: 100%;
        white-space: normal;
    }

    .announcement-banner .ann-dismiss {
        position: absolute;
        top: 6px;
        right: 6px;
    }
}

.announcement-banner.ann-warning {
    border-color: var(--warning);
    background: rgba(251, 191, 36, 0.12);
}

.announcement-banner.ann-warning .ann-icon,
.announcement-banner.ann-warning .ann-cta {
    color: var(--warning);
}

.announcement-banner.ann-success {
    border-color: var(--green-text);
    background: rgba(25, 240, 94, 0.10);
}

.announcement-banner.ann-success .ann-icon,
.announcement-banner.ann-success .ann-cta {
    color: var(--green-text);
}

/* ── Repli de la zone de saisie — quand la place verticale est limitée ───────
   Portrait (toute largeur) OU paysage court (téléphone couché, hauteur ≤ 600px).
   Exclut desktop/tablette en paysage (hauteur suffisante). Le bouton-poignée
   reste visible pour ré-afficher la saisie. */
@media (orientation: portrait), (max-height: 600px) {
    .btn-toggle-input {
        display: flex;
        align-items: center;
        gap: 6px;
        width: fit-content;
        margin: 0 auto 8px;
        padding: 3px 14px;
        border: 1px solid var(--border);
        border-radius: 999px;
        background: var(--bg-secondary);
        color: var(--text-secondary);
        font-size: 0.72rem;
        cursor: pointer;
    }

    .btn-toggle-input .ti-chevron {
        transition: transform 0.2s ease;
    }

    .chat-input-bar.input-collapsed {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .chat-input-bar.input-collapsed > #sync-lock-banner,
    .chat-input-bar.input-collapsed > .input-row,
    .chat-input-bar.input-collapsed > .input-hints {
        display: none;
    }

    .chat-input-bar.input-collapsed .ti-chevron {
        transform: rotate(180deg);
    }
}

/* ── Mention de transparence AI Act (art. 50 §1) ──────────────────────────────
   Volontairement HORS de `.msg-bubble` : elle ne doit pas partir dans le
   presse-papiers quand l'utilisateur copie un e-mail ou un contrat généré.
   Discrète mais lisible — contraste vérifié sur le fond sombre. */
.ai-act-notice {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0 0;
    padding: 6px 10px;
    border-left: 2px solid var(--border);
    font-size: .72rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.ai-act-notice svg { flex-shrink: 0; margin-top: 2px; opacity: .7; }

/* ── Désaccord entre le traitement forcé et l'intention lue dans la phrase ─────
   Même gabarit que la mention AI Act (hors bulle, donc jamais copiée), mais
   accentué : c'est une explication ACTIONNABLE, pas une mention légale. */
/* ── Conversation vide : la saisie au centre, comme à l'ouverture d'un carnet ──
   Deux marges `auto` qui se partagent l'espace libre : l'en-tête reste collé en haut,
   le couple accueil + saisie se centre dans ce qui reste. Aucune valeur magique, donc
   le résultat tient à toutes les hauteurs d'écran.
   Dès le premier message, `is-empty` tombe et la saisie regagne le bas. */
#page-chat.is-empty .page-header-chat { margin-bottom: auto; }
#page-chat.is-empty .chat-messages {
    /* Le fond de la zone porte deux dégradés radiaux violets. Pleine hauteur, c'est un
       lavis discret ; réduite à la taille du salut, la même ellipse devient un HALO net
       derrière le texte — l'« ombre » visible à l'écran. Elle n'a plus lieu d'être ici. */
    background: none;
    padding-top: 0;
    /* `0 1 auto` et non `0 0 auto` : la zone prend sa hauteur naturelle mais accepte de
       se COMPRIMER. Sans `flex-shrink`, le bloc d'accueil (514 px) poussait la saisie
       sous la ligne de flottaison sur un écran de 800 px — mesuré, elle sortait de
       l'écran. `min-height: 0` est indispensable en flex : sans lui, un enfant
       scrollable refuse de descendre sous sa hauteur de contenu. */
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 0;
}
#page-chat.is-empty .chat-input-bar {
    /* Vertical : `margin-bottom: auto` face au `margin-bottom: auto` de l'en-tête —
       les deux se partagent l'espace libre et centrent le bloc.
       Horizontal : largeur bornée + marges latérales automatiques. Pleine largeur, la
       barre ne se lit pas comme une invite mais comme un pied de page. */
    margin-bottom: auto;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 860px;
    border-top: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    /* Correction OPTIQUE, et assumée comme telle. Les marges automatiques centrent
       exactement le groupe — mesuré, son centre tombe à 479 px pour une zone centrée à
       479,5. Mais le groupe porte sous la saisie une barre d'outils et la mention
       d'hygiène (~63 px) : l'œil, lui, cale sur la SAISIE, qui se retrouve donc basse.
       `transform` ne touche pas au flux — rien ne bouge, seul le rendu remonte. */
    transform: translateY(-1rem);
}

/* Une seule LIGNE : hors accueil, `.input-row` empile le champ au-dessus de ses icônes
   (colonne), ce qui donne un bloc d'environ 100 px. Au centre d'un écran vide, c'est une
   boîte, pas une invite. En rangée, le champ et les icônes tiennent sur la même ligne.
   Le champ garde son agrandissement automatique : dès que l'on écrit plusieurs lignes il
   grandit, exactement comme ailleurs. */
#page-chat.is-empty .input-row {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    padding: 4px 8px 4px 16px;
}
#page-chat.is-empty .chat-textarea {
    /* En colonne, le champ occupe `width: 100%` sans gêner personne. En RANGÉE, ce même
       100 % éjecte les icônes hors de la boîte : le bouton d'envoi sortait de l'écran.
       Il doit partager la ligne, donc grandir et rétrécir. `min-width: 0` lève la largeur
       minimale implicite d'un élément flex, sans laquelle il refuse de se comprimer. */
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 40px;
    padding: 9px 0;
}
#page-chat.is-empty .input-actions { flex: 0 0 auto; padding-bottom: 4px; }
/* Accueil resserré dans l'état centré UNIQUEMENT : à 800 px de haut, la seconde rangée
   de suggestions était coupée par la saisie remontée. Les valeurs d'origine restent en
   vigueur partout ailleurs — rien n'est perdu, seule la densité change là où l'espace
   est disputé. Mesuré : ~70 px regagnés, ce qui suffit aux quatre cartes. */
/* Dans une discussion neuve, la saisie prend la PLACE du bloc d'accueil — elle ne se
   glisse pas dessous. C'est ce qui permet le centrage vertical réel : l'accueil complet
   mesure 514 px pour une fenêtre utile d'environ 620, il ne restait rien à centrer.
   Le bloc n'est pas supprimé, seulement masqué dans cet état : il reste dans le DOM,
   `newChat()` continue de le restaurer, et une seule règle à retirer pour le rétablir. */
#page-chat.is-empty #welcome-msg > *:not(.welcome-greeting) { display: none; }
/* `padding: 40px` et `gap: 14px` du bloc d'accueil n'ont plus d'objet quand il ne porte
   que le salut : ils laissaient 90 px de vide entre celui-ci et la barre. */
#page-chat.is-empty #welcome-msg { flex: 0 0 auto; padding: 0; gap: 0; }

/* Le salut n'existe que dans la discussion neuve. */
.welcome-greeting { display: none; }
#page-chat.is-empty .welcome-greeting {
    display: block;
    /* `.welcome p` porte `max-width: 400px`, pensé pour le paragraphe descriptif : le salut
       en héritait et se coupait en deux lignes. */
    max-width: none;
    /* Serré contre la barre — mais pas dessus : la correction optique de la barre remonte
       celle-ci de 1 rem, qu'il faut rendre ici. À 10 px, le salut chevauchait le champ. */
    margin: 0 0 20px;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}
@media (max-width: 480px) {
    #page-chat.is-empty .welcome-greeting { font-size: 1.15rem; margin-bottom: 12px; }
}

/* La mention d'hygiène ne s'affiche QUE dans l'état d'accueil : répétée sous chaque
   message, elle deviendrait du bruit qu'on cesse de lire. */
.chat-hygiene-hint { display: none; }
#page-chat.is-empty .chat-hygiene-hint {
    display: block;
    margin: 10px auto 0;
    max-width: 62ch;
    text-align: center;
    font-size: .74rem;
    line-height: 1.5;
    color: var(--text-muted);
}
/* Le repli de la saisie sert à dégager l'écran pour LIRE les messages. Dans une discussion
   neuve il n'y en a aucun : le bouton n'offre que de cacher la seule chose présente, et il
   s'intercale entre le salut et la barre qu'il éloigne d'autant. */
#page-chat.is-empty .btn-toggle-input { display: none; }

@media (max-width: 480px) {
    /* Le centrage était désactivé ici quand l'accueil pesait 514 px : il mangeait la place
       utile. Il ne reste qu'un salut et une barre d'une ligne — le centrage a donc repris
       sa place, et la barre cesse d'être à l'autre bout de l'écran par rapport au salut.
       Seule la correction optique tombe : sur un écran étroit, 1 rem de décalage compte. */
    #page-chat.is-empty .chat-input-bar { transform: none; }
}

/* Rejeu avec un autre type de traitement — rattrapage POST-HOC du routage.
   Rendu en BLOC sous la barre d'actions plutôt qu'en menu flottant : aucun calcul de
   position, navigable au clavier sans piège de focus, et les puces passent à la ligne
   d'elles-mêmes sur un écran étroit. */
.router-retry-choices {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0;
    padding: 7px 10px;
    border-left: 2px solid var(--accent, #7c5cff);
    background: var(--surface-sunken, transparent);
    border-radius: 0 8px 8px 0;
}
.router-retry-label {
    font-size: .72rem;
    color: var(--text-muted);
    margin-right: 2px;
}
.router-retry-choice {
    background: var(--surface-card, transparent);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px 9px;
    font-size: .74rem;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}
.router-retry-choice:hover {
    border-color: var(--accent, #7c5cff);
    color: var(--accent, #7c5cff);
}
.router-retry-choice:focus-visible {
    outline: 2px solid var(--accent, #7c5cff);
    outline-offset: 2px;
}

.router-mismatch-notice {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0 0;
    padding: 6px 10px;
    border-left: 2px solid var(--warning, #d98324);
    font-size: .72rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.router-mismatch-notice svg { flex-shrink: 0; margin-top: 2px; opacity: .8; }
.router-mismatch-notice button {
    background: none;
    border: none;
    padding: 0;
    margin-left: 4px;
    font: inherit;
    color: var(--accent, #7c5cff);
    text-decoration: underline;
    cursor: pointer;
}
.router-mismatch-notice button:hover { opacity: .8; }
.router-mismatch-notice button:focus-visible { outline: 2px solid var(--accent, #7c5cff); outline-offset: 2px; }


/* Secondes écoulées pendant l'attente (2026-10-13) : discret, chiffres alignés. */
.thinking-chrono {
    margin-left: 6px;
    font-size: 0.85em;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
