/**
 * ============================================================================
 * BUBUL - MAIN STYLESHEET
 * ============================================================================
 *
 * Point d'entrée CSS principal.
 * Utilise Tailwind CSS v4 avec les styles legacy.
 *
 * ============================================================================
 */

/* === HIGHLIGHT.JS THEME === */
@import 'highlight.js/styles/github-dark.css';

/* === KATEX (rendu LaTeX dans l'éditeur Moodia) === */
@import 'katex/dist/katex.min.css';

/* === TAILWIND CSS === */
@import "tailwindcss";
@source not "../../public";
@source "../../templates";
@source "../../assets/controllers";

/* === VARIABLES (couleurs, ombres, etc.) === */
@import "./variables.css";

/* === PAGE-SPECIFIC STYLES === */
@import "./pages/auth.css";
@import "./pages/moodia/editor.css";
@import "./pages/slidia/editor.css";
@import "./pages/slidia/index.css";
@import "./pages/slidia/create.css";
@import "./pages/slidia/generate.css";
@import "./pages/landing.css";
@import "./pages/onboarding.css";
@import "./pages/sam.css";
@import "./pages/dashboard.css";
@import "./pages/promptly.css";
@import "./pages/pixia.css";
@import "./pages/badges.css";

/* Tutoriels interactifs — un seul fichier, un seul import : le retirer suffit à
   désinstaller l'habillage du tutoriel. */
@import "./components/tour.css";

/* === BASE STYLES === */
@layer base {
    *, *::before, *::after {
        box-sizing: border-box;
    }

    html {
        font-size: 16px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        line-height: 1.5;
    }

    h1, h2, h3, h4, h5, h6 {
        font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        font-weight: 700;
        line-height: 1.25;
    }

    /* Tailwind v4 a retiré le cursor:pointer par défaut des <button>.
       On le rétablit sur tous les éléments cliquables (hors désactivés).
       Les utilitaires .cursor-* (layer utilities) restent prioritaires,
       donc .cursor-not-allowed / .cursor-default gardent la main. */
    button:not(:disabled),
    [role="button"]:not([aria-disabled="true"]),
    [data-action*="click->"]:not(:disabled),
    summary,
    select:not(:disabled),
    input[type="checkbox"]:not(:disabled),
    input[type="radio"]:not(:disabled),
    input[type="submit"]:not(:disabled),
    input[type="button"]:not(:disabled),
    input[type="file"]:not(:disabled)::file-selector-button,
    input[type="file"]:not(:disabled) {
        cursor: pointer;
    }
}

/* === UTILITIES === */
@layer utilities {
    /* Masquer la scrollbar sur tous les navigateurs */
    .scrollbar-none {
        -ms-overflow-style: none;  /* IE/Edge */
        scrollbar-width: none;     /* Firefox */
    }
    .scrollbar-none::-webkit-scrollbar {
        display: none;             /* Chrome/Safari/Opera */
    }

    /* Scrollbar fine stylisee (primary) */
    .scrollbar-thin {
        scrollbar-width: thin;
        scrollbar-color: rgb(12 129 228 / 0.3) rgb(12 129 228 / 0.06);
    }
    .scrollbar-thin::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    .scrollbar-thin::-webkit-scrollbar-track {
        background: rgb(12 129 228 / 0.06);
        border-radius: 3px;
    }
    .scrollbar-thin::-webkit-scrollbar-thumb {
        background: rgb(12 129 228 / 0.3);
        border-radius: 3px;
    }
    .scrollbar-thin::-webkit-scrollbar-thumb:hover {
        background: rgb(12 129 228 / 0.5);
    }

    /* Slidia drag & drop active state */
    .slidia-dropzone-active {
        border-color: var(--color-primary) !important;
        background-color: rgb(12 129 228 / 0.05) !important;
    }

    /* ================================================================= */
    /* COLLAPSIBLE - Animation d'ouverture/fermeture                     */
    /* ================================================================= */

    .collapsible-open {
        display: block;
        opacity: 1;
    }

    .collapsible-closed {
        display: none;
        opacity: 0;
    }

    /* ================================================================= */
    /* SLIDIA - Radio Card Styles                                        */
    /* ================================================================= */
    /* Styles pour les cartes radio personnalisées.                      */
    /* Utilise .is-selected au lieu de :has(input:checked) pour          */
    /* une meilleure compatibilité navigateur.                           */
    /* ================================================================= */

    .slidia-radio-card.is-selected {
        border-color: var(--color-primary);
        background-color: var(--color-primary-muted);
        box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    }

    .slidia-radio-card.is-selected .slidia-radio-indicator {
        opacity: 1;
        transform: scale(1);
    }

    .slidia-radio-card.is-selected .slidia-radio-dot {
        border-color: var(--color-primary);
    }

    .slidia-radio-card.is-selected .slidia-radio-dot > div {
        opacity: 1;
        transform: scale(1);
    }

    /* ================================================================= */
    /* CASTIA - Dynamic State Classes (JS-toggled)                        */
    /* ================================================================= */

    /* Voice preview playing state */
    .castia-preview-playing {
        background-color: var(--color-primary) !important;
        color: #fff !important;
    }

    /* Voice star active (favorited) state */
    .castia-star-active {
        color: var(--color-warning) !important;
        opacity: 1 !important;
    }

    .castia-star-active:hover {
        color: var(--color-warning-dark) !important;
    }

    /* Always show buttons when star is active */
    [data-castia-voice]:has(.castia-star-active) [data-castia-voice-btns] {
        opacity: 1;
    }

    /* ================================================================= */
    /* SERENIA - Voice Recording Active State                             */
    /* ================================================================= */

    .seren-ia__voice-btn--active {
        color: #fff !important;
        background-color: var(--color-error) !important;
        animation: voice-pulse 1.5s ease-in-out infinite;
    }

    @keyframes voice-pulse {
        0%, 100% {
            box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
        }
        50% {
            box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
        }
    }

    /* ================================================================= */
    /* NAV ITEM — Couleur dynamique par outil (--tool-rgb)               */
    /* ================================================================= */
    /* --tool-rgb est défini via inline style par la sidebar.             */
    /* --tool-rgb a une valeur de repli grise pour éviter rgb() invalide → noir */

    .nav-item--tool {
        --tool-rgb: 107, 114, 128;
    }

    .nav-item--tool:hover {
        background: linear-gradient(135deg, rgba(var(--tool-rgb), 0.12) 0%, rgba(var(--tool-rgb), 0.08) 100%);
        color: rgb(var(--tool-rgb));
    }

    .nav-item--tool[aria-current="page"],
    .nav-item--tool.nav-item--active {
        background: linear-gradient(135deg, rgba(var(--tool-rgb), 0.15) 0%, rgba(var(--tool-rgb), 0.10) 100%);
        color: rgb(var(--tool-rgb));
        font-weight: 600;
    }

}

/* === COMPONENTS === */
@layer components {
    /* Symfony Form Inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        width: 100%;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        line-height: 1.5;
        color: var(--color-gray-900, #111827);
        background-color: #fff;
        border: 1px solid var(--color-gray-200, #e5e7eb);
        border-radius: 0.75rem;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus,
    input[type="number"]:focus,
    input[type="tel"]:focus,
    input[type="url"]:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: var(--color-primary, #0C81E4);
        box-shadow: 0 0 0 3px rgba(12, 129, 228, 0.1);
    }

    input::placeholder,
    textarea::placeholder {
        color: var(--color-gray-400, #9ca3af);
    }

    /* Symfony Form Labels */
    label {
        display: block;
        margin-bottom: 0.375rem;
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--color-gray-700, #374151);
    }

    /* Containers pour alertes/notifications */
    .container-success {
        background: linear-gradient(135deg, rgba(48, 147, 68, 0.08), rgba(52, 211, 153, 0.04));
        border: 1px solid rgba(48, 147, 68, 0.15);
    }

    .container-warning {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.04));
        border: 1px solid rgba(245, 158, 11, 0.2);
    }

    .container-error {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(248, 113, 113, 0.04));
        border: 1px solid rgba(239, 68, 68, 0.2);
    }

    .container-info {
        background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(125, 211, 252, 0.04));
        border: 1px solid rgba(14, 165, 233, 0.2);
    }

    .container-cohorts {
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
        border: 1px solid rgba(139, 92, 246, 0.2);
    }

    /* Containers avec fonds pastel (variantes muted) */
    .container-primary-muted {
        background: linear-gradient(135deg, rgb(12 129 228 / 0.06), var(--color-primary-muted));
        border: 1px solid var(--color-primary-subtle);
    }

    .container-warning-muted {
        background: linear-gradient(135deg, rgb(255 193 7 / 0.08), var(--color-warning-muted));
        border: 1px solid var(--color-warning-subtle);
    }

    /* Logo SVG container - force SVG to fill container */
    .logo-svg-container svg {
        width: 100%;
        height: 100%;
    }

    /* ================================================================= */
    /* SERENIA - Minimal Styles (Full Tailwind conversion)                */
    /* ================================================================= */
    /* Only keeping:                                                      */
    /* - Textarea override for proper styling                             */
    /* - Prose styles for Markdown rendering (cannot be inline)           */
    /* - Copy button hover on message                                     */
    /* ================================================================= */

    /* --- Textarea override (resets default input styles) --- */
    .serenia-textarea {
        width: 100%;
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
        border: none;
        border-radius: 0;
        background: transparent;
    }
    .serenia-textarea:focus {
        outline: none;
        border-color: transparent;
        box-shadow: none;
    }

    /* --- Messages area scrollbar --- */
    .serenia-messages {
        scrollbar-width: thin;
        scrollbar-color: var(--color-gray-300) transparent;
    }
    .serenia-messages::-webkit-scrollbar {
        width: 5px;
    }
    .serenia-messages::-webkit-scrollbar-track {
        background: transparent;
    }
    .serenia-messages::-webkit-scrollbar-thumb {
        background: var(--color-gray-300);
        border-radius: 9999px;
    }
    .serenia-messages::-webkit-scrollbar-thumb:hover {
        background: var(--color-gray-400);
    }

    /* --- Prose styles for Markdown content (inside assistant messages) --- */
    /* --- Titres : les dispositifs de Scormia, a l'echelle du chat -----------
       Scormia signe ses titres par une barre d'accent : soulignement court
       (54x4) sous un titre, barre laterale (5x24) devant un sous-titre. Ce
       sont ces DISPOSITIFS qui font l'identite, pas leurs dimensions — un
       titre de 32px concu pour une page de cours n'a rien a faire dans une
       colonne de conversation a 14px. Les proportions sont donc transposees,
       le geste conserve. */

    .serenia-prose h1 {
        margin: 1.125rem 0 0.5rem 0;
        font-weight: 700;
        font-size: 1.25rem;
        color: var(--color-gray-900);
        font-family: 'Poppins', sans-serif;
    }

    .serenia-prose h1::after {
        content: '';
        display: block;
        width: 3rem;
        height: 3px;
        border-radius: 99px;
        background: var(--color-cohorts);
        margin-top: 0.5rem;
    }

    .serenia-prose h2 {
        margin: 1rem 0 0.375rem 0;
        font-weight: 600;
        font-size: 1.1rem;
        color: var(--color-gray-900);
        font-family: 'Poppins', sans-serif;
    }

    .serenia-prose h2::after {
        content: '';
        display: block;
        width: 2.25rem;
        height: 2.5px;
        border-radius: 99px;
        background: color-mix(in srgb, var(--color-cohorts) 55%, white);
        margin-top: 0.375rem;
    }

    /* Sous-titre : la barre laterale de Scormia. Le premier enfant ne doit pas
       decoller du titre qui le precede, d'ou la marge haute reduite. */
    .serenia-prose h3 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0.875rem 0 0.375rem 0;
        font-weight: 600;
        font-size: 1rem;
        color: var(--color-gray-800);
        font-family: 'Poppins', sans-serif;
    }

    .serenia-prose h3::before {
        content: '';
        flex: 0 0 auto;
        width: 3px;
        height: 1rem;
        border-radius: 99px;
        background: var(--color-cohorts);
    }

    /* Liens : traitement exact de Scormia — accent, soulignement decolle et
       attenue, qui s'affirme au survol. */
    .serenia-prose a {
        color: var(--color-cohorts-dark);
        text-decoration: underline;
        text-underline-offset: 3px;
        text-decoration-color: color-mix(in srgb, var(--color-cohorts) 45%, transparent);
        transition: text-decoration-color 0.15s;
    }

    .serenia-prose a:hover {
        text-decoration-color: var(--color-cohorts);
    }

    .serenia-prose p {
        margin: 0.5rem 0;
        line-height: 1.8;
    }

    .serenia-prose p + p {
        margin-top: 0.625rem;
    }

    /* Le gras porte la couleur de l'outil : c'est le repere le plus frequent
       dans une reponse, donc celui qui fait le plus pour la rendre vivante. */
    .serenia-prose strong {
        font-weight: 600;
        color: var(--color-cohorts-dark);
    }

    .serenia-prose em {
        font-style: italic;
        color: var(--color-gray-600);
    }

    .serenia-prose code {
        background: var(--color-gray-100);
        padding: 0.125rem 0.375rem;
        border-radius: 0.25rem;
        font-family: 'Courier New', monospace;
        font-size: 0.8125rem;
        /* --color-primary est le bleu global : sur une page Serenia, violette,
           il jurait. Le code suit desormais la couleur de l'outil. */
        color: var(--color-cohorts-dark);
        background: color-mix(in srgb, var(--color-cohorts) 8%, white);
    }

    .serenia-prose pre {
        background: var(--color-gray-900);
        color: var(--color-gray-100);
        padding: 0.875rem 1rem;
        border-radius: 0.75rem;
        overflow-x: auto;
        margin: 0.75rem 0;
        font-size: 0.8125rem;
        line-height: 1.5;
    }

    .serenia-prose pre code {
        background: none;
        color: inherit;
        padding: 0;
    }

    .serenia-prose ul,
    .serenia-prose ol {
        padding-left: 1.5rem;
        margin: 0.5rem 0;
        line-height: 1.8;
    }

    .serenia-prose li {
        margin: 0.125rem 0;
        padding-left: 0.25rem;
    }

    /* --- Puces : le fil violet ---------------------------------------------
       Un seul geste chromatique traverse toute la reponse — puces, filet de
       citation, en-tete de tableau, separateur — pour que l'oeil suive une
       colonne vertebrale plutot que de la couleur saupoudree.
       Les teintes sont derivees de --color-cohorts : si la couleur de l'outil
       change en base, l'habillage suit sans retoucher une ligne. */

    .serenia-prose ul {
        list-style: none;
        padding-left: 1.25rem;
    }

    .serenia-prose ul > li {
        position: relative;
        padding-left: 0.875rem;
    }

    .serenia-prose ul > li::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0.7em;
        width: 0.375rem;
        height: 0.375rem;
        border-radius: 2px;
        background: var(--color-cohorts);
        transform: rotate(45deg);
    }

    /* Le niveau imbrique passe en anneau creux : la profondeur est encodee,
       pas decoree. Le selecteur vise « ul dans un li » et non « ul dans ul »,
       pour que la puce soit la meme qu'on imbrique sous une liste a puces ou
       sous une liste numerotee. */
    .serenia-prose li ul > li::before {
        background: transparent;
        border: 1.5px solid var(--color-cohorts-light);
    }

    /* Une liste numerotee EST une sequence : le numero porte une information,
       il merite donc d'etre mis en avant. */
    .serenia-prose ol {
        list-style: none;
        counter-reset: serenia-ol;
        padding-left: 1.25rem;
    }

    .serenia-prose ol > li {
        position: relative;
        counter-increment: serenia-ol;
        padding-left: 1.5rem;
    }

    .serenia-prose ol > li::before {
        content: counter(serenia-ol);
        position: absolute;
        left: 0;
        top: 0.28em;
        min-width: 1.125rem;
        height: 1.125rem;
        padding: 0 0.25rem;
        border-radius: 0.3125rem;
        background: color-mix(in srgb, var(--color-cohorts) 14%, white);
        color: var(--color-cohorts-dark);
        font-size: 0.6875rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .serenia-prose ul ul,
    .serenia-prose ol ul,
    .serenia-prose ul ol,
    .serenia-prose ol ol {
        margin: 0.25rem 0;
        padding-left: 1rem;
    }

    .serenia-prose blockquote {
        border-left: 3px solid var(--color-cohorts);
        background: color-mix(in srgb, var(--color-cohorts) 5%, white);
        border-radius: 0 0.5rem 0.5rem 0;
        padding: 0.5rem 0.75rem;
        margin: 0.75rem 0;
        color: var(--color-gray-700);
        font-style: normal;
    }

    /* --- Tableaux ---
       Coins arrondis via overflow sur un conteneur : border-collapse les
       ecraserait. Le defilement horizontal evite qu'un tableau large
       n'elargisse toute la colonne de conversation. */
    .serenia-prose table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        margin: 0.875rem 0;
        font-size: 0.8125rem;
        border: 1px solid color-mix(in srgb, var(--color-cohorts) 22%, white);
        border-radius: 0.625rem;
        overflow: hidden;
        display: table;
    }

    .serenia-prose table th,
    .serenia-prose table td {
        padding: 0.5rem 0.75rem;
        text-align: left;
        border-bottom: 1px solid var(--color-gray-100);
    }

    .serenia-prose table tr:last-child td {
        border-bottom: none;
    }

    .serenia-prose table th {
        background: color-mix(in srgb, var(--color-cohorts) 10%, white);
        color: var(--color-cohorts-dark);
        font-weight: 600;
        border-bottom: 1px solid color-mix(in srgb, var(--color-cohorts) 22%, white);
    }

    /* Zebrures a peine perceptibles : elles guident l'oeil sans quadriller. */
    .serenia-prose table tbody tr:nth-child(even) {
        background: color-mix(in srgb, var(--color-cohorts) 3%, white);
    }

    /* Le gras d'une premiere colonne sert d'etiquette de ligne : il reste
       neutre pour ne pas concurrencer l'en-tete. */
    .serenia-prose table td:first-child strong {
        color: var(--color-gray-900);
    }

    /* Une liste tient dans une cellule : marges et retrait resserres, sinon
       elle pousse la colonne et deforme tout le tableau. */
    .serenia-prose table ul,
    .serenia-prose table ol {
        margin: 0;
        padding-left: 0.875rem;
    }

    .serenia-prose table li {
        margin: 0.0625rem 0;
        padding-left: 0.5rem;
    }

    .serenia-prose table ul > li::before {
        top: 0.55em;
        width: 0.3125rem;
        height: 0.3125rem;
    }

    /* --- Separateur ---
       Un filet plein coupe la lecture net. Celui-ci s'eteint vers la droite :
       il marque une respiration, pas une frontiere. */
    /* --- Indicateur de recherche web ---
       Remplace les points de saisie pendant que Serenia interroge le web.
       Un point qui pulse dit « j'attends » ; une loupe qui balaie dit « je
       cherche ». Le geste doit nommer l'action, pas seulement occuper l'ecran.
       Deux animations, une seule idee : la loupe balaie, un reflet passe sur
       le libelle — comme un scan qui traverse. */
    .serenia-search-indicator {
        display: inline-flex;
        align-items: center;
        gap: 0.4375rem;
        padding: 0.375rem 0.8125rem 0.375rem 0.6875rem;
        border-radius: 99px;
        background: color-mix(in srgb, var(--color-cohorts) 7%, white);
        border: 1px solid color-mix(in srgb, var(--color-cohorts) 16%, white);
        color: var(--color-cohorts-dark);
        font-size: 0.8125rem;
        font-weight: 500;
        line-height: 1;
    }

    .serenia-search-indicator__icon {
        flex: 0 0 auto;
        opacity: 0.9;
    }

    .serenia-search-indicator__label::after {
        content: '…';
        opacity: 0.55;
    }

    /* Le point qui suit les points de suspension reprend le fil de l'outil :
       meme dispositif que le separateur, ou seul le point porte la couleur. */
    .serenia-search-indicator::after {
        content: '';
        width: 0.3125rem;
        height: 0.3125rem;
        border-radius: 50%;
        background: var(--color-cohorts);
        flex: 0 0 auto;
        margin-left: 0.125rem;
    }

    @media (prefers-reduced-motion: no-preference) {
        .serenia-search-indicator::after {
            animation: serenia-search-pulse 1.9s ease-in-out infinite;
        }

        @keyframes serenia-search-pulse {
            0%, 100% { opacity: 0.25; }
            50%      { opacity: 1; }
        }
    }

    @media (prefers-reduced-motion: no-preference) {
        /* La loupe balaie un court arc, comme un regard qui parcourt. */
        .serenia-search-indicator__icon {
            animation: serenia-search-sweep 1.9s ease-in-out infinite;
            transform-origin: 45% 45%;
        }

        @keyframes serenia-search-sweep {
            0%, 100% { transform: translateX(-1px) rotate(-14deg); }
            50%      { transform: translateX(1px)  rotate(14deg); }
        }

        /* Un seul geste anime. Un reflet balayant le libelle avait ete tente :
           background-clip:text rendait le texte invisible des que le degrade
           sortait de la boite. Le libelle reste donc plein et lisible — c'est
           la loupe qui porte le mouvement. */
    }

    /* --- Separateur : le sc-divider--dot de Scormia -------------------------
       Deux filets NEUTRES encadrant un point d'accent centre. Le <hr> etant un
       element vide, les filets sont des pseudo-elements et le point un degrade
       radial centre dans l'ecart qui les separe.
       Le filet reste gris : seul le point porte la couleur, ce qui rend le
       separateur lisible sans le faire concurrencer les titres. */
    .serenia-prose hr {
        border: 0;
        display: flex;
        align-items: center;
        gap: 14px;
        height: 9px;
        margin: 1.5rem 0;
        background-image: radial-gradient(
            circle,
            var(--color-cohorts) 4.5px,
            transparent 4.5px
        );
        background-position: center;
        background-repeat: no-repeat;
    }

    .serenia-prose hr::before,
    .serenia-prose hr::after {
        content: '';
        flex: 1;
        height: 2px;
        border-radius: 99px;
        background: var(--color-gray-200);
    }

    /* --- Formules LaTeX (KaTeX) --- */

    /* Une matrice large déborderait la colonne de conversation : on la fait
       défiler dans son propre conteneur plutôt que d'élargir la page. */
    /* KaTeX centre les formules en bloc et leur donne 1em de marge. Dans une
       colonne de conversation alignée à gauche, ça isole chaque formule au
       milieu d'un grand vide. On réaligne et on dégonfle. */
    .serenia-prose .katex-display {
        overflow-x: auto;
        overflow-y: hidden;
        text-align: left;
        margin: 0.5rem 0;
        padding: 0;
    }

    .serenia-prose .katex-display > .katex {
        text-align: left;
    }

    /* markdown-it enroule la formule dans un <p>, dont la marge s'ajoute à
       celle de la formule. Un paragraphe qui ne contient qu'une formule ne
       doit pas cumuler les deux. */
    .serenia-prose p:has(> .katex-display:only-child) {
        margin: 0;
    }

    .serenia-prose .katex {
        font-size: 1.05em;
    }

    /* --- QCM options in messages --- */
    .serenia-prose .qcm-options {
        list-style: none;
        padding-left: 0.75rem;
        margin: 0.375rem 0 0.75rem 0;
        border-left: 2px solid var(--color-gray-200);
    }

    .serenia-prose .qcm-options li {
        padding: 0.25rem 0;
        list-style: none;
    }

    .serenia-prose .qcm-options li strong {
        color: var(--color-primary);
        margin-right: 0.25rem;
    }

    /* --- Code blocks with copy button --- */
    .code-wrapper {
        position: relative;
        margin: 0.75rem 0;
    }

    .code-wrapper .hljs-block {
        margin: 0;
    }

    .copy-code-btn {
        position: absolute;
        top: 6px;
        right: 8px;
        background: rgba(255,255,255,0.1);
        border: 1px solid rgba(255,255,255,0.15);
        border-radius: 4px;
        padding: 2px 8px;
        font-size: 10px;
        color: rgba(255,255,255,0.7);
        cursor: pointer;
        font-family: inherit;
        transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
        z-index: 1;
    }

    .copy-code-btn:hover {
        background: rgba(255,255,255,0.22);
        color: rgba(255,255,255,0.95);
    }

    /* --- Copy button on messages (hover reveal) --- */
    .serenia-copy-btn {
        position: absolute;
        top: -6px;
        right: -6px;
        background: #fff;
        border: 1px solid var(--color-gray-200);
        border-radius: 0.5rem;
        padding: 0.25rem;
        cursor: pointer;
        opacity: 0;
        transition: all var(--duration-150) var(--ease-default);
        color: var(--color-gray-400);
        box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
    }

    .serenia-message:hover .serenia-copy-btn {
        opacity: 1;
    }

    .serenia-copy-btn:hover {
        background: var(--color-gray-50);
        color: var(--color-gray-700);
    }
}

/* === TYPING DOTS ANIMATION === */
.animate-typing-dot {
    animation: typing-dot 1.4s ease-in-out infinite;
}

@keyframes typing-dot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* === SERENIA MESSAGE FADE-IN === */
.serenia-message {
    animation: serenia-msg-in 250ms ease-out both;
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes serenia-msg-in {
        from { opacity: 0; transform: translateY(6px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes serenia-modal-in {
        from { opacity: 0; transform: translateY(12px) scale(0.97); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    @keyframes serenia-modal-out {
        from { opacity: 1; transform: translateY(0) scale(1); }
        to   { opacity: 0; transform: translateY(12px) scale(0.97); }
    }
}

@media (prefers-reduced-motion: reduce) {
    @keyframes serenia-msg-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
    @keyframes serenia-modal-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
    @keyframes serenia-modal-out {
        from { opacity: 1; }
        to   { opacity: 0; }
    }
}

.serenia-modal-panel.serenia-modal-enter {
    animation: serenia-modal-in 220ms ease-out both;
}

.serenia-modal-panel.serenia-modal-leave {
    animation: serenia-modal-out 180ms ease-in both;
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes conv-item-in {
        from { opacity: 0; transform: translateX(-8px) scale(0.97); }
        to   { opacity: 1; transform: translateX(0) scale(1); }
    }

    .conv-item-new {
        animation: conv-item-in 180ms ease-out both;
    }
}

@media (prefers-reduced-motion: reduce) {
    @keyframes conv-item-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    .conv-item-new {
        animation: conv-item-in 180ms ease-out both;
    }
}

/* === ACTION MENU (_molecules/action-menu) === */
.action-menu-item:hover {
    background-color: rgba(var(--accent-rgb), 0.08) !important;
    color: rgb(var(--accent-rgb)) !important;
}

/* Guided product tour */
.tour-highlight {
    position: relative;
    z-index: 41;
    box-shadow: 0 0 0 4px var(--color-primary), 0 0 0 6px rgba(12, 129, 228, 0.3);
    border-radius: 8px;
}

/* === MOODIA — assistant IA inline : animation de chargement (étincelle + points) === */
@keyframes moodia-regen-pop {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%      { transform: scale(1.18); opacity: .7;  }
}
.moodia-regen-spark { animation: moodia-regen-pop 1.2s ease-in-out infinite; }
@keyframes moodia-regen-dots {
    0%        { content: '.';   }
    33%       { content: '..';  }
    66%, 100% { content: '...'; }
}
.moodia-regen-dots::after {
    content: '...';
    display: inline-block;
    width: 1.1em;
    text-align: left;
    animation: moodia-regen-dots 1.4s steps(1, end) infinite;
}

/* === MOODIA — barre flottante de sélection : entrées animées === */
@keyframes moodia-bar-in {
    from { opacity: 0; transform: translateY(4px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}
.moodia-bar-in { animation: moodia-bar-in 0.14s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes moodia-menu-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
.moodia-menu-in {
    transform-origin: top right;
    animation: moodia-menu-in 0.13s cubic-bezier(0.16, 1, 0.3, 1);
}

/* === MOODIA — historique : panneau coulissant (drawer) === */
/* Courbe « drawer » (façon Vaul) : départ franc, longue décélération douce. */
.moodia-history-panel {
    transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
}
/* Légère cascade d'apparition des lignes une fois le panneau en place. */
@keyframes moodia-history-rise {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.moodia-history-stagger > li {
    opacity: 0;
    animation: moodia-history-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.moodia-history-stagger > li:nth-child(1)  { animation-delay: 0.10s; }
.moodia-history-stagger > li:nth-child(2)  { animation-delay: 0.13s; }
.moodia-history-stagger > li:nth-child(3)  { animation-delay: 0.16s; }
.moodia-history-stagger > li:nth-child(4)  { animation-delay: 0.19s; }
.moodia-history-stagger > li:nth-child(5)  { animation-delay: 0.22s; }
.moodia-history-stagger > li:nth-child(6)  { animation-delay: 0.25s; }
.moodia-history-stagger > li:nth-child(7)  { animation-delay: 0.28s; }
.moodia-history-stagger > li:nth-child(8)  { animation-delay: 0.31s; }
.moodia-history-stagger > li:nth-child(9)  { animation-delay: 0.34s; }
.moodia-history-stagger > li:nth-child(n+10) { animation-delay: 0.37s; }
@media (prefers-reduced-motion: reduce) {
    .moodia-history-panel { transition-duration: 0.01ms; }
    .moodia-history-stagger > li { animation: none; opacity: 1; }
}

/* === MOODIA — tailles des titres dans l'éditeur de page (le reset Tailwind les enlève) === */
.moodia-rich-text h1 { font-size: 1.875rem; margin: 0.7em 0 0.3em;  }
.moodia-rich-text h2 { font-size: 1.5rem;   margin: 0.6em 0 0.3em;  }
.moodia-rich-text h3 { font-size: 1.25rem;  margin: 0.5em 0 0.25em; }
.moodia-rich-text h4 { font-size: 1.125rem; margin: 0.5em 0 0.25em; }
.moodia-rich-text h5 { font-size: 1rem;     margin: 0.4em 0 0.2em;  }
.moodia-rich-text h6 {
    font-size: 0.85rem;
    margin: 0.4em 0 0.2em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #4b5563;
}
