/* ============================================================
   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) */
}

/* ============================================================
   ACCUEIL D'ORIA — dessin de la maquette woopets.com (étape 5, lot B2,
   docs/maquette-accueil-woopets/oria.css). Toutes les couleurs viennent de
   public/css/woopets-tokens.css. Ces règles sont dans la feuille CRITIQUE : une
   règle d'accueil posée dans une feuille différée ferait bouger la page en arrivant.
   ============================================================ */

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

.welcome-masthead {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Le titre est l'élément le plus grand de l'écran (LCP) : AUCUNE animation d'entrée sur lui —
   une opacité à 0 au départ retarde la mesure de l'affichage. */
.welcome-title {
    margin: 0;
    font-family: var(--f-display);
    font-size: clamp(2.25rem, 3.9vw, 3.35rem);
    font-weight: 600;
    line-height: 1.02;
    letter-spacing: -0.055em;
    color: var(--c-text);
    text-wrap: balance;
}

/* Le mot mis en valeur : Georgia italique (règle « Fraunces italic » de woopets-tokens.css). */
.welcome-title em {
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.045em;
    color: var(--c-primary);
}

.welcome-subtitle {
    max-width: 56ch;
    margin: 16px auto 0;
    font-size: 1.02rem;
    line-height: 1.55;
    color: var(--c-text-muted);
    text-wrap: pretty;
}

/* ---- Pastilles de réassurance ---- */
.welcome-trust {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}

.welcome-trust-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px 5px 10px;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-full);
    background: var(--c-primary-light);
    color: var(--c-primary);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

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

/* ---- Sélecteur « N spécialistes IA » ---- */
.welcome-experts {
    width: 100%;
    margin-top: 18px;
}

.welcome-experts-summary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 6px 16px 6px 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-full);
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    font-size: 0.88rem;
    font-weight: 620;
    list-style: none;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--dur-fast);
}

.welcome-experts-summary::-webkit-details-marker { display: none; }
.welcome-experts-summary:hover { border-color: var(--c-primary-muted); }
.welcome-experts-summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.welcome-experts-faces {
    display: flex;
    align-items: center;
    padding-left: 6px;
}

.welcome-experts-face,
.welcome-expert-photo {
    position: relative;
    flex: none;
    overflow: hidden;
    border-radius: 50%;
    background: var(--c-primary-light);
}

.welcome-experts-face {
    width: 34px;
    height: 34px;
    margin-left: -8px;
    border: 2px solid var(--c-bg-card);
}

.welcome-experts-face img,
.welcome-expert-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lettre de repli sous la photo (la photo en échec se retire). */
.welcome-experts-letter {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--f-display);
    font-weight: 600;
    color: var(--c-primary);
}

.welcome-experts-count { white-space: nowrap; }
.welcome-experts-chevron { flex: none; transition: transform var(--dur-fast); }
.welcome-experts[open] .welcome-experts-chevron { transform: rotate(180deg); }

.welcome-experts-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.welcome-expert {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    background: var(--c-bg-card);
}

.welcome-expert-photo { width: 48px; height: 48px; }
.welcome-expert-text { min-width: 0; }

.welcome-expert-name {
    display: block;
    font-family: var(--f-display);
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.03em;
    color: var(--c-text);
}

.welcome-expert-role {
    display: block;
    margin-top: 1px;
    font-size: 0.8rem;
    font-weight: 640;
    color: var(--c-primary);
}

.welcome-expert-bio {
    display: -webkit-box;
    margin-top: 5px;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--c-text-muted);
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- « Pour commencer » ---- */
.quick-actions-container {
    width: 100%;
    margin-top: 34px;
}

.quick-actions-label {
    margin: 0 0 12px;
    font-family: var(--f-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.035em;
    color: var(--c-text);
    text-align: left;
}

/* Grille à colonnes égales (cf. historique : jamais un flux de cartes centrées). Deux colonnes
   dans les 780 px, une sur téléphone ; nombre impair → la dernière carte prend la largeur. */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
    gap: 12px;
}

.quick-actions-grid .quick-action-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

.quick-action-card {
    min-width: 0;
    min-height: 88px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    background: var(--c-bg-card);
    color: var(--c-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform var(--dur-fast), box-shadow var(--dur-fast), border-color var(--dur-fast);
}

.quick-action-card:hover {
    transform: translateY(-2px);
    border-color: var(--c-primary-muted);
    box-shadow: var(--shadow-md);
}

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

/* Pastille du pictogramme : quatre teintes de la maquette, dans l'ordre des cartes. L'emoji
   (repli d'une action sans pictogramme connu) garde le même rond. */
.qa-icon {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--c-tint-rose);
    color: var(--c-tint-rose-ink);
    font-size: 1.15rem;
}

.quick-action-card:nth-child(4n + 2) .qa-icon { background: var(--c-primary-light); color: var(--c-primary); }
.quick-action-card:nth-child(4n + 3) .qa-icon { background: var(--c-tint-sand); color: var(--c-tint-sand-ink); }
.quick-action-card:nth-child(4n + 4) .qa-icon { background: var(--c-tint-olive); color: var(--c-tint-olive-ink); }

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

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

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

.qa-chevron {
    flex: none;
    margin-left: auto;
    color: var(--c-text-muted);
}

/* ---- Cartes du bas : Explorer, clic solidaire, promenade solidaire ---- */
.welcome-extras {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
    gap: 12px;
    margin-top: 12px;
    text-align: left;
}

.welcome-extras:not(:has(> :not([hidden]))) { display: none; }

.welcome-explore-card,
.welcome-clic-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px 14px 14px;
    border-radius: var(--r-lg);
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-fast);
}

.welcome-clic-card[hidden],
.welcome-explore-card[hidden] { display: none; }

.welcome-explore-card {
    border: 1px solid var(--c-border-light);
    background: var(--c-primary-light);
}

.welcome-explore-card:hover { background: var(--c-bg-warm); }

.welcome-clic-card {
    border: 1px solid var(--c-tint-stone-line);
    background: var(--c-tint-stone);
}

.welcome-clic-card:hover { background: var(--c-tint-stone-deep); }

.welcome-explore-card:focus-visible,
.welcome-clic-card:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.welcome-explore-card-ico,
.welcome-clic-card-ico {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.welcome-explore-card-ico { background: var(--c-bg-card); color: var(--c-primary); }
.welcome-clic-card-ico { background: var(--c-tint-stone-deep); color: var(--c-tint-stone-ink); }
.welcome-village-card.is-done .welcome-clic-card-ico { background: var(--c-primary-light); color: var(--c-primary); }
.welcome-village-card[role="button"] { cursor: pointer; }

.welcome-explore-card-texts,
.welcome-clic-card-texts {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.welcome-explore-card-title,
.welcome-clic-card-title {
    font-size: 0.97rem;
    font-weight: 650;
    line-height: 1.3;
    color: var(--c-text);
}

.welcome-explore-card-desc,
.welcome-clic-card-desc {
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--c-text-muted);
}

.welcome-explore-card-cta {
    flex: none;
    margin-left: auto;
    font-size: 0.9rem;
    font-weight: 650;
    color: var(--c-primary);
    white-space: nowrap;
}

.welcome-clic-card-chevron { flex: none; margin-left: auto; color: var(--c-tint-stone-ink); }

/* ---- Entrée en douceur (pas le titre : c'est l'affichage mesuré) ---- */
@keyframes wd-welcome-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.welcome-subtitle,
.welcome-trust,
.welcome-experts,
.quick-actions-container,
.welcome-extras {
    animation: wd-welcome-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.welcome-subtitle        { animation-delay: 0.06s; }
.welcome-trust           { animation-delay: 0.12s; }
.welcome-experts         { animation-delay: 0.18s; }
.quick-actions-container { animation-delay: 0.24s; }
.welcome-extras          { animation-delay: 0.3s; }

/* ---- Téléphone ---- */
@media (max-width: 767px) {
    .welcome-title { font-size: clamp(2rem, 9.2vw, 2.45rem); }
    .welcome-subtitle { font-size: 0.98rem; }
    .welcome-trust-item--data { display: none; }
    .welcome-experts-summary { gap: 10px; padding-right: 14px; }
    .welcome-experts-face { width: 30px; height: 30px; margin-left: -9px; }
    .welcome-experts-list { grid-template-columns: 1fr; }
    .input-disclaimer { font-size: 0.7rem; }
    .quick-actions-container { margin-top: 28px; }
    /* L'onglet Accueil de la barre du bas remplace la carte Explorer. */
    .welcome-explore-card { display: none; }
    .quick-actions-grid .qa-description {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Écrans bas (portables 1280 × 800, iPhone SE) : le titre se resserre d'un cran. */
@media (max-height: 820px) and (min-width: 768px) {
    .welcome-title { font-size: clamp(2.1rem, 3.4vw, 2.9rem); }
    .quick-actions-container { margin-top: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    .welcome-subtitle,
    .welcome-trust,
    .welcome-experts,
    .quick-actions-container,
    .welcome-extras {
        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(24, 79, 82, 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(24, 79, 82, 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%;
    /* Corail Unique v2 (ADO-1) : créer un compte n'est pas parler à l'IA. Pêche pour
       l'accent chaleureux, teal pour l'action (ci-dessous). */
    background: var(--c-accent);
    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-primary);
    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-primary-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: 780px;
    margin: 0 auto;
}

/* Zone de saisie de la maquette (lot B2) : les animaux en tête, le texte sur toute la largeur,
   puis une rangée « photo · outils … envoyer ». L'ordre visuel est posé par `order` : le HTML
   (et les scripts qui y insèrent les puces d'animaux ou de photo) ne change pas. */
.input-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 10px 10px 9px 14px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 24px;
    box-shadow: 0 4px 18px rgba(24, 46, 43, 0.07);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input-wrapper:focus-within {
    border-color: var(--c-primary-muted);
    box-shadow: 0 4px 22px rgba(24, 46, 43, 0.11);
}

.input-wrapper > .pet-chips-row { order: 0; }
.input-wrapper > .chat-photo-chip-row { order: 1; }
.input-wrapper > .main-textarea { order: 2; }
.input-wrapper > .services-toolbar-row { order: 3; flex: 1 1 auto; width: auto; min-width: 0; padding: 0; }
.input-wrapper > .send-btn { order: 4; margin-left: auto; }

.main-textarea {
    flex: 1 1 100%;
    min-height: 44px;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--f-body);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--c-text);
    background: transparent;
    padding: 10px 2px 6px;
    max-height: 180px;
    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: 46px;
    height: 46px;
    border: none;
    border-radius: var(--r-full);
    background: var(--c-accent-vivid);
    color: var(--c-on-vivid);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), transform var(--dur-fast);
}

.send-btn:hover {
    background: var(--c-accent-vivid-hover);
    transform: translateY(-1px);
}

/* Boutons ronds de la rangée du bas (photo) et pilule « Outils » : la maquette. Posés ici, dans
   la feuille critique, pour qu'ils ne changent pas de forme quand leur feuille arrive. */
.input-wrapper .chat-photo-btn {
    width: 42px;
    height: 42px;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid var(--c-border);
    border-radius: 50%;
    background: var(--c-bg-card);
    color: var(--c-text-muted);
}

.input-wrapper .chat-photo-btn:hover { background: var(--c-bg-warm); color: var(--c-primary); border-color: var(--c-border); }

.input-wrapper .services-btn {
    height: 42px;
    gap: 7px;
    padding: 0 15px 0 12px;
    border: 1px solid var(--c-border);
    color: var(--c-text-secondary);
    font-size: 0.86rem;
    font-weight: 620;
}

.input-wrapper .services-btn:hover { background: var(--c-bg-warm); color: var(--c-text-secondary); border-color: var(--c-border); }

.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);
    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 {
    margin: 0;
    padding: 8px 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--c-text-muted);
    text-wrap: balance;
}

/* 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(). */

/* ============================================================
   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+) — colonne de la maquette (lot B2d) : messages, accueil et zone de saisie
   sur la même largeur de 780 px (812 px = 780 + les 16 px de marge intérieure de chaque côté). */
@media (min-width: 1280px) {
    .chat-messages-scroll { max-width: 812px; }
}

/* 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;
        /* Gain de place : bio tronquée à 2 lignes par défaut. Le bouton « Voir plus »
           (ajouté par JS si elle déborde) retire le clamp via .bio-expanded. */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .agent-intro-card.bio-expanded .agent-intro-bio {
        -webkit-line-clamp: unset;
        overflow: visible;
    }
    /* Bouton déployer/replier la bio (mobile uniquement — .agent-intro-info est display:contents
       ici, donc le bouton est un item de la grille : on le place en ligne 4 pleine largeur). */
    .agent-intro-bio-toggle {
        grid-row: 4;
        grid-column: 1 / -1;
        justify-self: start;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin-top: 6px;
        padding: 2px 0;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--c-primary);
        font-family: var(--f-body);
        font-size: 0.8rem;
        font-weight: 600;
    }
    .agent-intro-bio-chevron {
        transition: transform var(--dur-fast) var(--ease-out);
    }
    .agent-intro-card.bio-expanded .agent-intro-bio-chevron {
        transform: rotate(180deg);
    }
    .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; }
    .main-textarea { font-size: 16px; }

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

}

/* 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; }
    .indicator-role { max-width: 100px; }

    /* 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;
    }
}

/* 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; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .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);
    }
}

/* =========================================
   Promo app iOS (BIZ11) — bannière contextuelle au-dessus du composer.
   Insérée par demo-pwa.js (maybeShowAppPromo) sur iOS WEB uniquement,
   après une réponse complète ou un login. Fermable, cappée 1×/14 j.
   ========================================= */
.app-promo-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 768px; /* aligné sur .input-container */
    margin: 0 auto 8px;
    padding: 10px 12px;
    background: var(--c-bg-warm);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    animation: app-promo-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@media (prefers-reduced-motion: reduce) {
    .app-promo-banner { animation: none; }
}

.app-promo-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--c-primary-light);
    color: var(--c-primary);
}

.app-promo-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.app-promo-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--c-text);
}

.app-promo-text {
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--c-text-secondary);
}

.app-promo-cta {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--c-primary);
    color: var(--c-text-inverse);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}

.app-promo-cta:hover {
    background: var(--c-primary-hover);
}

.app-promo-close {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--c-text-muted);
    cursor: pointer;
}

.app-promo-close:hover {
    background: var(--c-bg-card);
    color: var(--c-text);
}

@media (max-width: 480px) {
    .app-promo-text { display: none; } /* compact : titre + CTA suffisent */
}
