/* ============================================================
   Demo Chat — Messages, bubbles, welcome, input, markdown, cards
   ============================================================ */

/* ============================================================
   CHAT AREA
   ============================================================ */

.demo-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---- Welcome / empty state ---- */

.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Ancrage HAUT (et NON justify-content:center) : les quick actions se chargent
       en async (API, dépend de l'heure client) ; un centrage vertical re-centrait
       tout le bloc quand elles apparaissaient (hauteur très variable : ~247px desktop,
       ~479px en étroit) → l'écran d'accueil "remontait" = layout shift visible (mesuré
       au Chrome DevTools : .welcome-inner / .demo-input-area / #quickActionsContainer).
       En flex-start, les actions se remplissent VERS LE BAS sans bouger le héros. Le
       padding-top fluide garde un placement aéré sans dépendre de la hauteur du contenu. */
    justify-content: flex-start;
    /* padding-top réduit : remonte le bloc (patte + hero) près de la topbar
       « Nouvelle conversation », tout en gardant un léger espace. */
    padding: clamp(1rem, 3vh, 2rem) 2rem 2rem;
    overflow-y: auto;
    overflow-x: hidden;   /* garde-fou : le halo radial ne doit jamais créer de scroll horizontal (iOS) */
}

.welcome-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Halo radial teal très subtil → profondeur sans image (zéro CLS).
   Ancré sur .welcome-inner (suit le contenu centré, cf. critique perf). */
.welcome-inner::before {
    content: "";
    position: absolute;
    top: -2.5rem;
    left: 50%;
    width: 620px;
    max-width: 100%;   /* borne le halo à la largeur du contenu → pas de débordement horizontal */
    height: 420px;
    transform: translateX(-50%);
    background: radial-gradient(60% 60% at 50% 30%, var(--c-primary-light) 0%, transparent 70%);
    opacity: 0.5;
    pointer-events: none;
    z-index: -1;
}

/* NOTE fold : ne PAS remettre de fondu sticky ::after en bas du welcome comme
   affordance de scroll. Testé et retiré (2026-07-10) : le dégradé vers la lagune
   n'est invisible QUE sur le fond — sur une quick-action card BLANCHE il devient
   un voile laiteux qui traverse la card (et en fin de scroll, le sticky se repose
   sur les 32 derniers px du contenu = en plein sur la card). La gestion du fold
   passe par la compression verticale des media queries max-height ci-dessous. */

.welcome-icon {
    margin: 0 0 0.35rem;
    display: flex;
    justify-content: center;
}

.welcome-icon-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border-light);
    color: var(--c-primary);
    box-shadow: var(--shadow-sm);
}

.welcome-title {
    font-family: var(--f-display);
    font-size: 2.1rem;
    font-weight: 500;
    color: var(--c-text);
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0;
    text-wrap: balance;
}

.welcome-title em {
    font-style: italic;
    color: var(--c-primary);
    font-weight: 500;
}

.welcome-subtitle {
    font-size: 0.98rem;
    color: var(--c-text-secondary);
    line-height: 1.55;
    max-width: 480px;
    margin: 0;
}

/* ---- Trust chips (réassurance : gratuit, spécialisé, données, temps réel) ---- */
.welcome-trust {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    max-width: 520px;
}

.welcome-trust-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.72rem;
    background: var(--c-primary-light);
    color: var(--c-primary);
    border-radius: var(--r-full);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.welcome-trust-ico { flex-shrink: 0; }

/* ---- ZONE 1 : Masthead (rythme INTERNE serré → se lit comme une unité) ---- */
.welcome-masthead {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    max-width: 560px;
}

/* ---- Preuve sociale condensée : pile d'avatars superposés + 1 légende ---- */
.welcome-proof {
    margin-top: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.7rem;
}

.welcome-proof-stack {
    display: flex;
    align-items: center;
}

.welcome-proof-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--r-full);
    overflow: hidden;
    background: var(--c-primary-light);
    border: 2px solid var(--c-bg-card);   /* liseré clair → détoure dans la pile */
    box-shadow: var(--shadow-sm);
}

/* Chevauchement : tous sauf le premier remontent vers la gauche */
.welcome-proof-avatar + .welcome-proof-avatar {
    margin-left: -12px;
}

/* Image au-dessus de la lettre ; onerror la retire → lettre de repli visible (pas d'icône cassée). */
.welcome-proof-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.welcome-proof-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--f-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-primary);
}

/* Pastille "+N" : fond teal foncé → contraste AA avec le blanc (cf. critique a11y). */
.welcome-proof-more {
    overflow: visible;
    background: var(--c-primary);
    color: var(--c-text-inverse);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-proof-label {
    margin: 0;
    font-size: 0.85rem;
    color: var(--c-text-secondary);
    line-height: 1.3;
    text-align: left;
}

/* ---- "Essayez par exemple :" au-dessus des quick actions ---- */
.quick-actions-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--c-text-secondary);
    margin-bottom: 0.6rem;
    text-align: center;
}

/* ---- Quick Actions ---- */

/* ---- ZONE 2 : Comptoir d'action (point focal, détaché par le SEUL grand gap) ---- */
.quick-actions-container {
    margin-top: clamp(1.75rem, 4vw, 2.75rem);
    width: 100%;
    max-width: 640px;
}

/* Les bulles de suggestion coulent à la suite et passent à la ligne quand il n'y a plus de place
   (flex-wrap), centrées. Jamais coupées (aucun overflow/peek) : une bulle qui ne tient pas part
   entière à la ligne suivante. */
.quick-actions-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
}

.quick-action-card {
    /* Taille au contenu (pas de largeur imposée) → plusieurs bulles courtes tiennent côte à côte
       dès qu'il y a la place, puis passage à la ligne sans coupure. Plafonnée à 300px pour qu'une
       bulle à longue description ne s'étale pas seule ; min-width:0 = le texte wrap dans la bulle
       au lieu de la faire déborder. */
    flex: 0 1 auto;
    min-width: 0;
    max-width: 300px;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.95rem 1.05rem;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: left;
    font-size: 0.88rem;
    color: var(--c-text);
    transition: border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}

/* Seul groupe avec hover/élévation marqué → signale visuellement "ici on agit". */
.quick-action-card:hover {
    border-color: var(--c-primary-soft);
    transform: translateY(-2px);
}

.qa-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    margin-top: 1px;
    opacity: 0.85;
}

.qa-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.qa-text {
    font-weight: 600;
    line-height: 1.3;
    color: var(--c-text);
    font-size: 0.88rem;
}

.qa-description {
    font-size: 0.78rem;
    color: var(--c-text-muted);
    line-height: 1.35;
}

/* ---- Révélation au chargement (cascade) + accessibilité ---- */
@keyframes wd-welcome-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* L'état final (opacity:1) est garanti par `both` → jamais bloqué si l'anim est absente. */
.welcome-icon,
.welcome-title,
.welcome-subtitle,
.welcome-trust,
.welcome-proof,
.quick-actions-container {
    animation: wd-welcome-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.welcome-title           { animation-delay: 0.06s; }
.welcome-subtitle        { animation-delay: 0.12s; }
.welcome-trust           { animation-delay: 0.18s; }
.welcome-proof           { animation-delay: 0.24s; }
.quick-actions-container { animation-delay: 0.32s; }  /* la zone focale entre en dernier */

.quick-action-card:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .welcome-icon,
    .welcome-title,
    .welcome-subtitle,
    .welcome-trust,
    .welcome-proof,
    .quick-actions-container {
        animation: none;
    }
    .quick-action-card,
    .quick-action-card:hover {
        transition: none;
        transform: none;
    }
}

/* ---- Messages area ---- */

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-messages-scroll {
    max-width: 768px;
    margin: 0 auto;
    padding: 1.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    width: 100%;
}

/* ---- Chat messages ---- */

.chat-message {
    display: flex;
    flex-direction: column;
}

.chat-message.user { align-items: flex-end; }
.chat-message.agent { align-items: flex-start; }
.chat-message.system { align-items: center; }

/* ---- Chat bubbles ---- */

.chat-bubble {
    max-width: 78%;
    padding: 0.75rem 1.05rem;
    line-height: 1.6;
    font-size: 0.94rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: bubbleIn var(--dur-slow) var(--ease-out);
    will-change: transform, opacity;
}

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

.chat-bubble.user {
    background: var(--c-bg-warm);
    color: var(--c-text);
    border-radius: 18px 18px 6px 18px;
    box-shadow: none;
}

.chat-bubble.agent {
    background: transparent;
    color: var(--c-text);
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 100%;
}

.chat-bubble.system {
    background: var(--c-accent-light);
    color: var(--c-text-secondary);
    border-radius: var(--r-md);
    font-size: 0.84rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 0.9rem;
}

.system-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    border: 1px solid var(--c-primary-soft);
    background: var(--c-bg-card);
    color: var(--c-primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.system-retry-btn:hover {
    background: var(--c-primary);
    color: var(--c-text-inverse);
}

/* ---- Urgent warning banner ---- */

.chat-urgent-banner {
    display: flex;
    justify-content: center;
    padding: 0 1rem;
    margin: 0.5rem 0;
}

.urgent-banner-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--c-warning-light);
    border: 1px solid var(--c-warning-border);
    border-radius: var(--r-md);
    color: var(--c-warning-text);
    font-size: 0.84rem;
    font-weight: 500;
    max-width: 600px;
}

.urgent-icon {
    flex-shrink: 0;
    color: var(--c-warning);
    overflow: visible;
}

/* ---- Debug panel (APP_DEBUG only) ---- */

.debug-panel {
    max-width: 75%;
    margin: 0.25rem auto 0;
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.debug-summary {
    cursor: pointer;
    color: var(--c-text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: var(--r-sm);
    user-select: none;
    font-size: 0.72rem;
    text-align: center;
}

.debug-summary:hover {
    color: var(--c-text-secondary);
}

.debug-content {
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--c-bg-warm);
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-sm);
    line-height: 1.5;
}

.debug-row {
    padding: 0.1rem 0;
    word-break: break-all;
}

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

.debug-indent {
    padding-left: 16px;
    font-size: 11px;
    color: var(--c-text-muted);
}

.debug-tool-detail {
    margin: 0.2rem 0 0.2rem 16px;
}

.debug-tool-detail summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--c-text-muted);
}

.debug-tool-detail summary:hover {
    color: var(--c-text-secondary);
}

.debug-tool-body {
    padding: 0.25rem 0 0.25rem 12px;
    border-left: 2px solid var(--c-border-light);
    margin-left: 4px;
}

.debug-pre {
    margin: 0.15rem 0 0.35rem;
    padding: 0.35rem 0.5rem;
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-xs, 4px);
    font-size: 10px;
    line-height: 1.4;
    max-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---- Agent badge (above agent bubble) ---- */

.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    align-self: flex-start;
    padding: 0.2rem 0;
    margin-bottom: 0.45rem;
    font-family: var(--f-display);
    font-size: 0.86rem;
    font-style: italic;
    font-weight: 500;
    color: var(--c-primary);
    letter-spacing: -0.005em;
    animation: fadeIn var(--dur-normal) var(--ease-out);
}

/* ---- Agent switch divider ---- */

.agent-switch-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    animation: fadeIn var(--dur-normal) var(--ease-out);
}

.switch-line {
    flex: 1;
    height: 1px;
    background: var(--c-border);
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--c-primary-soft);
    white-space: nowrap;
}

.agent-handoff-divider .switch-label {
    color: var(--c-accent);
}

/* ---- Markdown in agent bubbles ---- */

.chat-bubble.agent p { margin-bottom: 0.4rem; }
.chat-bubble.agent p:last-child { margin-bottom: 0; }
.chat-bubble.agent strong { font-weight: 700; }
.chat-bubble.agent em { font-style: italic; }
.chat-bubble.agent ul, .chat-bubble.agent ol { margin: 0.3rem 0; padding-left: 1.2rem; }
.chat-bubble.agent li { margin-bottom: 0.15rem; }
.chat-bubble.agent code {
    background: rgba(0,0,0,0.05);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.84em;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.chat-bubble.agent pre {
    background: rgba(0,0,0,0.04);
    padding: 0.65rem 0.8rem;
    border-radius: var(--r-sm);
    overflow-x: auto;
    margin: 0.4rem 0;
    font-size: 0.82rem;
}
.chat-bubble.agent pre code { background: none; padding: 0; }
.chat-bubble.agent h1, .chat-bubble.agent h2, .chat-bubble.agent h3 {
    font-family: var(--f-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--c-text);
    letter-spacing: -0.01em;
    margin: 0.85rem 0 0.35rem;
    line-height: 1.3;
}
.chat-bubble.agent h1 { font-size: 1.25rem; font-weight: 700; }
.chat-bubble.agent h1:first-child, .chat-bubble.agent h2:first-child, .chat-bubble.agent h3:first-child { margin-top: 0; }
.chat-bubble.agent a {
    color: var(--c-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(27, 85, 92, 0.4);
    transition: text-decoration-color var(--dur-fast);
}
.chat-bubble.agent a:hover { text-decoration-color: var(--c-primary); }
.chat-bubble.agent blockquote {
    border-left: 2px solid var(--c-primary);
    padding-left: 0.85rem;
    margin: 0.6rem 0;
    color: var(--c-text-secondary);
    font-family: var(--f-display);
    font-style: italic;
}
.chat-bubble.agent hr {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 0.6rem 0;
}

/* ---- Markdown tables (GFM) ----
 * display:block + overflow-x:auto → scroll horizontal sur mobile sans wrapper (la table
 * est insérée inline par formatMarkdown). Palette Woopets, pas de fallback hardcodé. */
.chat-bubble.agent .md-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 0.7rem 0;
    font-size: 0.92em;
    -webkit-overflow-scrolling: touch;
}
.chat-bubble.agent .md-table th,
.chat-bubble.agent .md-table td {
    border: 1px solid var(--c-border);
    padding: 0.45rem 0.7rem;
    text-align: left;
    vertical-align: top;
}
.chat-bubble.agent .md-table th {
    background: var(--c-bg-warm);
    font-weight: 600;
    color: var(--c-text);
}
.chat-bubble.agent .md-table tbody tr:nth-child(even) td {
    background: var(--c-bg);
}

/* ---- Product cards in chat (markdown-rendered) ----
 * Pattern visuel cohérent avec .training-card / .adoption-card / .nutrition-card :
 * largeur stable pleine bulle, top accent strip peach (identité Woopets — produits/affiliation),
 * layered shadow, animation d'entrée subtile. Layout horizontal (image gauche + info droite).
 * Sur mobile (<480px), bascule en stack vertical (image au-dessus). */

.chat-bubble.agent .product-card a,
.chat-bubble.agent .product-card a:hover,
.chat-bubble.agent .product-card a:visited {
    color: var(--c-text);
    text-decoration: none !important;
}

.product-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
    width: 100%;
}

.product-card {
    box-sizing: border-box;
    width: min(720px, calc(100vw - 48px));
    background: var(--c-bg-card);
    border: 1px solid var(--c-border-light);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 4px 12px rgba(15, 23, 42, 0.06);
    animation: product-card-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
    /* Isole le repaint pour limiter les ré-affichages cascadés
     * lorsque le streaming réécrit textContainer.innerHTML à chaque tick. */
    contain: layout paint style;
}

@keyframes product-card-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pendant le streaming, le bubble parent porte la classe .streaming et
 * textContainer.innerHTML est réécrit ~66×/sec → les .product-card markdown
 * sont détruites/recréées et leur animation d'entrée re-déclenche à chaque tick
 * (= scintillement / pulsation visible). On la coupe tant que le stream est en cours.
 * À la finalisation (.streaming retirée), l'animation peut éventuellement re-jouer
 * une fois — acceptable car ne se produit qu'au tout dernier render. */
.chat-bubble.agent.streaming .product-card {
    animation: none !important;
}

/* Top accent strip (4px) — peach gradient cohérent avec .adoption-card */
.product-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent-hover));
    z-index: 1;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.06),
        0 8px 20px rgba(15, 23, 42, 0.08);
}

.product-card a,
.product-card a:hover,
.product-card a:visited,
.product-card a:active {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    color: var(--c-text);
    text-decoration: none !important;
    padding-top: 4px; /* compense le top accent strip pour ne pas le chevaucher */
}

.product-card-image {
    flex: 0 0 140px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
    border-right: 1px solid var(--c-border-light);
}

.product-card-image img {
    width: auto;
    height: auto;
    max-height: 116px;
    max-width: 116px;
    object-fit: contain;
    display: block;
}

.product-card-image.product-card-image--placeholder {
    background: var(--c-primary-light);
}

.product-card-image svg {
    width: 36px;
    height: 36px;
    color: var(--c-primary-soft);
    opacity: 0.5;
}

.product-card-info {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    /* PAS de position: relative ici. Aucun enfant n'est en position absolue, donc
     * c'était superflu — et surtout, dans le widget (iframe), .product-card cumule
     * overflow:hidden + contain:paint (clipping paint roots) + transform au :hover.
     * WebKit échoue alors à repeindre les SOUS-ARBRES POSITIONNÉS après le transform :
     * le bloc info (positionné) disparaissait au survol tandis que l'<img> (statique)
     * restait. Le garder statique le fait repeindre avec le reste de la card. */
}

.product-card-brand {
    font-size: 0.68rem;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.product-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--c-text);
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
    transition: color 0.18s ease;
}

.product-card a:hover .product-card-name {
    color: var(--c-primary);
}

.product-card-nutrition {
    font-size: 0.78rem;
    color: var(--c-text-secondary);
    line-height: 1.4;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Footer : prix + boutique à gauche, bouton CTA à droite */
.product-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.product-card-meta-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}

.product-card-price {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--c-primary);
    letter-spacing: -0.01em;
}

.product-card-meta-sep {
    color: var(--c-text-muted);
    font-size: 0.75rem;
    opacity: 0.6;
}

.product-card-shop {
    font-size: 0.75rem;
    color: var(--c-text-muted);
    font-weight: 500;
}

.product-card-cta {
    align-self: flex-start;
    margin-top: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 9999px;
    background: var(--c-accent);
    color: var(--c-text-inverse);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    white-space: nowrap;
}

.product-card-cta-arrow {
    display: inline-block;
    transition: transform 0.18s ease;
    font-weight: 700;
}

.product-card a:hover .product-card-cta {
    background: var(--c-accent-hover);
    box-shadow: 0 2px 6px rgba(236, 142, 79, 0.35);
}

.product-card a:hover .product-card-cta-arrow {
    transform: translateX(2px);
}

/* ---- Professional cards ---- */

.pro-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0;
    width: 100%;
}

.pro-card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pro-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.pro-card-header {
    padding: 0.6rem 0.75rem 0.35rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.pro-card-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--c-text);
}

.pro-card-rating {
    font-size: 0.72rem;
    color: var(--c-text-secondary);
    white-space: nowrap;
}

.pro-card-body {
    padding: 0 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pro-card-location {
    font-size: 0.78rem;
    color: var(--c-text-secondary);
}

.pro-card-location strong {
    color: var(--c-primary);
    font-weight: 600;
}

.pro-card-phone,
.pro-card-website,
.pro-card-hours {
    font-size: 0.75rem;
    color: var(--c-text-muted);
}

.pro-card-website a {
    color: var(--c-primary);
    text-decoration: none;
}

.pro-card-website a:hover {
    text-decoration: underline;
}

.chat-image {
    max-width: 100%;
    border-radius: var(--r-md);
    margin: 0.3rem 0;
}

/* ---- Sources block ---- */

.sources-block {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(27, 85, 92, 0.12);
}
.sources-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--c-text-muted);
    margin-bottom: 0.4rem;
}
.source-link {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.3rem 0;
    text-decoration: none !important;
    color: var(--c-text-secondary) !important;
    font-size: 0.8rem;
    line-height: 1.3;
    transition: color 0.15s ease;
}
.source-link:hover {
    color: var(--c-primary) !important;
}
.source-link .source-title {
    color: var(--c-primary-soft);
    text-decoration: underline;
    text-underline-offset: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.source-link:hover .source-title {
    color: var(--c-primary);
}
.source-link .source-domain {
    font-size: 0.7rem;
    color: var(--c-text-muted);
    flex-shrink: 0;
}

/* ---- Typing indicator ---- */

.typing-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    animation: bubbleIn var(--dur-slow) var(--ease-out);
}

.typing-indicator > span:not(.typing-text) {
    width: 7px;
    height: 7px;
    background: var(--c-primary);
    border-radius: 50%;
    animation: typingPulse 1.4s ease-in-out infinite;
    will-change: transform, opacity;
}

.typing-indicator > span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator > span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
    30% { opacity: 1; transform: scale(1); }
}

.typing-text {
    margin-left: 0.35rem;
    font-size: 0.8rem;
    color: var(--c-text-muted);
    font-style: italic;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 250ms var(--ease-out), opacity 250ms var(--ease-out);
    transform: translateY(0);
    opacity: 1;
}

/* Roll out: slide up + fade */
.typing-text-roll-out {
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 250ms var(--ease-in, ease-in), opacity 250ms var(--ease-in, ease-in);
}

/* Roll in start: positioned below, invisible (applied instantly before animating) */
.typing-text-roll-in-start {
    transform: translateY(100%);
    opacity: 0;
    transition: none;
}

@media (min-width: 768px) {
    .typing-text { max-width: 420px; }
}

@media (min-width: 1280px) {
    .typing-text { max-width: 560px; }
}

@media (max-width: 767px) {
    .typing-text {
        max-width: 100%;
        min-width: 0;
        flex: 1 1 auto;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.35;
    }
}

/* ============================================================
   REGISTER NUDGE — carte douce après la 1ère réponse (anonyme)
   ============================================================ */

.register-nudge {
    position: relative;
    margin: 0.5rem auto 1rem;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 2.25rem 0.9rem 1rem;
    background: var(--c-accent-light);
    border: 1px solid var(--c-accent-soft);
    border-radius: 14px;
    animation: fadeIn var(--dur-normal) var(--ease-out);
}

.register-nudge-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--c-accent-vivid);
    color: #fff;
}

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

.register-nudge-text {
    font-size: 0.88rem;
    color: var(--c-text);
    line-height: 1.4;
    margin: 0 0 0.55rem;
}

.register-nudge-cta {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: var(--r-full);
    background: var(--c-accent-vivid);
    color: var(--c-text-inverse);
    font-family: var(--f-body);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--dur-fast);
}

.register-nudge-cta:hover { background: var(--c-accent-vivid-hover); }

.register-nudge-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--dur-fast), color var(--dur-fast);
}

.register-nudge-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--c-text);
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.demo-input-area {
    flex-shrink: 0;
    padding: 0.75rem 1rem 0.85rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    background: var(--c-bg);
    position: relative; /* ancre le bouton "revenir en bas" (.scroll-to-bottom-btn) */
}

/* Bouton flottant "revenir en bas" — visible UNIQUEMENT quand l'utilisateur a remonté
   (state.stickToBottom=false). Posé juste au-dessus de l'input, centré. Toggle .visible
   piloté par W.initScrollTracking. */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-bottom: 6px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--c-border);
    border-radius: 9999px;
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Halo marqué : détoure le bouton même sur un thème embed plat (surface ≈ bg, sans contrainte
       de contraste côté publisher). Pas de hex de marque hardcodé — uniquement du noir alpha. */
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden; /* sort du tab order + arbre a11y quand masqué (embed sur pages tierces) */
    pointer-events: none;
    transform: translateX(-50%) translateY(8px) scale(0.92);
    transition: opacity var(--dur-fast), transform var(--dur-fast), visibility 0s linear var(--dur-fast);
    z-index: 5;
}
.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
    transition: opacity var(--dur-fast), transform var(--dur-fast), visibility 0s;
}
.scroll-to-bottom-btn:hover {
    color: var(--c-text);
    border-color: var(--c-primary-soft);
}

.input-container {
    max-width: 768px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.55rem 0.55rem 0.55rem 0.75rem;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input-wrapper:focus-within {
    border-color: var(--c-primary);
    box-shadow: var(--shadow-md);
}

.main-textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--f-body);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--c-text);
    background: transparent;
    padding: 0.45rem 0.25rem;
    max-height: 150px;
    overflow-y: auto;
    box-shadow: none !important;
    border-radius: 0;
}

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

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--r-full);
    background: var(--c-accent-vivid);
    color: var(--c-text-inverse);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), transform var(--dur-fast);
}

.send-btn:hover {
    background: var(--c-accent-vivid-hover);
    transform: scale(1.05);
}

.send-btn:active { transform: scale(0.95); }

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* [V2-SKIN] Composer « Atelier-iOS » : pilule plus ronde + hairline + élévation douce ;
   bouton d'envoi en cible tactile (corail conservé). L'input reste opaque (au-dessus du
   clavier → pas de materials permanent en shell). Bulle agent INCHANGÉE (transparente,
   style épuré iOS) ; carte blanche éventuelle = décision de revue V2→V3. [V2.4 composer] */
body.v2-skin .input-wrapper {
    border: var(--v2-hairline);
    border-radius: var(--r-xl);
    box-shadow: var(--v2-shadow-card);
}
body.v2-skin .send-btn {
    width: var(--v2-touch);
    height: var(--v2-touch);
}

/* [V3.9] Mode Stop pendant le streaming : carré sur fond neutre (au lieu de la flèche corail). */
.send-btn.stop-mode {
    background: var(--c-text-secondary);
    cursor: pointer;
}
.send-btn.stop-mode:hover { background: var(--c-text); transform: none; }
.send-btn.stop-mode svg { display: none; }
.send-btn.stop-mode::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 2px;
    background: currentColor;
}

.char-counter {
    font-size: 0.7rem;
    color: var(--c-text-muted);
    margin-left: auto;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
}
.char-counter.warning { color: var(--c-accent); }
.char-counter.over { color: var(--c-danger); font-weight: 600; }

.char-counter-row {
    justify-content: flex-end;
}

.input-disclaimer {
    text-align: center;
    font-size: 0.7rem;
    /* Texte secondaire (7,1:1) : le taupe muted échoue AA sur fond lagune (4,24:1). */
    color: var(--c-text-secondary);
    margin-top: 0.4rem;
    padding-bottom: 0.25rem;
}

/* Disclaimer rétrogradé sur l'écran d'accueil : il s'affiche en conversation
   (à côté des réponses IA), pas avant le moindre essai. cf. refreshWelcomeChrome(). */
body.is-chat-welcome .input-disclaimer { display: none; }

/* ============================================================
   AGENT INTRO CARD — Editorial card
   ============================================================ */

.agent-intro-card {
    display: flex;
    gap: 16px;
    padding: 18px 20px 18px 20px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border-light);
    border-left: 3px solid var(--c-primary);
    border-radius: var(--r-md);
    margin: 6px 0 14px;
    max-width: 78%;
    box-shadow: var(--shadow-xs);
    animation: bubbleIn var(--dur-slow) var(--ease-out);
}

.agent-intro-avatar-wrap { flex-shrink: 0; }

.agent-intro-avatar-wrap img,
.agent-intro-avatar-wrap .agent-avatar-img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--c-border-light);
}

.agent-intro-avatar-wrap .agent-avatar-letter {
    width: 52px;
    height: 52px;
    font-size: 22px;
}

.agent-intro-info { min-width: 0; }

.agent-intro-name {
    font-family: var(--f-display);
    font-style: italic;
    font-weight: 500;
    color: var(--c-text);
    font-size: 1.1rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.agent-intro-role {
    font-size: 0.82rem;
    color: var(--c-primary);
    font-weight: 500;
    line-height: 1.3;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.agent-intro-bio {
    font-size: 0.86rem;
    color: var(--c-text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

/* ============================================================
   AGENT AVATAR (generic)
   ============================================================ */

.agent-avatar-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--c-primary-soft);
    color: white;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.agent-avatar-img {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE — Chat
   ============================================================ */

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
    .chat-messages-scroll { max-width: 860px; }
    .input-container { max-width: 860px; }
}

/* Tablet (768px–1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .agent-intro-card { max-width: 85%; }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .chat-bubble { max-width: 85%; }
    .agent-intro-card {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 10px;
        row-gap: 0;
        align-items: start;
        padding: 12px 14px;
        max-width: 95%;
    }
    .agent-intro-avatar-wrap {
        grid-row: 1 / span 2;
        grid-column: 1;
        align-self: center;
    }
    .agent-intro-info { display: contents; }
    .agent-intro-name {
        grid-row: 1;
        grid-column: 2;
        font-size: 1rem;
    }
    .agent-intro-role {
        grid-row: 2;
        grid-column: 2;
        font-size: 0.75rem;
    }
    .agent-intro-bio {
        grid-row: 3;
        grid-column: 1 / -1;
        font-size: 0.82rem;
        margin-top: 8px;
    }
    .agent-intro-avatar-wrap img,
    .agent-intro-avatar-wrap .agent-avatar-img,
    .agent-intro-avatar-wrap .agent-avatar-letter {
        width: 40px;
        height: 40px;
    }
    .agent-intro-avatar-wrap .agent-avatar-letter { font-size: 18px; }
    .welcome-title { font-size: 1.5rem; }
    .welcome-subtitle { font-size: 0.92rem; }
    .main-textarea { font-size: 16px; }

    /* Halo atténué + réduit sur petit écran */
    .welcome-inner::before { width: 420px; height: 320px; opacity: 0.4; }

    /* Comptoir d'action : gap inter-zones réduit pour limiter la hauteur de l'écran d'accueil */
    .quick-actions-container { margin-top: 1.5rem; }

    .indicator-role { max-width: 140px; }

    /* Quick Actions : la grille flex-wrap de base s'applique telle quelle (bulles à la suite,
       passage à la ligne sans coupure). On rend juste la largeur pleine et on clampe les
       descriptions à 2 lignes pour des hauteurs homogènes sur petit écran. */
    .quick-actions-container { max-width: 100%; }
    .quick-actions-grid .qa-description {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Small mobile (< 480px) */
@media (max-width: 479px) {
    .chat-messages-scroll { padding: 1rem 0.75rem; }
    .input-wrapper { padding: 0.4rem; }
    .chat-bubble { max-width: 90%; font-size: 0.85rem; }
    .welcome-title { font-size: 1.25rem; }
    .welcome-subtitle { font-size: 0.88rem; }
    .welcome-trust-item { font-size: 0.72rem; padding: 0.28rem 0.6rem; }
    .welcome-icon-circle { width: 46px; height: 46px; }
    .welcome-icon-circle svg { width: 30px; height: 30px; }
    .welcome-proof-avatar { width: 36px; height: 36px; }
    .indicator-role { max-width: 100px; }

    /* Quick Actions : padding réduit */
    .quick-action-card { padding: 0.7rem 0.85rem; font-size: 0.84rem; }
    .qa-text { font-size: 0.82rem; }

    /* Product cards : stack vertical (image au-dessus, info dessous) */
    .product-card a {
        flex-direction: column;
    }
    .product-card-image {
        flex: 0 0 auto;
        width: 100%;
        height: 160px;
        padding: 14px;
        border-right: none;
        border-bottom: 1px solid var(--c-border-light);
    }
    .product-card-image img {
        max-height: 130px;
        max-width: 70%;
    }
    .product-card-info {
        padding: 12px 14px 14px;
    }
    /* CTA reste visible sur sa propre ligne si meta + CTA ne tiennent pas côte à côte */
    .product-card-footer {
        gap: 8px;
    }
    .product-card-cta {
        padding: 5px 10px;
        font-size: 0.74rem;
    }
}

/* Tiny mobile (< 360px) */
@media (max-width: 359px) {
    .welcome-icon-circle { width: 42px; height: 42px; }
}

/* iOS safe areas */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .demo-input-area {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* iOS input zoom fix (16px minimum to prevent zoom) */
@supports (-webkit-touch-callout: none) {
    .main-textarea,
    .feedback-comment { font-size: 16px; }
}

/* ============================
   Feedback thumbs
   ============================ */

.chat-feedback {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0 4px;
}

.chat-feedback-submitted {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--c-border);
    border-radius: 50%;
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-feedback-btn:hover:not(:disabled) {
    color: var(--c-primary);
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}

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

.chat-feedback-btn.selected-positive {
    color: #16a34a;
    border-color: #16a34a;
    background: #f0fdf4;
    opacity: 1;
}

.chat-feedback-btn.selected-negative {
    color: #dc2626;
    border-color: #dc2626;
    background: #fef2f2;
    opacity: 1;
}

.chat-feedback-thanks {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-left: 4px;
}

/* Feedback modal */
.feedback-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
}

.feedback-modal-overlay.active {
    display: flex;
}

.feedback-modal {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: feedbackModalIn 0.25s cubic-bezier(0.16,1,0.3,1);
}

@keyframes feedbackModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.feedback-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}

.feedback-modal-close:hover {
    background: var(--c-bg-warm);
}

.feedback-modal-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--c-text);
}

.feedback-comment {
    width: 100%;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 72px;
    max-height: 160px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.feedback-comment:focus {
    outline: none;
    border-color: var(--c-primary);
}

.feedback-submit-btn {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 10px 0;
    background: var(--c-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.feedback-submit-btn:hover:not(:disabled) {
    background: var(--c-primary-hover);
}

.feedback-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   TOOL BADGES (streaming)
   ============================================================ */

/* ---- Tool status block (unified, single line with slot-machine animation) ---- */

.tool-status-block {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--c-primary-light);
    font-size: 0.8rem;
    color: var(--c-primary);
    width: fit-content;
    max-width: 100%;
    margin-bottom: 8px;
    overflow: hidden;
    animation: toolStatusFadeIn 0.3s ease;
}

.tool-status-icon {
    flex-shrink: 0;
    font-size: 0.85rem;
    transition: transform 200ms ease, opacity 200ms ease;
}

.tool-status-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 200ms var(--ease-out, ease-out), opacity 200ms var(--ease-out, ease-out);
}

.tool-status-indicator {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.tool-status-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--c-primary-soft);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.tool-status-check {
    color: var(--c-primary-soft);
    font-weight: bold;
    font-size: 0.85rem;
}

/* Error state */
.tool-status-block.error {
    background: #fef2f2;
    color: #b91c1c;
}

/* Slot machine animation — roll out (slide up + fade) */
.tool-status-roll-out {
    transform: translateY(-100%) !important;
    opacity: 0 !important;
    transition: transform 200ms ease-in, opacity 200ms ease-in !important;
}

/* Slot machine animation — roll in start (positioned below, invisible) */
.tool-status-roll-in-start {
    transform: translateY(100%) !important;
    opacity: 0 !important;
    transition: none !important;
}

@keyframes toolStatusFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ---- Streaming cursor ---- */

.chat-bubble.streaming {
    min-height: 1.4em;
}

.chat-bubble.streaming::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--c-primary);
    margin-left: 3px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: streamPulse 1s ease-in-out infinite;
}

@keyframes streamPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Landscape phone */
/* ---- Viewports COURTS (laptops 1280×800-900, mobiles portrait) : compression du
   budget vertical du masthead pour que la 3e suggestion passe au-dessus du fold.
   Cf. critique 2026-07-09 (P2). ---- */
@media (max-height: 900px) {
    .chat-welcome { padding-top: 0.75rem; }
    .welcome-masthead { gap: 0.45rem; }
    .welcome-icon { margin-bottom: 0.1rem; }
    .welcome-icon-circle { width: 44px; height: 44px; }
    .welcome-title { font-size: 1.85rem; }
    .welcome-subtitle { font-size: 0.92rem; }
    .welcome-proof { margin-top: 0.4rem; }
    .quick-actions-container { margin-top: 1.25rem; }
}

/* Très courts (≈ iPhone SE/8 portrait, petites fenêtres desktop) : l'icône
   décorative cède sa place au contenu utile ; chips et preuve resserrées. */
@media (max-height: 780px) {
    .welcome-icon { display: none; }
    .welcome-title { font-size: 1.7rem; }
    .welcome-trust { gap: 0.35rem; }
    .welcome-trust-item { padding: 0.26rem 0.62rem; font-size: 0.76rem; }
    .welcome-proof-avatar { width: 34px; height: 34px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .welcome-icon { display: none; }
    .input-disclaimer { display: none; }
}

/* =========================================
   Signalement de contenu IA (bouton flag + modale motifs)
   ========================================= */
.chat-report-btn,
.chat-copy-btn,
.chat-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 4px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
}

.chat-report-btn:hover {
    opacity: 1;
    color: var(--c-danger);
    background: var(--c-bg-warm);
}

/* [V3.13] Bouton Copier — même gabarit que report, hover teal (pas danger). */
.chat-copy-btn:hover {
    opacity: 1;
    color: var(--c-primary);
    background: var(--c-bg-warm);
}

/* [V4.1] Bouton Partager — caché par défaut, révélé si le partage est disponible (body.can-share :
   plugin natif en shell, ou navigator.share sur web mobile). */
.chat-share-btn { display: none; }
body.can-share .chat-share-btn { display: inline-flex; }
.chat-share-btn:hover {
    opacity: 1;
    color: var(--c-primary);
    background: var(--c-bg-warm);
}

@media (hover: none) and (pointer: coarse) {
    .chat-report-btn,
    .chat-copy-btn,
    .chat-share-btn { opacity: 0.8; }
}

.report-reasons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.report-reason-btn {
    padding: 11px 14px;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg-card);
    color: var(--c-text);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.report-reason-btn:hover {
    border-color: var(--c-primary-soft);
}

.report-reason-btn.selected {
    border-color: var(--c-primary);
    background: var(--c-primary-light);
    font-weight: 600;
}

/* Fallback générique pour les ui_type inconnus (vieux shell OTA vs API plus récente) */
.ui-fallback-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    width: min(720px, calc(100vw - 48px));
}

.ui-fallback-item {
    display: block;
    padding: 10px 14px;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg-card);
    color: var(--c-text);
    text-decoration: none;
    font-size: 0.95rem;
}

a.ui-fallback-item:hover {
    border-color: var(--c-primary-soft);
    background: var(--c-primary-light);
}

/* -------------------------------------------------------
 * Bulles de suivi (followup_suggestions)
 * Chips cliquables sous la réponse agent → pré-remplissent le champ au clic.
 * Rendues en .ui-cards-block sibling du texte (pas de flicker streaming).
 * ------------------------------------------------------- */
.ui-cards-block[data-card-type="followup_suggestions"] {
    margin-top: 10px;
}

.followup-suggestions {
    width: min(720px, calc(100vw - 48px));
}

.followup-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--c-text-muted);
    margin: 0 0 8px 2px;
    letter-spacing: 0.01em;
}

.followup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.followup-chip {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--c-border);
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.3;
    padding: 8px 14px;
    min-height: 36px;
    border-radius: 9999px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    animation: followup-chip-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.followup-chip:hover {
    background: var(--c-primary-light);
    border-color: var(--c-primary-soft);
    color: var(--c-primary);
}

.followup-chip:active {
    transform: scale(0.97);
}

.followup-chip:focus-visible {
    outline: 2px solid var(--c-primary-soft);
    outline-offset: 2px;
}

@keyframes followup-chip-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Pas de re-trigger d'animation pendant le streaming (cohérent avec les product cards). */
.chat-bubble.agent.streaming .followup-chip {
    animation: none !important;
}

/* Tactile : pas de dépendance au hover, cible confortable. */
@media (hover: none) and (pointer: coarse) {
    .followup-chip {
        min-height: 40px;
        padding: 10px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .followup-chip {
        animation: none;
        transition: none;
    }
}

/* Squelette des bulles de suivi : affiché dès que l'agent commence à écrire ses suggestions
 * (event followups_pending), remplacé par les vraies chips quand elles arrivent. Masque le
 * délai de génération du bloc <followups>. */
.followup-chip-skel {
    display: inline-block;
    height: 36px;
    border-radius: 9999px;
    background: linear-gradient(90deg, var(--c-bg-warm) 25%, var(--c-bg-card) 50%, var(--c-bg-warm) 75%);
    background-size: 200% 100%;
    animation: followup-skel-shimmer 1.2s ease-in-out infinite;
}

@media (hover: none) and (pointer: coarse) {
    .followup-chip-skel { height: 40px; }
}

@keyframes followup-skel-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .followup-chip-skel {
        animation: none;
        background: var(--c-bg-warm);
    }
}
