/* Chat IA Français — thème sombre, layout moderne */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
    --bg-app: #0a0b0f;
    --bg-sidebar: #0f1117;
    --bg-chat: #12141c;
    --bg-input: #161922;
    --bg-elevated: #1a1e28;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #eceef2;
    --text-muted: #8b919d;
    --accent: #22d3ee;
    --accent-dim: rgba(34, 211, 238, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 260px;
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    overflow: hidden;
}

body {
    margin: 0;
    height: 100%;
    height: var(--app-height, 100dvh);
    max-height: 100vh;
    max-height: 100dvh;
    max-height: var(--app-height, 100dvh);
    min-height: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

body.page-index {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ——— Layout principal : plein écran, pas de scroll page ——— */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    position: fixed;
    top: var(--app-top, 0px);
    left: 0;
    right: 0;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: var(--app-height, 100dvh);
    height: var(--app-height, 100dvh);
    overflow: hidden;
}

.left-panel {
    grid-column: 1;
    grid-row: 1 / -1;
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0c0e14 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Logo : zone fixe, jamais dans le scroll */
.sidebar-brand {
    flex-shrink: 0;
    padding: 0.75rem 1rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(15, 17, 23, 0.98) 0%, var(--bg-sidebar) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tokens restants : sous le logo, zone fixe */
.sidebar-chats {
    flex-shrink: 0;
    padding: 0.65rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-model-slot {
    width: 100%;
    min-width: 0;
}

/* Conversations, description, contact, annonces : zone scrollable */
.sidebar-info {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.65rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Mentions légales / liens : bas fixe de la colonne gauche */
.sidebar-legal {
    flex-shrink: 0;
    padding: 0.5rem 1rem 0.65rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0c0e14 100%);
}

.sidebar-disclaimer {
    margin: 0.45rem 0 0;
    font-size: 0.68rem;
    line-height: 1.35;
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
}

.bloc-mentions-sidebar {
    margin: 0;
    text-align: center;
    line-height: 1.35;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.15rem 0;
    font-size: 0.6rem;
}

.bloc-mentions-sidebar .mentions-sep {
    text-decoration: none;
    cursor: default;
    padding: 0 0.2rem;
    opacity: 0.55;
    user-select: none;
}

.chat-panel {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.footer-input {
    grid-column: 2;
    grid-row: 2;
    background: var(--bg-input);
    border-top: 1px solid var(--border);
    padding: 0.45rem 0.75rem 0.6rem;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
}

/* Ancienne classe conservée pour cohérence */
.right-panel {
    background: var(--bg-chat);
}

.right-input {
    background: var(--bg-input);
}

/* Logo & branding */
#bloc-logo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0;
    color: var(--text);
}

.site-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex-shrink: 0;
}

#logo-title .brand-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

#logo-title .brand-title span {
    font-size: inherit;
}

#left-install-app {
    margin-top: 0.5rem;
}

/* Conversations (IndexedDB) — dans .sidebar-info, défile avec le reste */
.conversations-block {
    margin-bottom: 0.65rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.conversations-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    margin-top: 0;
}

/* Modèle IA : en tête du bloc, au-dessus du titre Conversations */
.conversations-model {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.conversations-model-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.conversations-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.btn-new-conversation {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-new-conversation svg {
    width: 14px;
    height: 14px;
    display: block;
}

.btn-new-conversation:hover {
    background: var(--accent-dim);
    border-color: rgba(34, 211, 238, 0.35);
    color: var(--text-muted);
}

.conversations-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conversations-storage-note {
    margin-top: 0.4rem;
    font-size: 0.64rem;
    line-height: 1.3;
    color: rgba(236, 238, 242, 0.45);
    user-select: none;
}

.conversation-item {
    display: flex;
    align-items: stretch;
    gap: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    overflow: hidden;
}

.conversation-item.active {
    border-color: rgba(34, 211, 238, 0.45);
    box-shadow: 0 0 0 1px var(--accent-dim);
}

.conversation-item-btn {
    flex: 1;
    min-width: 0;
    padding: calc(0.35rem + 1.5px) 0.45rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.72rem;
    text-align: left;
    cursor: pointer;
    line-height: 1.25;
}

.conversation-item-btn:hover {
    background: var(--bg-hover);
}

.conversation-item-rename {
    flex-shrink: 0;
    width: 26px;
    padding: 0;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
}

.conversation-item-rename:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

.conversation-item-del {
    flex-shrink: 0;
    width: 26px;
    padding: 0;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.conversation-item-del:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Zone de saisie + glisser-déposer */
.input-compose-area {
    border-radius: var(--radius);
    border: 1px dashed transparent;
    padding: 0;
    margin-bottom: 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.input-compose-area.compose-drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.attachment-preview-thumb-wrap {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #0d0f14;
    border: 1px solid var(--border);
}

.attachment-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-preview-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.attachment-preview-name {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.35;
    padding-top: 0.15rem;
}

.attachment-preview-actions {
    flex-shrink: 0;
    display: inline-flex;
    align-items: flex-start;
    gap: 0.35rem;
}

.attachment-preview-edit {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.12s ease;
}

.attachment-preview-edit:hover {
    background: var(--accent-dim);
    border-color: rgba(34, 211, 238, 0.45);
    color: var(--accent);
}

.attachment-preview-edit:active {
    transform: scale(0.94);
}

.attachment-preview-edit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.attachment-preview-remove {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 1.35rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.12s ease;
}

.attachment-preview-remove:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(248, 113, 113, 0.5);
    color: #f87171;
}

.attachment-preview-remove:active {
    transform: scale(0.94);
}

.attachment-preview-remove:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#left-token-limit {
    color: var(--text);
    text-align: left;
    font-size: 0.8rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#left-token-limit h3 {
    margin: 0.5rem 0 0;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.4;
}

#token-count,
#token-count-2 {
    color: var(--accent) !important;
    font-weight: 600;
}

.token-info-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 2px;
    margin: 0;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 0;
    border-radius: 999px;
    flex-shrink: 0;
}

.token-info-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

.token-info-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.token-info-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.token-info-btn--mobile svg {
    width: 15px;
    height: 15px;
}

#left-your-id {
    text-align: left;
    padding-top: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
}

#left-your-id a {
    color: var(--accent);
    text-decoration: none;
}

#left-your-id a:hover {
    text-decoration: underline;
}

#left-contact {
    position: relative;
    margin-top: auto;
    padding-top: 0.75rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
}

#left-contact a {
    color: var(--accent);
    text-decoration: none;
}

#left-contact a:hover {
    text-decoration: underline;
}

#annonce-left {
    margin-top: 0.35rem;
}

/* Zone chat — seul défilement principal de la colonne centrale */
#chat {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 1.25rem;
    padding-bottom: 0.75rem;
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    --bubble-user-bg: linear-gradient(145deg, rgba(34, 211, 238, 0.22) 0%, rgba(34, 211, 238, 0.1) 100%);
    --bubble-user-border: rgba(34, 211, 238, 0.35);
    --bubble-assistant-bg: rgba(26, 30, 40, 0.95);
    --bubble-assistant-border: rgba(255, 255, 255, 0.1);
    --bubble-radius: 16px;
    --bubble-radius-tail: 4px;
}

#right-token-limit {
    color: var(--text);
    text-align: left;
    flex-shrink: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
    background: var(--bg-chat);
}

#right-token-limit table {
    width: 100%;
    border-collapse: collapse;
}

#right-token-limit .header-chat-mobile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

#right-token-limit .header-chat-mobile-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#right-token-limit .header-chat-mobile-row img,
#right-token-limit .header-chat-mobile img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
}

#right-token-limit .title-mobile {
    font-size: 1rem;
    font-weight: 600;
}

#but-token-limit-infos {
    vertical-align: top;
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
}

.token-limit-mobile-line {
    cursor: default;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Bouton menu mobile (≤420px) : visible seulement sur petit écran via media query */
.btn-mobile-sidebar {
    display: none;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.btn-mobile-sidebar:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn-mobile-sidebar__icon {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    box-shadow: 0 -6px 0 var(--text), 0 6px 0 var(--text);
}

.sidebar-backdrop {
    display: none;
}

.mobile-model-slot {
    width: 100%;
    min-width: 0;
}

.mobile-model-slot[hidden] {
    display: none !important;
}

.mobile-model-slot .sidebar-model-select,
.mobile-model-slot #selected-api {
    width: 100%;
    font-size: 0.78rem;
    padding: 0.35rem 0.45rem;
}

/* Barre de saisie (compose) */
.compose-bar {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.compose-bar__textarea,
#input-question.compose-bar__textarea {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    max-height: 150px;
    resize: none;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text) !important;
    padding: 0.5rem 0.65rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.35;
}

.compose-bar__textarea::placeholder,
#input-question.compose-bar__textarea::placeholder {
    color: var(--text-muted);
    font-weight: 500;
    opacity: 1;
}

.compose-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.compose-bar__attach {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-elevated) !important;
    color: var(--text) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.compose-bar__attach:hover {
    background: var(--bg-hover) !important;
    border-color: var(--border-strong) !important;
}

.compose-bar__attach-icon {
    display: block;
    width: 18px;
    height: 18px;
    background: url("../img/attachment.png") center / contain no-repeat;
    opacity: 0.65;
}

.compose-bar__send,
#button-input-question.compose-bar__send {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: var(--radius-sm) !important;
    border: 1px solid rgba(34, 211, 238, 0.35) !important;
    background: var(--accent-dim) !important;
    color: var(--accent) !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.compose-bar__send:hover,
#button-input-question.compose-bar__send:hover {
    background: rgba(34, 211, 238, 0.22) !important;
}

/* Flèche « envoyer » (remplace le libellé ; title / aria-label conservés sur le bouton) */
.compose-bar__send-icon {
    display: block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z'/%3E%3C/svg%3E")
        center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z'/%3E%3C/svg%3E")
        center / contain no-repeat;
}

.file-attached {
    background: rgba(34, 211, 238, 0.15) !important;
    border-color: rgba(34, 211, 238, 0.4) !important;
}

.file-attached .compose-bar__attach-icon {
    opacity: 1;
}

#selected-api,
.sidebar-model-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-elevated) !important;
    color: var(--text) !important;
    padding: 0.4rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.3;
    cursor: pointer;
}

#selected-api option,
.sidebar-model-select option {
    background: var(--bg-elevated);
    color: var(--text);
}

.bloc-mentions {
    color: var(--text-muted);
    font-size: 0.68rem;
    text-align: center;
    margin-top: 0.25rem;
}

.bloc-mentions .show-conditions,
.bloc-mentions .show-why,
.bloc-mentions .freepik,
.bloc-mentions .sidebar-legal-link {
    padding: 0 0.35rem;
    text-decoration: underline;
    cursor: pointer;
    color: inherit;
}

.bloc-mentions .show-conditions:hover,
.bloc-mentions .show-why:hover,
.bloc-mentions .freepik:hover,
.bloc-mentions .sidebar-legal-link:hover {
    color: var(--accent);
}

.sidebar-seo-links {
    margin-top: 0.25rem !important;
}

/* ——— État vide du chat : SEO visible + indexable (sans scroll page) ——— */
.chat-seo-empty {
    max-width: 720px;
    margin: 0 auto;
    padding: 0.5rem 0.35rem 1.5rem;
    line-height: 1.6;
    color: var(--text);
}

.chat-seo-empty[hidden] {
    display: none !important;
}

.seo-disclaimer {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.seo-content__h1 {
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
    margin: 0 0 0.65rem;
    letter-spacing: -0.02em;
    font-weight: 700;
    line-height: 1.25;
}

.chat-seo-empty > p {
    margin: 0 0 1rem;
    color: rgba(236, 238, 242, 0.92);
    font-size: 0.92rem;
}

.seo-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.55rem;
    margin: 1rem 0 0.75rem;
}

.seo-highlight {
    display: block;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.seo-highlight:hover {
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(34, 211, 238, 0.06);
}

.seo-highlight strong {
    display: block;
    color: var(--accent);
    margin-bottom: 0.15rem;
    font-size: 0.88rem;
}

.seo-highlight span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-seo-empty__faq-title,
.chat-seo-empty h2 {
    font-size: 1.05rem;
    margin: 1.35rem 0 0.65rem;
    font-weight: 700;
    line-height: 1.3;
}

.chat-seo-empty h2 + p {
    margin: 0 0 0.85rem;
    color: rgba(236, 238, 242, 0.92);
    font-size: 0.92rem;
}

.seo-disclaimer a {
    color: var(--accent);
}

.chat-seo-empty details {
    margin: 0.45rem 0;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.025);
}

.chat-seo-empty summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-seo-empty details p {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.seo-footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1.1rem;
    margin-top: 1.35rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

.seo-footer-nav a {
    color: var(--text-muted);
    text-decoration: none;
}

.seo-footer-nav a:hover {
    color: var(--accent);
}

/* Messages — bulles type app mobile (sans avatar, méta légère + action texte) */
.chat-msg {
    position: relative;
    margin-bottom: 0.72rem;
    overflow-x: hidden !important;
    max-width: 100%;
}

/* Nouvelles sauvegardes : pas de carte pleine largeur */
.chat-msg:has(.chat-msg-inner) {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

/* Anciennes conversations (HTML sans .chat-msg-inner) */
.chat-msg:not(:has(.chat-msg-inner)) {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-elevated);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.chat-msg-inner {
    max-width: min(90%, 40rem);
    width: 100%;
}

.chat-msg--user .chat-msg-inner {
    margin-left: auto;
    max-width: min(82%, 34rem);
}

.chat-msg--assistant .chat-msg-inner {
    margin-right: auto;
}

.chat-msg--system .chat-msg-inner {
    margin-left: auto;
    margin-right: auto;
    max-width: min(94%, 26rem);
}

.chat-msg-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    max-width: 100%;
}

.chat-msg--user .chat-msg-stack {
    align-items: flex-end;
}

.chat-msg--system .chat-msg-stack {
    align-items: center;
}

.chat-msg-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.72;
    line-height: 1.2;
    padding: 0 0.35rem;
    max-width: 100%;
}

.chat-msg--user .chat-msg-meta {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.chat-msg--assistant .chat-msg-meta,
.chat-msg--system .chat-msg-meta {
    justify-content: flex-start;
}

.chat-msg-author {
    display: inline-block;
    min-width: 0;
}

.chat-msg-menu-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.35rem;
    flex-shrink: 0;
    line-height: 1;
}

.chat-msg-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(34, 38, 47, 0.9);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.95;
    transition: transform 120ms ease, border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.chat-msg-action-btn:hover {
    background: rgba(42, 48, 60, 0.95);
    border-color: rgba(34, 211, 238, 0.35);
    color: var(--accent);
    opacity: 1;
    transform: translateY(-1px);
}

.chat-msg-action-btn:active {
    transform: translateY(0);
}

.chat-msg-action-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.chat-msg-action-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.chat-msg-action-btn > span[aria-hidden="true"] {
    font-size: 1.05rem;
    line-height: 1;
    font-weight: 700;
}

.chat-msg-action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: currentColor;
}

.chat-msg-bubble {
    position: relative;
    max-width: 100%;
    border-radius: var(--bubble-radius);
    padding: 0.48rem 0.72rem 0.55rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Les actions sont désormais dans l’en-tête (meta), pas dans la bulle */

.chat-msg--assistant .chat-msg-bubble {
    background: var(--bubble-assistant-bg);
    border: 1px solid var(--bubble-assistant-border);
    border-bottom-left-radius: var(--bubble-radius-tail);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.chat-msg--user .chat-msg-bubble {
    background: var(--bubble-user-bg);
    border: 1px solid var(--bubble-user-border);
    border-bottom-right-radius: var(--bubble-radius-tail);
    box-shadow: 0 2px 10px rgba(34, 211, 238, 0.06);
}

.chat-msg--system .chat-msg-bubble {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 12px;
    text-align: center;
}

.chat-msg-content {
    font-weight: normal;
    color: var(--text);
    font-size: 0.8125rem;
}

.chat-msg--user .chat-msg-content {
    color: #e8fbfe;
}

.chat-msg-content > *:first-child {
    margin-top: 0;
}

.chat-msg-content > *:last-child {
    margin-bottom: 0;
}

.chat-msg-bubble .chat-msg-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-msg--user .chat-msg-bubble .chat-msg-content a {
    color: #a5f3fc;
}

.chat-msg-bubble .chat-msg-content pre {
    margin: 0.5rem 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow-x: auto;
    font-size: 0.75rem;
}

.chat-msg-bubble .chat-msg-content code {
    font-size: 0.88em;
}

.chat-msg-bubble .chat-msg-content p {
    margin: 0.35rem 0;
}

.chat-msg-bubble .chat-msg-content ul,
.chat-msg-bubble .chat-msg-content ol {
    margin: 0.45rem 0;
    padding-left: 1.25rem;
}

.chat-msg-bubble .chat-msg-content img,
.chat-msg-bubble .chat-msg-content .img-dl {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    vertical-align: middle;
}

.chat-msg:not(:has(.chat-msg-inner)) .chat-msg-title {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
}

/* Plus d’avatar dans les bulles (y compris anciennes sauvegardes IndexedDB) */
.chat-logo {
    display: none !important;
}

/* Anciens boutons PNG supprimés : les actions utilisent désormais `.chat-msg-action-btn` + SVG */

.arrow {
    border: solid var(--text);
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 3px;
}

.arrow-right {
    transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
}

.lds-ellipsis {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
    margin-left: 5px;
}

.lds-ellipsis div {
    position: absolute;
    top: 20px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.lds-ellipsis div:nth-child(1) {
    left: 8px;
    animation: lds-ellipsis1 0.6s infinite;
}

.lds-ellipsis div:nth-child(2) {
    left: 8px;
    animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(3) {
    left: 32px;
    animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(4) {
    left: 56px;
    animation: lds-ellipsis3 0.6s infinite;
}

@keyframes lds-ellipsis1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes lds-ellipsis3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes lds-ellipsis2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

.chat-msg-content-quote {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    padding: 10px;
}

.chat-msg-content-bold {
    font-weight: bold;
    text-decoration: underline;
}

.chat-msg h1,
.chat-msg h2,
.chat-msg h3,
.chat-msg h4,
.chat-msg h5,
.chat-msg h6 {
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-size: 1.05em;
    color: var(--text);
}

.chat-msg p {
    margin: 0.5em 0;
}

.pwa-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.18), rgba(34, 211, 238, 0.10));
    color: var(--text);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--accent-dim) inset;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.pwa-install-btn svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: var(--accent);
}

.pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(34, 211, 238, 0.22) inset;
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(34, 211, 238, 0.12));
    color: var(--text);
}

.pwa-install-btn:active {
    transform: translateY(0px);
}

.pwa-install-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pwa-install-btn--compact {
    width: 100%;
    padding: 8px 12px;
    font-weight: 650;
    letter-spacing: 0.15px;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26), 0 0 0 1px var(--accent-dim) inset;
}

.pwa-install-btn--compact span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chat-msg blockquote {
    border-left: 3px solid var(--accent);
    color: var(--text-muted);
    padding: 0.5em 1em;
    margin: 0.5em 0;
    background: rgba(0, 0, 0, 0.2);
}

.chat-msg code {
    background: rgba(0, 0, 0, 0.35);
    padding: 0.15em 0.4em;
    font-size: 0.88em;
    border-radius: 4px;
}

.chat-msg pre {
    background: #0d0f14;
    padding: 1em;
    overflow: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.chat-msg pre code {
    background: transparent;
    padding: 0;
    font-size: 0.9em;
    color: #7ee787;
}

.chat-msg ul,
.chat-msg ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.chat-msg table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.chat-msg table th,
.chat-msg table td {
    border: 1px solid var(--border);
    padding: 0.5em 0.75em;
}

.chat-msg table th {
    background: rgba(0, 0, 0, 0.35);
}

.chat-msg del {
    text-decoration: line-through;
}

.chat-msg strong {
    font-weight: 600;
}

.chat-msg em {
    font-style: italic;
}

.iframeannonce {
    margin: auto;
    display: block;
    border-radius: var(--radius-sm);
}

.qc-cmp2-persistent-link {
    background-color: transparent !important;
    font-size: 50%;
}

/* Modales — thème sombre */
.modal-content.theme-dark-modal {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.theme-dark-modal .modal-header {
    border-bottom-color: var(--border);
    padding: 1rem 1.25rem;
}

.theme-dark-modal .modal-title {
    color: var(--text);
    font-weight: 600;
}

.theme-dark-modal .modal-body {
    padding: 1rem 1.25rem;
    color: var(--text-muted);
}

.theme-dark-modal .modal-body a {
    color: var(--accent);
}

.theme-dark-modal .modal-footer {
    border-top-color: var(--border);
    padding: 0.75rem 1.25rem;
    gap: 0.5rem;
}

.theme-dark-modal .form-check-label {
    color: var(--text);
}

.theme-dark-modal .form-control {
    background: var(--bg-chat);
    border-color: var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    max-width: 100%;
}

.theme-dark-modal .form-control:focus {
    background: var(--bg-chat);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.theme-dark-modal .form-control::placeholder {
    color: rgba(255, 255, 255, 0.55);
    opacity: 1;
}

.theme-dark-modal .btn-primary {
    background: var(--accent);
    border: none;
    color: #0a0b0f;
    font-weight: 600;
}

.theme-dark-modal .btn-primary:hover {
    filter: brightness(1.08);
    color: #0a0b0f;
}

.theme-dark-modal .btn-outline-primary {
    border-color: var(--border-strong);
    color: var(--text);
    background: transparent;
}

.theme-dark-modal .btn-outline-primary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

.theme-dark-modal .btn-secondary {
    background: var(--bg-chat);
    border-color: var(--border);
    color: var(--text);
}

.theme-dark-modal .btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.theme-dark-modal .paypal-offer-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(34, 211, 238, 0.06);
}

.theme-dark-modal .paypalamountprice {
    color: var(--accent) !important;
}

/* Modale édition image + masque */
.modal-image-edit-dialog {
    max-width: min(560px, calc(100vw - 1.5rem));
}

.modal-image-edit-preview-wrap {
    position: relative;
    display: block;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-chat);
    line-height: 0;
}

.modal-image-edit-preview-img {
    display: block;
    max-width: 100%;
    height: auto;
    vertical-align: top;
}

.modal-image-edit-mask-canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.theme-dark-modal .form-range {
    max-width: 100%;
}

.paypal-less,
.paypal-more {
    border-radius: var(--radius-sm) !important;
}

.modal-dialog {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#modal-popup-informations-content {
    width: min(720px, 92vw);
    max-height: 90vh;
}

#modal-popup-informations-body {
    font-size: 0.9rem;
    text-align: justify;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
    padding: 0 1.25rem 1rem;
    color: var(--text-muted);
}

/* PC */
@media only screen and (min-width: 930px) {
    .site-logo {
        width: 52px;
        height: 52px;
    }

    #logo-title .brand-title {
        font-size: 1.15rem;
    }

    /* Bulles conversation : largeur max 70% sur PC */
    .chat-msg-inner,
    .chat-msg--user .chat-msg-inner,
    .chat-msg--system .chat-msg-inner {
        max-width: 70%;
    }
}

/* Grands écrans : élargit le panneau gauche */
@media only screen and (min-width: 1200px) {
    :root {
        --sidebar-w: 320px;
    }
}

@media only screen and (min-width: 1600px) {
    :root {
        --sidebar-w: 360px;
    }
}

/* Mobile */
@media only screen and (max-width: 929px) {
    .footer-input {
        padding: 0.38rem 0.55rem 0.48rem;
    }

    .compose-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
    }

    .compose-bar__actions {
        width: 100%;
        justify-content: stretch;
    }

    .compose-bar__send,
    #button-input-question.compose-bar__send {
        flex: 1;
        min-height: 44px;
    }

    .compose-bar__textarea,
    #input-question.compose-bar__textarea {
        min-height: 44px;
        max-height: 120px;
        font-size: 16px;
    }

    #chat {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .site-logo {
        width: 44px;
        height: 44px;
        margin: 0 auto;
    }

    .sidebar-brand {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .sidebar-chats {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .sidebar-info {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    #bloc-logo {
        flex-direction: column;
        text-align: center;
    }

    #logo-title .brand-title {
        font-size: 0.75rem;
    }

    #left-token-limit {
        font-size: 0.68rem;
        padding: 0.5rem;
    }

    #left-contact {
        font-size: 0.6rem;
        text-align: center;
    }

    #modal-popup-informations-content {
        width: 95vw;
        max-height: 90vh;
    }

    #modal-popup-informations-body {
        font-size: 0.8rem;
    }

}

/* Mobile (tiroir sidebar + header mobile) */
@media only screen and (max-width: 929px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas:
            "chat"
            "footer";
        height: 100vh;
        height: 100dvh;
        height: var(--app-height, 100dvh);
        max-height: 100vh;
        max-height: 100dvh;
        max-height: var(--app-height, 100dvh);
        min-height: 0;
    }

    .sidebar-backdrop {
        display: block;
        grid-area: chat;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, 0.52);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    body.mobile-sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .left-panel {
        display: flex;
        grid-area: chat;
        position: fixed;
        top: 0;
        left: 0;
        width: min(100vw - 48px, 300px);
        max-width: 92vw;
        height: 100%;
        max-height: 100dvh;
        z-index: 1050;
        transform: translate3d(-100%, 0, 0);
        transition: transform 0.22s ease;
        pointer-events: none;
        box-shadow: none;
    }

    body.mobile-sidebar-open .left-panel {
        transform: translate3d(0, 0, 0);
        pointer-events: auto;
        box-shadow: 6px 0 28px rgba(0, 0, 0, 0.45);
    }

    body.mobile-sidebar-open {
        overflow: hidden;
    }

    .btn-mobile-sidebar {
        display: inline-flex;
    }

    .chat-panel,
    .footer-input {
        grid-column: unset;
    }

    .chat-panel {
        grid-area: chat;
        min-height: 0;
    }

    .footer-input {
        grid-area: footer;
    }

    /* En-tête mobile hors du scroll : même colonne, au-dessus de #chat */
    .chat-panel {
        flex-direction: column;
        min-height: 0;
    }

    #right-token-limit {
        margin-bottom: 0;
        padding-top: 0.45rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: 0.55rem;
    }

    #chat {
        flex: 1 1 0;
        min-height: 0;
        padding-top: 0.5rem;
    }

    .right-panel {
        font-size: 0.92rem;
    }

    .modal {
        font-size: 0.9rem;
    }

    .modal-body {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .footer-input {
        padding: 0.32rem 0.45rem 0.42rem;
        padding-bottom: max(0.42rem, env(safe-area-inset-bottom, 0px));
    }

    .attachment-preview {
        padding: 0.35rem 0.45rem;
        margin-bottom: 0.3rem;
    }

    /* Une seule ligne : zone de texte + boutons, pied de page plus bas */
    .compose-bar {
        flex-direction: row;
        align-items: flex-end;
        gap: 0.35rem;
    }

    .compose-bar__actions {
        width: auto;
        flex-shrink: 0;
        justify-content: flex-end;
    }

    .compose-bar__attach {
        width: 38px;
        min-width: 38px;
        height: 38px;
    }

    .compose-bar__send,
    #button-input-question.compose-bar__send {
        flex: 0 0 auto;
        width: 38px;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .compose-bar__send-icon {
        width: 20px;
        height: 20px;
    }

    .compose-bar__textarea,
    #input-question.compose-bar__textarea {
        min-height: 38px;
        max-height: 96px;
        padding: 0.45rem 0.55rem;
        font-size: 16px;
    }

    .site-logo {
        width: 56px;
        height: 56px;
    }
}

@media only screen and (min-width: 930px) {
    #right-token-limit {
        display: none;
    }
}

@media only screen and (max-height: 620px) {
    #left-your-id {
        display: none;
    }
}

* {
    scrollbar-width: thin !important;
    scrollbar-color: rgba(34, 211, 238, 0.35) var(--bg-sidebar) !important;
}

@media print {
    html,
    body {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .app-layout {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .site-logo {
        width: 100px;
        height: 100px;
    }

    .left-panel {
        display: none;
    }

    .right-input,
    .footer-input {
        display: none;
    }

    .modal {
        display: none !important;
    }

    #chat {
        overflow-y: visible;
        margin-bottom: 10mm;
    }

    .but-remove,
    .but-download {
        display: none;
    }

    @page {
        size: A4 portrait;
        margin: 10mm;
    }
}
