* {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    :root {
        --primary: #1a4731;
        --primary-light: #2d6a4f;
        --secondary: #40916c;
        --text: #1b4332;
        --text-light: #588577;
        --background: #f8f9fa;
        --white: #ffffff;
        --glass: rgba(255, 255, 255, 0.6);
        --border: rgba(0, 0, 0, 0.08);
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
        --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
        --shadow-lg: 0 8px 12px rgba(0,0,0,0.1);
        --transition: all 0.3s ease-in-out;
        --border-radius: 12px;
        --font-size-base: 16px;
        --gold: #d4a373;
        --cream: #faf6f1;
    }

    body {
        font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        background: var(--background);
        color: var(--text);
        min-height: 100vh;
        line-height: 1.6;
        font-size: var(--font-size-base);
    }

    .chat-container {
        max-width: 600px;
        margin: 1rem auto;
        height: auto;
        min-height: calc(100vh - 2rem);
        display: flex;
        flex-direction: column;
        background: var(--glass);
        position: relative;
        overflow: hidden;
        box-shadow: var(--shadow-lg);
        border-radius: var(--border-radius);
        backdrop-filter: blur(12px);
        border: 1px solid var(--border);
    }

    .chat-header {
        background: linear-gradient(135deg, var(--primary), var(--primary-light));
        color: var(--white);
        padding: 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: relative;
        z-index: 10;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .chat-header img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid rgba(255,255,255,0.7);
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }

    .chat-header img:hover {
        transform: scale(1.1);
        box-shadow: var(--shadow-md);
    }

    .chat-header-info {
        flex: 1;
    }

    .chat-header h2 {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.1rem;
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    .chat-header .status {
        font-size: 0.75rem;
        opacity: 0.85;
        display: flex;
        align-items: center;
        gap: 5px;
        text-shadow: 0 1px 1px rgba(0,0,0,0.08);
    }

    .status::before {
        content: '';
        width: 7px;
        height: 7px;
        background: var(--secondary);
        border-radius: 50%;
        box-shadow: 0 0 0 1.5px rgba(64,145,108,0.2), 0 0 4px rgba(64,145,108,0.3);
        animation: statusPulse 2s infinite;
    }

    @keyframes statusPulse {
        0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(64,145,108,0.4), 0 0 0 0 rgba(64,145,108,0.2); }
        70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(64,145,108,0), 0 0 0 9px rgba(64,145,108,0); }
        100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(64,145,108,0), 0 0 0 0 rgba(64,145,108,0); }
    }

    #chatHistory {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        background: transparent;
        scroll-behavior: smooth;
        display: flex;
        flex-direction: column;
    }

    .message {
        max-width: 85%;
        margin: 0.5rem 0;
        padding: 0.6rem 0.8rem;
        border-radius: 10px;
        position: relative;
        font-size: 0.9rem;
        line-height: 1.4;
        letter-spacing: 0.2px;
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
        word-break: break-word;
    }

    .message:hover {
        box-shadow: var(--shadow-md);
    }

    .question {
        background: var(--cream);
        margin-right: auto;
        border-top-left-radius: 4px;
    }

    .user-response {
        background: rgba(64, 145, 108, 0.15);
        margin-left: auto;
        border-top-right-radius: 4px;
    }

    .feedback {
        background: var(--cream);
        margin-right: auto;
        border-top-left-radius: 4px;
    }

    .timestamp {
        font-size: 0.7rem;
        color: var(--text-light);
        margin-top: 4px;
        display: block;
        text-align: right;
    }

    #thinkingIndicator {
        display: none;
        padding: 1rem;
        background: var(--glass);
        backdrop-filter: blur(10px);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-lg);
        margin: 0.75rem;
        text-align: center;
    }

    .loader {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .loader span {
        width: 7px;
        height: 7px;
        background: var(--primary);
        border-radius: 50%;
        display: inline-block;
        animation: bounce 1.4s infinite cubic-bezier(0.45, 0.05, 0.55, 0.95);
    }

    @keyframes bounce {
        0%, 100% { transform: translateY(0) scale(1); background: var(--primary); }
        50% { transform: translateY(-8px) scale(1.1); background: var(--secondary); }
    }

    #thinkingText {
        color: var(--text);
        font-size: 0.8rem;
        font-weight: 500;
        margin-top: 8px;
        opacity: 0.8;
    }

    .chat-input-container {
        background: rgba(255, 255, 255, 0.7);
        padding: 0.75rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        border-top: 1px solid var(--border);
        backdrop-filter: blur(8px);
        box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
    }

    #userAnswer {
        flex: 1;
        padding: 0.6rem 0.8rem;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: var(--white);
        font-size: 0.9rem;
        color: var(--text);
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }

    #userAnswer:focus {
        outline: none;
        border-color: var(--secondary);
        box-shadow: 0 0 0 2px rgba(64, 145, 108, 0.2);
    }

    button {
        background: linear-gradient(135deg, var(--primary), var(--primary-light));
        color: var(--white);
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 16px;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition);
        box-shadow: var(--shadow-sm);
    }

    button:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }

    button:disabled {
        background: #ccc;
        cursor: not-allowed;
        box-shadow: none;
        transform: none;
    }

    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.03);
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb {
        background: linear-gradient(to bottom, var(--primary), var(--primary-light));
        border-radius: 3px;
        border: 1px solid transparent;
        background-clip: content-box;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(to bottom, var(--primary-light), var(--secondary));
    }

    @keyframes messageIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .message.new {
        animation: messageIn 0.2s ease-out;
    }

    .floating-buttons-container {
        position: fixed;
        bottom: 80px; 
        right: 20px; 
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        z-index: 1000;
    }

    .floating-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        box-shadow: var(--shadow-md);
        transition: var(--transition);
        font-size: 1.5rem;
        color: white;
        text-decoration: none;  /* Important pour les liens <a> */
    }

    .floating-button:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-lg);
    }

    .reset-button {
        background: var(--primary);
    }

    .home-button {
        background: var(--secondary);
    }

    @media (max-width: 768px) {
        :root {
            --font-size-base: 15px;
            --border-radius: 8px;
        }

        .chat-container {
            margin: 0;
            border-radius: 0;
            width: 100%;
            min-height: 100vh;
        }

        .chat-header {
            padding: 0.75rem;
        }

        .chat-header img {
            width: 35px;
            height: 35px;
        }

        .chat-header h2 {
            font-size: 0.9rem;
        }

        .chat-header .status {
            font-size: 0.7rem;
        }

        #chatHistory {
            padding: 0.75rem;
        }

        .message {
            max-width: 95%;
            padding: 0.5rem 0.7rem;
            font-size: 0.85rem;
            border-radius: 8px;
        }

        .chat-input-container {
            padding: 0.6rem;
        }

        #userAnswer {
            padding: 0.5rem 0.7rem;
            font-size: 0.8rem;
        }

        button {
            padding: 0.4rem 0.8rem;
            font-size: 0.75rem;
        }

        #thinkingIndicator {
            padding: 0.75rem;
            margin: 0.5rem;
        }

        .floating-buttons-container {
            bottom: 65px;
            right: 15px;
            gap: 8px;
        }

        .floating-button {
            width: 40px;
            height: 40px;
            font-size: 1.2rem;
        }
    }
    .rtl-text {
        direction: rtl;
        text-align: right;
        unicode-bidi: bidi-override;
    }

    .rtl-text .timestamp {
        float: left;
    }

    [dir="rtl"] .message {
        border-radius: 15px 0 15px 15px;
        margin-left: auto;
        margin-right: 10px;
    }

    [dir="ltr"] .message {
        border-radius: 0 15px 15px 15px;
        margin-left: 10px;
        margin-right: auto;
    }
    .arabic-text {
        direction: rtl;
        text-align: right;
        unicode-bidi: embed; 
    }

    .malagasy-text {
        direction: ltr;
        text-align: left;
        unicode-bidi: normal;
    }
    .highlighted-text {
        font-weight: bold;
        color: var(--gold);
    }