        @import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400&family=Lato:wght@300;400&display=swap');

        :root {
            --nav-height: 72px;
            --primary-blue: #0056b3;
            --light-blue: #e3f2fd;
            --dark-bg: #1f1f1f;
            --gray-bg: #f5f5f5;
        }

        * { box-sizing: border-box; }

        body {
            margin: 0;
            padding: 0;
            font-family: 'Lato', sans-serif;
            background-color: #999;
            padding-top: var(--nav-height);
            min-height: 100dvh;
        }


        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            min-height: calc(100dvh - var(--nav-height));
        }

        .expert-container {
            background: white;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            padding: clamp(28px, 4vw, 40px);
            min-height: calc(100dvh - var(--nav-height) - 80px);
            display: flex;
            flex-direction: column;
            margin-top: 16px;
        }

        .expert-header {
            margin-bottom: 16px;
        }

        .expert-title {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            font-family: 'Lato', sans-serif;
            font-size: clamp(2rem, 3vw, 2.2rem);
            font-weight: 700;
            color: #333;
            border-bottom: 2px solid #0056b3;
            padding-bottom: 10px;
            margin: 0 0 18px 0;
            text-align: center;
        }

        .subtitle {
            font-family: 'Lato', sans-serif;
            font-weight: 400;
            font-size: clamp(1.05rem, 2vw, 1.2rem);
            margin: 0 0 14px 0;
            color: #444;
        }

        .info-banner { display: none; }

        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            border: 1px solid #ddd;
            border-radius: 8px;
            overflow: hidden;
            min-height: 500px;
            margin-top: 0;
            max-height: calc(100dvh - var(--nav-height) - 220px);
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            background: #fafafa;
            min-height: 0;
        }

        .message {
            margin-bottom: 16px;
            padding: 0;
            animation: fadeIn 0.3s ease-in;
        }

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

        .message-user {
            text-align: right;
        }

        .message-content {
            display: inline-block;
            max-width: 80%;
            padding: 12px 18px;
            border-radius: 18px;
            line-height: 1.6;
            white-space: pre-wrap;
        }

        .message-user .message-content {
            background: var(--primary-blue);
            color: white;
        }

        .message-assistant .message-content {
            background: white;
            color: #333;
            box-shadow: 0 1px 2px rgba(0,0,0,0.1);
            text-align: left;
            line-height: 1.6;
        }

        .message-user .message-content {
            background: var(--primary-blue);
            color: white;
            box-shadow: none;
        }

        .message-assistant .message-content p {
            margin: 0;
        }

        .message-assistant .message-content p + p {
            margin-top: 8px;
        }

        /* Bandeau d'introduction hors du flux de messages */
        #chat-intro {
            background: white;
            border-bottom: 1px solid #eee;
        }

        .chat-intro-message {
            padding: 10px 20px;
            color: #333;
            line-height: 1.6;
        }

        .chat-intro-message p {
            margin: 0;
        }

        .message-assistant .message-content a {
            color: var(--primary-blue);
            text-decoration: underline;
            font-weight: 500;
        }

        .message-assistant .message-content a:hover {
            color: #003f82;
        }

        .message-assistant .message-content ul,
        .message-assistant .message-content ol {
            margin: 15px 0;
            padding-left: 20px;
        }

        .message-assistant .message-content li {
            margin: 4px 0;
            line-height: 1.5;
        }

        .message-assistant .message-content li > ul,
        .message-assistant .message-content li > ol {
            margin: 4px 0;
        }

        .message-assistant .message-content .chat-table-wrap {
            max-width: 100%;
            overflow-x: auto;
            margin: 10px 0;
        }

        .message-assistant .message-content .chat-table {
            border-collapse: collapse;
            font-size: 0.92em;
            line-height: 1.4;
            white-space: normal;
        }

        .message-assistant .message-content .chat-table th,
        .message-assistant .message-content .chat-table td {
            border: 1px solid #dde3ea;
            padding: 6px 10px;
            text-align: left;
            vertical-align: top;
        }

        .message-assistant .message-content .chat-table th {
            background: #eef3f8;
            color: var(--primary-blue);
            font-weight: 600;
        }

        .message-assistant .message-content .chat-table tbody tr:nth-child(even) {
            background: #f8fafc;
        }

        .message-assistant .message-content p + ul,
        .message-assistant .message-content p + ol {
            margin-top: 10px;
        }

        .message-assistant .message-content strong {
            font-weight: 600;
        }

        .message-assistant .message-content h1,
        .message-assistant .message-content h2,
        .message-assistant .message-content h3,
        .message-assistant .message-content h4 {
            margin: 0 0 10px 0;
            font-weight: 600;
            color: #333;
        }

        .message-assistant .message-content h1 {
            font-size: 1.5em;
            border-bottom: 2px solid #e0e0e0;
            padding-bottom: 5px;
        }

        .message-assistant .message-content h2 {
            font-size: 1.3em;
        }

        .message-assistant .message-content h3 {
            font-size: 1.15em;
            color: var(--primary-blue);
        }

        .message-assistant .message-content h4 {
            font-size: 1.05em;
        }

        .resource-back-button img {
            width: 24px;
            height: 24px;
            opacity: 0.8;
            transition: opacity 0.2s ease;
        }

        .resource-back-button:hover img { opacity: 1; }
        .resource-back-button:focus-visible img { outline: 2px solid #FFD700; outline-offset: 2px; }

        footer {
            background: #1f1f1f;
            color: #fff;
            text-align: center;
            padding: 20px;
            margin-top: 40px;
        }

        .message-assistant .message-content br {
            display: block;
            content: "";
            margin: 5px 0;
        }

        .typing-indicator {
            display: inline-block;
            padding: 12px 18px;
            background: white;
            border-radius: 18px;
            box-shadow: 0 1px 2px rgba(0,0,0,0.1);
        }

        .typing-indicator span {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #999;
            margin: 0 2px;
            animation: bounce 1.4s infinite ease-in-out both;
        }

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

        @keyframes bounce {
            0%, 80%, 100% { transform: scale(0); }
            40% { transform: scale(1); }
        }

        .chat-input-container {
            padding: 20px;
            background: white;
            border-top: 1px solid #ddd;
            position: sticky;
            bottom: 0;
            z-index: 2;
        }

        .chat-actions {
            display: flex;
            justify-content: center;
            gap: 22px;
            flex-wrap: wrap;
        }

        .chat-reset-button {
            display: block;
            margin: 10px 0 0;
            padding: 4px 12px;
            border: none;
            background: none;
            color: #777;
            font-family: 'Lato', sans-serif;
            font-size: 0.85rem;
            text-decoration: underline;
            cursor: pointer;
        }

        .chat-reset-button:hover { color: var(--primary-blue); }

        /* Réponse tranchée par la limite de durée du serveur : on le dit, sobrement. */
        .message-coupure {
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px dashed #d0d0d0;
            color: #8a6d3b;
            font-size: 0.88rem;
            font-style: italic;
        }

        .chat-input-form {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .chat-input {
            flex: 1;
            padding: 12px 18px;
            border: 2px solid #ddd;
            border-radius: 24px;
            font-size: 1rem;
            font-family: 'Lato', sans-serif;
            outline: none;
            transition: border-color 0.2s;
        }

        .chat-input:focus {
            border-color: var(--primary-blue);
        }

        .chat-send-button {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            border: none;
            background: var(--primary-blue);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: transform 0.15s ease, background-color 0.2s ease;
            padding: 0;
        }

        .chat-send-button svg {
            width: 22px;
            height: 22px;
            fill: white;
        }

        .chat-send-button:hover {
            background: #003f82;
            transform: translateY(-1px);
        }

        .chat-send-button:active {
            transform: scale(0.97);
        }

        .chat-send-button:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        .chat-send-button.is-stop {
            background: var(--primary-blue);
        }

        .chat-send-button.is-pulsing {
            animation: pulseStop 1.2s ease-in-out infinite;
        }

        @keyframes pulseStop {
            0% { box-shadow: 0 0 0 0 rgba(0, 86, 179, 0.35); }
            50% { box-shadow: 0 0 0 10px rgba(0, 86, 179, 0); }
            100% { box-shadow: 0 0 0 0 rgba(0, 86, 179, 0); }
        }

        .error-message {
            background: #ffebee;
            border-left: 4px solid #d32f2f;
            padding: 15px 20px;
            margin: 10px 0;
            border-radius: 4px;
            color: #c62828;
        }

        .suggested-questions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            padding: 8px 20px 12px;
            background: white;
        }

        .question-chip {
            padding: 7px 14px;
            border: 1px solid #0056b3;
            border-radius: 20px;
            background: white;
            color: #0056b3;
            font-size: 0.88rem;
            font-family: 'Lato', sans-serif;
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
            text-align: left;
        }

        .question-chip:hover {
            background: #0056b3;
            color: white;
        }

        @media (max-width: 768px) {
            .container { padding: 10px; }
            .expert-container {
                padding: 16px;
                min-height: calc(100dvh - var(--nav-height) - 20px);
                margin-top: 8px;
            }
            .chat-container {
                min-height: 0;
                max-height: calc(100dvh - var(--nav-height) - 150px);
            }
            .chat-messages {
                padding: 14px;
            }
            .chat-input-container {
                padding: 12px;
                padding-bottom: max(12px, env(safe-area-inset-bottom));
            }
            .chat-input {
                font-size: 16px;
            }
            .expert-header h1 { font-size: 1.5rem; }
            .expert-header p { font-size: 0.95rem; }
            .message-content { max-width: 90%; }
        }

        @media (max-height: 760px) {
            .expert-container {
                min-height: calc(100dvh - var(--nav-height) - 12px);
            }
            .chat-container {
                min-height: 0;
                max-height: calc(100dvh - var(--nav-height) - 120px);
            }
            .chat-intro-message {
                padding: 8px 14px;
            }
            .suggested-questions {
                padding: 6px 14px 10px;
            }
            .chat-input-container {
                padding: 10px 12px;
            }
        }
    
