/* ══════════════════════════════════════════
   SWAPI PREMIUM — premium.css
   Tous les styles spécifiques à la version Premium
   ══════════════════════════════════════════ */

/* ══════════════════════════════════════════
   VARIABLES & BASE
══════════════════════════════════════════ */
:root {
    --c-bg:       #faf9f7;
    --c-surface:  #ffffff;
    --c-border:   #e8e4de;
    --c-border-2: #d4cfc8;
    --c-text:     #2a2520;
    --c-muted:    #7a726a;
    --c-subtle:   #aca49a;
    --c-amber:    #c8813a;
    --c-amber-l:  #fef6ec;
    --c-amber-m:  #fde5c3;
    --c-success:  #16a34a;
    --c-error:    #dc2626;
    --radius:     12px;
    --radius-lg:  18px;
    --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:  0 12px 40px rgba(0,0,0,.09), 0 4px 12px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }


body {
    font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* Gradient mesh animé — subtil, professionnel */
    background-color: #faf9f7;
}

/* ══════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════ */
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 99px; }

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */
#app-container { height: 100vh; display: flex; flex-direction: column; }

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
header {
    height: 54px;
    background: rgba(255, 252, 248, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 1px 0 rgba(200, 129, 58, 0.08),
        0 4px 24px rgba(0, 0, 0, 0.04);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    flex-shrink: 0; z-index: 20;
}
.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 6px; }

.logo-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer; padding: 0;
}
.logo-img { height: 28px; object-fit: contain; }
.logo-wordmark { font-size: 1rem; font-weight: 800; color: var(--c-text); letter-spacing: -.02em; }
.logo-badge {
    font-size: 8.5px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--c-amber);
    background: var(--c-amber-l); border: 1px solid var(--c-amber-m);
    padding: 2px 6px; border-radius: 99px;
}

#sidebar-toggle-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px;
    border: 1px solid var(--c-border);
    background: var(--c-surface); color: var(--c-muted);
    cursor: pointer; transition: all .15s;
}
#sidebar-toggle-btn:hover { background: var(--c-bg); color: var(--c-text); }

.header-btn {
    display: flex; align-items: center; gap: 5px;
    background: none; border: 1px solid transparent;
    border-radius: 9px; padding: 5px 9px;
    font-size: .75rem; font-weight: 500; color: var(--c-muted);
    cursor: pointer; transition: all .15s; font-family: inherit;
}
.header-btn:hover { background: var(--c-bg); border-color: var(--c-border); color: var(--c-text); }
.header-sep { width: 1px; height: 18px; background: var(--c-border); margin: 0 2px; }

.protected-badge {
    display: flex; align-items: center; gap: 5px;
    font-size: .7rem; font-weight: 600; color: var(--c-amber);
    background: var(--c-amber-l); border: 1px solid var(--c-amber-m);
    padding: 3px 9px; border-radius: 99px;
}

.mobile-btn {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--c-muted); padding: 4px;
}
@media (max-width: 1023px) {
    .mobile-btn { display: flex; }
    #sidebar-toggle-btn { display: none; }
}

#user-greeting {
    display: none; align-items: center; gap: 6px;
}
.greeting-name {
    font-size: .78rem; font-weight: 600; color: var(--c-text);
    background: var(--c-bg); border: 1px solid var(--c-border);
    padding: 3px 9px; border-radius: 99px;
}

/* ══════════════════════════════════════════
   ADMIN BANNER
══════════════════════════════════════════ */
.admin-banner {
    display: flex; align-items: center; gap: 10px;
    background: var(--c-amber-l); border-bottom: 1px solid var(--c-amber-m);
    padding: 8px 18px; font-size: .77rem; color: #7c4b1a;
}
.admin-banner-text { flex: 1; font-weight: 500; }
.admin-banner-close {
    background: none; border: none; cursor: pointer;
    color: #c8813a; opacity: .7; padding: 2px; display: flex;
}
.admin-banner-close:hover { opacity: 1; }

/* ══════════════════════════════════════════
   BODY LAYOUT
══════════════════════════════════════════ */
#body-wrapper { flex: 1; display: flex; overflow: hidden; position: relative; }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
#main-sidebar {
    width: 0; overflow: hidden; flex-shrink: 0;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column;
    transition: width .25s cubic-bezier(.4,0,.2,1);
}
#main-sidebar.open { width: 272px; }

@media (max-width: 1023px) {
    #main-sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
        transform: translateX(-100%); width: 272px !important;
        transition: transform .25s cubic-bezier(.4,0,.2,1);
        box-shadow: var(--shadow-lg);
        /* MOBILE FIX: sidebar doit être scrollable */
        overflow-y: auto;
    }
    #main-sidebar.mobile-open { transform: translateX(0); }
}

.sidebar-header {
    padding: 13px 14px;
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    /* Sticky en mobile */
    position: sticky; top: 0; background: var(--c-surface); z-index: 1;
}
.sidebar-title {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--c-muted);
    display: flex; align-items: center; gap: 6px;
}
.sidebar-close {
    background: none; border: none; cursor: pointer;
    color: var(--c-muted); padding: 2px; display: none;
}
@media (max-width: 1023px) { .sidebar-close { display: flex; } }
#mapping-table-container { flex: 1; overflow-y: auto; }

/* ══════════════════════════════════════════
   MAPPING TABLE
══════════════════════════════════════════ */
.mapping-table { width: 100%; font-size: .77rem; border-collapse: collapse; }
.mapping-row td { padding: 7px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.mapping-row:hover td { background: var(--c-bg); }
.mapping-row td:first-child { font-weight: 500; color: var(--c-text); max-width: 108px; }
.mapping-row td:nth-child(2) { color: var(--c-muted); font-family: 'Geist Mono', monospace; font-size: .7rem; max-width: 85px; }
.editable-alias { cursor: text; border-radius: 4px; padding: 2px 4px; }
.editable-alias:hover { background: var(--c-bg); }
.editable-alias[contenteditable=true]:focus { outline: 2px solid var(--c-amber); background: white; border-radius: 4px; }
.remove-btn {
    background: none; border: none; cursor: pointer;
    opacity: 0.5; padding: 3px; border-radius: 6px;
    transition: all .15s; display: flex;
}
.remove-btn:hover { color: var(--c-error); background: #fef2f2; }
/* ── Section données service (dépliable) ── */
.service-data-section {
    border-top: 1px dashed var(--c-border, #e8e4de);
    margin-top: 4px;
}
.service-data-section summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; cursor: pointer;
    font-size: .66rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--c-subtle, #aaa);
    list-style: none; user-select: none;
}
.service-data-section summary::-webkit-details-marker { display: none; }
.service-data-section summary:hover { background: var(--c-bg, #faf9f7); }
.service-data-count {
    background: var(--c-border, #e8e4de); color: var(--c-muted, #7a726a);
    font-size: .62rem; font-weight: 700; padding: 1px 6px;
    border-radius: 99px;
}
.mapping-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 36px 20px; color: var(--c-subtle); text-align: center; gap: 8px;
}
.mapping-empty p { font-size: .77rem; }

/* ══════════════════════════════════════════
   MAIN CHAT
══════════════════════════════════════════ */
#main-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

#messages-list {
    flex: 1; overflow-y: auto; padding: 22px;
    display: flex; flex-direction: column; gap: 18px;
}

#empty-state {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; color: var(--c-muted);
}
.empty-logo { height: 44px; opacity: .2; }
.empty-title { font-size: .92rem; font-weight: 700; color: var(--c-muted); }
.empty-sub { font-size: .78rem; color: var(--c-subtle); text-align: center; line-height: 1.65; }

/* ══════════════════════════════════════════
   MESSAGES — DA Crème/Glass
══════════════════════════════════════════ */
.msg-user {
    display: flex; gap: 10px; justify-content: flex-end; align-items: flex-end;
}
.msg-user-bubble {
    max-width: 70%;
    background: linear-gradient(
        135deg,
        rgba(255, 248, 235, 0.92) 0%,
        rgba(254, 237, 210, 0.88) 100%
    );
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-bottom: 1px solid rgba(200, 129, 58, 0.2);
    color: var(--c-text);
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    padding: 12px 14px 10px;
    font-size: .875rem; line-height: 1.7;
    word-break: break-word;
    box-shadow:
        0 2px 8px rgba(200, 129, 58, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.msg-user-actions {
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid rgba(200,129,58,.15);
    display: flex; align-items: center; gap: 4px;
    justify-content: flex-end; flex-wrap: wrap;
}
.msg-action-btn {
    display: flex; align-items: center; gap: 4px;
    background: rgba(200,129,58,.08); border: none; border-radius: 7px;
    padding: 3px 7px; font-size: .68rem; font-weight: 500;
    color: var(--c-amber); cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.msg-action-btn:hover { background: rgba(200,129,58,.16); }
.msg-action-btn.active {
    background: rgba(200,129,58,.2);
    outline: 1px solid rgba(200,129,58,.3);
}
.msg-badge-anon {
    font-size: .66rem; color: var(--c-subtle);
    display: flex; align-items: center; gap: 3px; margin-right: auto;
}

/* ── EDIT MESSAGE BUTTON ── */
.msg-edit-btn {
    display: flex; align-items: center; gap: 4px;
    background: rgba(200,129,58,.08); border: none; border-radius: 7px;
    padding: 3px 7px; font-size: .68rem; font-weight: 500;
    color: var(--c-subtle); cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.msg-user:hover .msg-edit-btn { opacity: 1; }
.msg-edit-btn:hover { background: var(--c-bg); color: var(--c-text); opacity: 1; }

/* ── INLINE HERO-STYLE ANONYMIZED PREVIEW ── */
/* Le texte de la bulle en mode "view" swap mot à mot */
.msg-text-content {
    word-break: break-word;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Ancien preview inline (kept for compat) */
.msg-raw-preview {
    margin-top: 7px; padding: 8px 10px;
    background: rgba(200,129,58,.07);
    border: 1px solid rgba(200,129,58,.2);
    border-radius: 9px;
    font-family: 'Geist Mono', monospace;
    font-size: .73rem; color: var(--c-muted);
    white-space: pre-wrap; word-break: break-word;
    display: none;
}
.msg-raw-preview.visible { display: block; animation: fadeUp .2s ease; }

.msg-assistant { display: flex; gap: 10px; align-items: flex-start; }
.msg-ai-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--c-surface); border: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}
.msg-assistant-bubble {
    max-width: 70%;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    padding: 12px 14px 10px; font-size: .875rem;
    line-height: 1.7; color: var(--c-text);
    word-break: break-word; flex: 1;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.msg-assistant-bubble.is-error {
    background: #fef8f8; border-color: #fecaca; color: var(--c-error);
}
.msg-assistant-actions {
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--c-border);
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.msg-action-light {
    display: flex; align-items: center; gap: 4px;
    background: none; border: 1px solid var(--c-border);
    border-radius: 7px; padding: 3px 8px;
    font-size: .69rem; font-weight: 500; color: var(--c-muted);
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.msg-action-light:hover { background: var(--c-bg); color: var(--c-text); border-color: var(--c-border-2); }
.msg-action-light.amber:hover { background: var(--c-amber-l); color: var(--c-amber); border-color: var(--c-amber-m); }
.msg-latency {
    font-size: .66rem; color: var(--c-subtle);
    display: flex; align-items: center; gap: 3px; margin-left: auto;
}

/* Typing */
.typing-wrap { display: flex; align-items: center; gap: 5px; padding: 4px 0; }
.typing-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--c-border-2);
}
@keyframes typingBounce {
    0%,60%,100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-5px); opacity: 1; }
}
.typing-dot { animation: typingBounce 1.2s ease-in-out infinite; }
.typing-dot:nth-child(1) { animation-delay: 0s;   background: #93c5fd; }
.typing-dot:nth-child(2) { animation-delay: .18s; background: #6ee7b7; }
.typing-dot:nth-child(3) { animation-delay: .36s; background: #fcd34d; }

/* Paste area */
.paste-area {
    width: 100%; min-height: 75px; padding: 10px 12px;
    background: var(--c-bg); border: 1.5px dashed var(--c-border-2);
    border-radius: 10px; font-size: .8rem; color: var(--c-muted);
    font-family: inherit; resize: none; outline: none; transition: border .15s;
}
.paste-area:focus { border-color: var(--c-amber); background: white; }

/* Markdown */
.md-content h1,.md-content h2,.md-content h3 {
    font-weight: 700; margin: .7em 0 .3em; line-height: 1.3; color: var(--c-text);
}
.md-content h1 { font-size: 1.1rem; }
.md-content h2 { font-size: .98rem; }
.md-content h3 { font-size: .88rem; }
.md-content p  { margin: .3em 0; }
.md-content ul,.md-content ol { padding-left: 1.3em; margin: .35em 0; }
.md-content li { margin: .2em 0; }
.md-content strong { font-weight: 700; }
.md-content em { font-style: italic; }
.md-content code {
    font-family: 'Geist Mono', monospace; font-size: .8em;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: 5px; padding: 1px 5px; color: #c2410c;
}
.md-content pre {
    background: #1e1e1e; border-radius: 10px; padding: 13px 15px;
    overflow-x: auto; margin: .5em 0;
}
.md-content pre code {
    background: none; border: none; color: #d4d4d4; padding: 0;
    font-size: .8rem; line-height: 1.7;
}
.md-content table { width: 100%; border-collapse: collapse; font-size: .8rem; margin: .5em 0; }
.md-content th { background: var(--c-bg); font-weight: 700; text-align: left; padding: 6px 11px; border: 1px solid var(--c-border); }
.md-content td { padding: 6px 11px; border: 1px solid var(--c-border); }
.md-content blockquote { border-left: 3px solid var(--c-amber); padding-left: 12px; margin: .5em 0; color: var(--c-muted); font-style: italic; }
.md-content hr { border: none; border-top: 1px solid var(--c-border); margin: .7em 0; }

/* ══════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════ */
#input-area {
    background: rgba(255, 252, 248, 0.80);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-top: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.04),
        0 -1px 0 rgba(200, 129, 58, 0.06);
    flex-shrink: 0;
}
#prompt-ribbon {
    display: flex; gap: 6px; padding: 9px 18px;
    overflow-x: auto; border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
}
#prompt-ribbon:empty, #prompt-ribbon.hidden { display: none; }

.prompt-card {
    flex-shrink: 0; padding: 4px 11px; border-radius: 99px;
    border: 1px solid var(--c-border); background: var(--c-surface);
    font-size: .73rem; font-weight: 500; color: var(--c-muted);
    cursor: pointer; white-space: nowrap; transition: all .15s; font-family: inherit;
}
.prompt-card:hover { border-color: var(--c-amber); color: var(--c-amber); }
.prompt-card.selected { background: var(--c-amber-l); border-color: var(--c-amber-m); color: var(--c-amber); font-weight: 600; }

#input-inner {
    max-width: 840px; margin: 0 auto;
    padding: 12px 18px; display: flex; flex-direction: column; gap: 9px;
}
.input-meta {
    display: flex; align-items: center; justify-content: space-between;
}
.input-meta-label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-subtle); }
#entities-count {
    font-size: .66rem; font-weight: 600; color: var(--c-amber);
    background: var(--c-amber-l); border: 1px solid var(--c-amber-m);
    padding: 2px 7px; border-radius: 99px;
}

.input-row { display: flex; gap: 7px; align-items: flex-end; }

#rich-input {
    flex: 1; background: var(--c-bg); border: 1.5px solid var(--c-border);
    border-radius: var(--radius); padding: 11px 14px;
    font-size: .87rem; line-height: 1.65; color: var(--c-text);
    font-family: inherit; outline: none; min-height: 48px; max-height: 160px;
    overflow-y: auto; white-space: pre-wrap; word-break: break-word;
    transition: border .15s, box-shadow .15s;
}
#rich-input:focus { border-color: var(--c-amber); box-shadow: 0 0 0 3px rgba(200,129,58,.1); }
#rich-input:empty::before {
    content: attr(placeholder); color: var(--c-subtle); pointer-events: none; display: block;
}

@keyframes sendReady {
    0%, 100% { box-shadow: 0 0 0 0 rgba(200, 129, 58, 0); }
    50%       { box-shadow: 0 0 0 5px rgba(200, 129, 58, 0.12); }
}
#send-btn {
    flex-shrink: 0; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 13px; border: none;
    background: linear-gradient(135deg, #2a2520 0%, #4a3f35 100%);
    color: white; cursor: pointer;
    transition: all .2s cubic-bezier(0.34, 1.5, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
#send-btn:not(:disabled) {
    animation: sendReady 2.5s ease-in-out infinite;
}
#send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #4a3f35 0%, #c8813a 100%);
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 6px 20px rgba(200, 129, 58, 0.35);
    animation: none;
}
#send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.97);
}
#send-btn:disabled {
    background: var(--c-border-2);
    cursor: not-allowed;
    box-shadow: none;
    animation: none;
}

/* ── État loading du bouton ── */
#send-btn.is-loading {
    background: var(--c-amber);
    cursor: wait;
    pointer-events: none;
}
#send-btn.is-loading svg { display: none; }
#send-btn.is-loading::after {
    content: '';
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: white;
    border-radius: 50%;
    animation: sendSpin .7s linear infinite;
    display: block;
}
@keyframes sendSpin { to { transform: rotate(360deg); } }

/* ══ BOUTONS MODÈLE (toggle) — discrets, intégrés ══ */
.model-toggle-group {
    display: flex;
    align-items: center;
    gap: 4px;
}
.model-toggle-btn {
    display: flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    font-size: .63rem; font-weight: 500; color: var(--c-subtle);
    cursor: pointer; font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
    user-select: none;
    opacity: 0.6;
}
.model-toggle-btn:hover {
    border-color: var(--c-border);
    color: var(--c-muted);
    background: var(--c-bg);
    opacity: 1;
}
.model-toggle-btn.is-active {
    background: var(--c-amber-l) !important;
    border-color: var(--c-amber-m) !important;
    color: var(--c-amber) !important;
    opacity: 1 !important;
    font-weight: 600 !important;
}
.input-hint { font-size: .62rem; color: var(--c-subtle); text-align: right; }
kbd {
    display: inline-block; padding: 1px 4px; border: 1px solid var(--c-border-2);
    border-radius: 4px; font-size: .58rem; font-family: 'Geist Mono', monospace;
    background: var(--c-bg); color: var(--c-muted);
}

/* Word tokens */
@keyframes tokenAppear {
    0%   { opacity: 0; transform: scale(0.9) translateY(-2px); }
    70%  { transform: scale(1.05) translateY(0); }
    100% { opacity: 1; transform: scale(1); }
}
.word-token {
    display: inline;
    border-bottom: 2px solid currentColor;
    border-radius: 4px;
    padding: 1px 4px;
    margin: 0 1px;
    position: relative;
    line-height: 1.5;
    cursor: pointer;
    transition: all .18s cubic-bezier(0.34, 1.5, 0.64, 1);
    animation: tokenAppear 0.25s cubic-bezier(0.34, 1.5, 0.64, 1) forwards;
}
.word-token:hover {
    filter: brightness(.9) saturate(130%);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ══════════════════════════════════════════
   POPOVERS & MODALS
══════════════════════════════════════════ */
#category-popover {
    position: fixed; z-index: 9999;
    background: var(--c-surface); border: 1.5px solid var(--c-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    font-family: inherit; min-width: 255px; max-width: 95vw; overflow: hidden;
}

#toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--c-text); color: white;
    padding: 8px 15px; border-radius: 99px;
    font-size: .77rem; font-weight: 500;
    box-shadow: var(--shadow-md); z-index: 50; white-space: nowrap;
}

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.35);
    backdrop-filter: blur(4px); z-index: 50;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
/* CRITICAL : .hidden doit toujours masquer même si .modal-overlay force display:flex */
.hidden { display: none !important; }
.modal-box {
    background: var(--c-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 480px;
    max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--c-border);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 18px; border-bottom: 1px solid var(--c-border);
}
.modal-title { font-size: .88rem; font-weight: 700; }
.modal-close {
    width: 27px; height: 27px; border-radius: 8px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--c-muted); transition: all .15s;
}
.modal-close:hover { background: #fef2f2; color: var(--c-error); }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; }
.modal-textarea {
    width: 100%; min-height: 90px; padding: 10px 13px;
    background: var(--c-bg); border: 1.5px solid var(--c-border);
    border-radius: 10px; font-size: .82rem; font-family: inherit;
    color: var(--c-text); resize: none; outline: none;
}
.modal-textarea:focus { border-color: var(--c-amber); }
.modal-result {
    min-height: 75px; padding: 11px 13px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: 10px; font-size: .82rem; color: var(--c-text);
}
.modal-btn {
    padding: 8px 16px; border-radius: 10px; border: none;
    font-size: .81rem; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all .15s;
}
.modal-btn-primary { background: var(--c-text); color: white; }
.modal-btn-primary:hover { background: #4a3f35; }
.modal-btn-ghost { background: var(--c-bg); color: var(--c-muted); border: 1px solid var(--c-border); }
.modal-btn-ghost:hover { background: var(--c-border); color: var(--c-text); }

/* Correction toast */
#correction-toast {
    position: fixed; top: 65px; left: 50%; transform: translateX(-50%);
    background: var(--c-surface); border: 1.5px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 13px 15px; z-index: 60; width: 295px; max-width: 90vw;
    font-family: inherit;
}

/* ══════════════════════════════════════════
   LOGIN OVERLAY — MOBILE FIRST
══════════════════════════════════════════ */
.login-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: var(--c-bg);
    overflow-y: auto; /* MOBILE FIX: scrollable */
    -webkit-overflow-scrolling: touch;
}
.login-page {
    min-height: 100vh; display: grid;
    grid-template-columns: 1fr 1fr;
}
/* MOBILE: stack en colonne, panneau promo au-dessus du form */
@media (max-width: 768px) {
    .login-page {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        min-height: 100svh; /* small viewport height pour mobile */
    }
}

/* Panneau gauche : présentation produit */
.login-promo {
    background: var(--c-text);
    padding: 50px 48px;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
/* MOBILE: panneau promo réduit et scrollable */
@media (max-width: 768px) {
    .login-promo {
        padding: 32px 24px 28px;
        justify-content: flex-start;
        /* On le montre sur mobile mais compact */
    }
}
.login-promo::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 20% 80%, rgba(200,129,58,.18) 0%, transparent 60%);
    pointer-events: none;
}
.login-promo-content { position: relative; z-index: 1; max-width: 400px; }
@media (max-width: 768px) {
    .login-promo-content { max-width: 100%; }
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
@media (max-width: 768px) { .login-brand { margin-bottom: 18px; } }
.login-logo { height: 34px; object-fit: contain; }
.login-wordmark-promo { font-size: 1.5rem; font-weight: 900; color: white; letter-spacing: -.02em; }
.login-plus-promo { color: var(--c-amber); }

.login-headline {
    font-size: 2rem; font-weight: 800; color: white;
    line-height: 1.18; letter-spacing: -.03em; margin: 0 0 14px;
}
@media (max-width: 768px) { .login-headline { font-size: 1.5rem; margin-bottom: 10px; } }
.login-subhead { font-size: .87rem; color: rgba(255,255,255,.5); line-height: 1.7; margin-bottom: 28px; }
@media (max-width: 768px) { .login-subhead { margin-bottom: 18px; font-size: .82rem; } }

/* Animation hero */
.hero-demo-block {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px; padding: 16px 18px; margin-bottom: 22px;
}
@media (max-width: 768px) { .hero-demo-block { margin-bottom: 16px; } }
.hero-demo-label {
    font-size: .62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: rgba(255,255,255,.3); margin-bottom: 10px;
}
#hero-animation-text {
    font-size: .84rem; line-height: 1.75; color: rgba(255,255,255,.75);
    font-family: 'Geist Mono', monospace;
}
.hero-token {
    display: inline; border-radius: 4px;
    padding: 1px 4px; font-weight: 600;
    transition: all .3s ease;
}
.hero-token.original {
    background: rgba(220,80,80,.2); color: #fca5a5;
    border-bottom: 2px solid rgba(220,80,80,.4);
}
.hero-token.anonymized {
    background: rgba(200,129,58,.25); color: #fcd34d;
    border-bottom: 2px solid rgba(200,129,58,.4);
}
.hero-token.swapping {
    opacity: 0; transform: translateY(-3px);
}

/* Features list — cachée sur mobile pour gagner de la place */
.login-features {
    list-style: none; padding: 0; margin: 0 0 28px;
    display: flex; flex-direction: column; gap: 14px;
}
@media (max-width: 768px) { .login-features { display: none; } }
.login-feature { display: flex; gap: 12px; align-items: flex-start; }
.login-feature-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c-amber); flex-shrink: 0; margin-top: 7px; }
.login-feature strong { display: block; font-size: .82rem; font-weight: 600; color: white; margin-bottom: 2px; }
.login-feature span { font-size: .77rem; color: rgba(255,255,255,.42); line-height: 1.55; }

.login-cta-block { padding-top: 24px; border-top: 1px solid rgba(255,255,255,.08); }
.login-cta-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: rgba(255,255,255,.3); margin-bottom: 6px; }
.login-cta-email {
    display: inline-block; font-size: .86rem; font-weight: 600; color: var(--c-amber);
    text-decoration: none; border-bottom: 1px solid rgba(200,129,58,.3); transition: border-color .15s;
}
.login-cta-email:hover { border-color: var(--c-amber); }
@media (max-width: 768px) { .login-cta-block { padding-top: 18px; } }

/* Formulaire de connexion */
.login-form-col {
    display: flex; align-items: center; justify-content: center;
    padding: 50px 36px; background: var(--c-surface);
}
@media (max-width: 768px) {
    .login-form-col {
        padding: 32px 24px 48px;
        align-items: flex-start;
    }
}
.login-form-inner { width: 100%; max-width: 340px; }

.login-form-title { font-size: 1.5rem; font-weight: 800; color: var(--c-text); letter-spacing: -.025em; margin: 0 0 7px; }
.login-form-sub { font-size: .81rem; color: var(--c-muted); margin-bottom: 28px; line-height: 1.6; }

.login-error {
    background: #fef2f2; border: 1px solid #fecaca; color: var(--c-error);
    padding: 9px 13px; border-radius: 9px; font-size: .79rem;
    margin-bottom: 16px; font-weight: 500;
}

.login-field-wrap { margin-bottom: 13px; }
.login-label { display: block; font-size: .71rem; font-weight: 600; color: var(--c-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.login-input {
    width: 100%; padding: 12px 15px; border-radius: 11px;
    border: 1.5px solid var(--c-border); background: var(--c-bg);
    font-size: .93rem; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; font-family: 'Geist Mono', monospace;
    color: var(--c-text); outline: none; transition: border .15s, box-shadow .15s;
}
.login-input:focus { border-color: var(--c-amber); box-shadow: 0 0 0 3px rgba(200,129,58,.1); background: white; }
.login-input::placeholder { color: var(--c-subtle); font-weight: 400; letter-spacing: .04em; text-transform: none; }

.login-btn {
    width: 100%; padding: 13px; border-radius: 11px; border: none;
    background: var(--c-text); color: white;
    font-size: .88rem; font-weight: 700; cursor: pointer;
    font-family: inherit; display: flex; align-items: center;
    justify-content: center; gap: 8px; transition: all .15s; margin-bottom: 18px;
}
.login-btn:hover:not(:disabled) { background: #4a3f35; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.login-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }
@keyframes loginSpin { to { transform: rotate(360deg); } }

.login-switch-note { font-size: .76rem; color: var(--c-subtle); text-align: center; }
.login-switch-link { color: var(--c-amber); font-weight: 600; text-decoration: none; }
.login-switch-link:hover { text-decoration: underline; }

/* ══════════════════════════════════════════
   CONFIRM CLEAR — style doux crème
══════════════════════════════════════════ */
.confirm-box {
    background: var(--c-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 360px;
    padding: 28px 24px; border: 1px solid var(--c-border);
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0;
}
.confirm-icon {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--c-amber-l); border: 2px solid var(--c-amber-m);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; margin-bottom: 16px;
}
.confirm-title { font-size: 1rem; font-weight: 800; margin-bottom: 10px; color: var(--c-text); }
.confirm-body { font-size: .8rem; color: var(--c-muted); line-height: 1.65; margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 10px; width: 100%; }
.confirm-btn-cancel {
    flex: 1; padding: 10px; border-radius: 10px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    color: var(--c-muted); font-size: .82rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.confirm-btn-cancel:hover { background: var(--c-border); color: var(--c-text); }
.confirm-btn-confirm {
    flex: 1; padding: 10px; border-radius: 10px;
    background: #7c3434; border: none;
    color: white; font-size: .82rem; font-weight: 700;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.confirm-btn-confirm:hover { background: #6b2c2c; }

/* ══════════════════════════════════════════
   MOBILE BACKDROP
══════════════════════════════════════════ */
#mobile-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 30; backdrop-filter: blur(2px);
    opacity: 0; transition: opacity .25s;
}
#mobile-backdrop.visible { opacity: 1; }

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */
@keyframes bubblePop {
    0%   { opacity: 0; transform: scale(0.94) translateY(10px); }
    60%  { transform: scale(1.02) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
.fade-up { animation: bubblePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

/* ══ GHOST DÉCORATIF — CSS pur, zéro JS ══ */
#ghost-container { pointer-events: none; }

#ghost-element {
    position: fixed;
    pointer-events: none;
    user-select: none;
    bottom: 90px;
    right: 24px;
    z-index: 0;
    animation: nodeIdle 10s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(200, 129, 58, 0.35);
}

@keyframes nodeIdle {
    0%   { opacity: 0;    transform: translateY(0px)   scale(1); }
    15%  { opacity: 0.15; transform: translateY(-5px)  scale(1.4); }
    50%  { opacity: 0.10; transform: translateY(-11px) scale(1.0); }
    85%  { opacity: 0.15; transform: translateY(-5px)  scale(1.4); }
    100% { opacity: 0;    transform: translateY(0px)   scale(1); }
}

/* ══ AMÉLIORATIONS UX — Animations messages ══ */

/* ── Entrée des bulles : rebond organique ── */
@keyframes bubbleFromRight {
    0%   { opacity: 0; transform: translateX(18px) translateY(6px) scale(0.96); }
    55%  { transform: translateX(-3px) translateY(-1px) scale(1.008); }
    100% { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}
@keyframes bubbleFromLeft {
    0%   { opacity: 0; transform: translateX(-18px) translateY(6px) scale(0.96); }
    55%  { transform: translateX(3px) translateY(-1px) scale(1.008); }
    100% { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}

.msg-user  { animation: bubbleFromRight 0.45s cubic-bezier(0.34, 1.5, 0.64, 1) forwards; }
.msg-assistant { animation: bubbleFromLeft  0.45s cubic-bezier(0.34, 1.5, 0.64, 1) forwards; }

/* Remplacement de .fade-up générique */
.fade-up { animation: bubbleFromLeft 0.45s cubic-bezier(0.34, 1.5, 0.64, 1) forwards; }

/* Hover sur les bulles */
.msg-user-bubble {
    transition: box-shadow .25s ease, transform .25s ease;
}
.msg-user-bubble:hover {
    box-shadow:
        0 8px 28px rgba(200, 129, 58, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transform: translateY(-2px);
}
.msg-assistant-bubble {
    transition: box-shadow .25s ease, transform .25s ease;
}
.msg-assistant-bubble:hover {
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.09),
        0 3px 10px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

/* Actions : apparaissent au hover avec slide */
.msg-user-actions,
.msg-assistant-actions {
    transition: opacity .25s ease, transform .25s ease;
}
.msg-user:not(:hover) .msg-user-actions {
    opacity: 0.5;
    transform: translateY(2px);
}
.msg-user:hover .msg-user-actions {
    opacity: 1;
    transform: translateY(0);
}
.msg-assistant:not(:hover) .msg-assistant-actions {
    opacity: 0.5;
    transform: translateY(2px);
}
.msg-assistant:hover .msg-assistant-actions {
    opacity: 1;
    transform: translateY(0);
}

/* Typing dots : respiration colorée */
@keyframes typingPulse {
    0%, 60%, 100% { transform: translateY(0) scale(1);    opacity: 0.4; }
    30%            { transform: translateY(-6px) scale(1.2); opacity: 1; }
}
.typing-dot { animation: typingPulse 1.3s ease-in-out infinite; }
.typing-dot:nth-child(1) { background: #fca5a5; animation-delay: 0s;    }
.typing-dot:nth-child(2) { background: #6ee7b7; animation-delay: 0.2s;  }
.typing-dot:nth-child(3) { background: #fde68a; animation-delay: 0.4s;  }

/* Scroll smooth */
#messages-list { scroll-behavior: smooth; }

/* Focus rich-input */
#rich-input:focus { background: rgba(255, 255, 255, 0.95); }

/* ══════════════════════════════════════════
   RESPONSIVE MOBILE GÉNÉRAL
══════════════════════════════════════════ */
@media (max-width: 640px) {
    #messages-list { padding: 14px; gap: 14px; }
    .msg-user-bubble, .msg-assistant-bubble { max-width: 90%; }
    #input-inner { padding: 10px 12px; gap: 7px; }
    .input-hint { display: none; }
    .header-btn span { display: none; }
    /* Sur mobile, les bulles prennent plus de place */
    .msg-user-bubble { max-width: 95%; }
    .msg-assistant-bubble { max-width: 100%; }
}

/* ══ ÉDITION INLINE — rich-input intégré ══ */
.inline-edit-wrap {
    width: 100%;
    display: flex; flex-direction: column; gap: 8px;
    padding: 2px 0 4px;
}

/* Zone contenteditable — même look que rich-input */
.inline-rich-input {
    min-height: 60px;
    max-height: 260px;
    overflow-y: auto;
    padding: 10px 13px;
    background: white;
    border: 1.5px solid var(--c-amber);
    border-radius: 10px;
    font-size: .875rem;
    line-height: 1.7;
    font-family: inherit;
    color: var(--c-text);
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 0 0 3px rgba(200,129,58,.1);
    transition: border-color .15s, box-shadow .15s;
    cursor: text;
}
.inline-rich-input:focus {
    border-color: var(--c-amber);
    box-shadow: 0 0 0 4px rgba(200,129,58,.15);
}
.inline-rich-input:empty::before {
    content: 'Modifiez le texte…';
    color: var(--c-subtle);
    pointer-events: none;
    display: block;
}

/* Barre du bas */
.inline-edit-footer {
    display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: 6px;
}
.inline-edit-hint {
    font-size: .67rem; color: var(--c-subtle); font-style: italic;
}
.inline-edit-cancel-btn {
    padding: 4px 11px; border-radius: 8px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    color: var(--c-muted); font-size: .73rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.inline-edit-cancel-btn:hover { background: var(--c-border); color: var(--c-text); }
.inline-edit-confirm-btn {
    padding: 4px 13px; border-radius: 8px;
    background: var(--c-text); border: none;
    color: white; font-size: .73rem; font-weight: 700;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.inline-edit-confirm-btn:hover { background: #4a3f35; }

/* ══ MODAL ÉDITION ══ */
#edit-message-modal { z-index: 9500; }
#edit-message-modal .modal-box { max-width: 560px; }
.edit-modal-original { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 10px; padding: 10px 13px; font-size: .8rem; color: var(--c-muted); white-space: pre-wrap; word-break: break-word; line-height: 1.6; max-height: 100px; overflow-y: auto; }
.edit-modal-textarea { width: 100%; min-height: 110px; max-height: 280px; padding: 11px 14px; background: var(--c-bg); border: 1.5px solid var(--c-border); border-radius: var(--radius); font-size: .87rem; line-height: 1.65; font-family: inherit; color: var(--c-text); resize: vertical; outline: none; transition: border .15s, box-shadow .15s; }
.edit-modal-textarea:focus { border-color: var(--c-amber); box-shadow: 0 0 0 3px rgba(200,129,58,.1); background: white; }
.edit-modal-warning { font-size: .74rem; color: #7c4b1a; background: var(--c-amber-l); border: 1px solid var(--c-amber-m); border-radius: 9px; padding: 8px 12px; line-height: 1.6; }
.edit-modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--c-border); }

/* ══ MODAL PARAMÈTRES ══ */
#settings-modal { z-index: 9500; }
#settings-modal .modal-box { max-width: 620px; }
.settings-section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--c-border); }
.settings-section:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.settings-section-title { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--c-muted); margin-bottom: 12px; }
.settings-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.settings-stat { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 10px; padding: 10px 12px; text-align: center; }
.settings-stat-value { font-size: 1.05rem; font-weight: 800; color: var(--c-text); font-family: 'Geist Mono', monospace; display: block; }
.settings-stat-label { font-size: .63rem; color: var(--c-muted); margin-top: 2px; display: block; }
.settings-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.settings-table th { text-align: left; padding: 7px 10px; font-size: .63rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); border-bottom: 2px solid var(--c-border); background: var(--c-bg); }
.settings-table td { padding: 7px 10px; border-bottom: 1px solid var(--c-border); color: var(--c-text); }
.settings-table td.mono { font-family: 'Geist Mono', monospace; font-size: .75rem; }
.settings-table tr:last-child td { border-bottom: none; }
.settings-table tr:hover td { background: var(--c-bg); }
.settings-table-wrap { border: 1px solid var(--c-border); border-radius: 10px; overflow: hidden; overflow-x: auto; }
.settings-empty { text-align: center; padding: 20px; color: var(--c-subtle); font-size: .8rem; font-style: italic; }
.settings-contact-link { display: inline-flex; align-items: center; gap: 6px; color: var(--c-amber); font-weight: 600; text-decoration: none; font-size: .82rem; }
.settings-contact-link:hover { text-decoration: underline; }

/* ══ formulaire settings ══ */
.settings-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}
.settings-field { display: flex; flex-direction: column; gap: 5px; }
.settings-field-full { grid-column: 1 / -1; }
.settings-label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--c-muted);
}
.settings-input {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--c-border); border-radius: 9px;
    background: var(--c-bg); font-size: .83rem; font-family: inherit;
    color: var(--c-text); outline: none; transition: border .15s, box-shadow .15s;
}
.settings-input:focus {
    border-color: var(--c-amber);
    box-shadow: 0 0 0 3px rgba(200,129,58,.1);
    background: white;
}
.settings-textarea {
    width: 100%; min-height: 80px; padding: 9px 12px;
    border: 1.5px solid var(--c-border); border-radius: 9px;
    background: var(--c-bg); font-size: .83rem; font-family: inherit;
    color: var(--c-text); outline: none; resize: vertical;
    transition: border .15s, box-shadow .15s;
}
.settings-textarea:focus {
    border-color: var(--c-amber);
    box-shadow: 0 0 0 3px rgba(200,129,58,.1);
    background: white;
}
@media (max-width: 540px) {
    .settings-form-grid { grid-template-columns: 1fr; }
}
/* ══ SÉLECTEUR DE MODÈLE IA ══ */
#model-selector-wrap { display: flex; align-items: center; }

.model-selector-btn {
    display: flex; align-items: center; gap: 5px;
    background: var(--c-bg); border: 1px solid var(--c-border);
    border-radius: 99px; padding: 3px 10px;
    font-size: .68rem; font-weight: 600; color: var(--c-muted);
    cursor: pointer; font-family: inherit; transition: all .15s;
    white-space: nowrap;
}
.model-selector-btn:hover { border-color: var(--c-amber); color: var(--c-amber); background: var(--c-amber-l); }

.model-dropdown {
    animation: fadeUp .15s cubic-bezier(.16,1,.3,1) forwards;
}
.model-option-btn {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    width: 100%; padding: 8px 11px; border-radius: 8px;
    border: none; background: transparent; cursor: pointer;
    font-family: inherit; text-align: left; transition: background .12s;
    gap: 8px;
}
.model-option-btn:hover { background: var(--c-bg); }
.model-option-btn.active { background: var(--c-amber-l); }
.model-option-label { font-size: .78rem; font-weight: 700; color: var(--c-text); }
.model-option-desc { font-size: .67rem; color: var(--c-muted); }
.model-option-check { font-size: .8rem; color: var(--c-amber); font-weight: 800; }

/* ══════════════════════════════════════════
   MODE SOMBRE
══════════════════════════════════════════ */
body.dark-mode {
    --c-bg:      #0f172a;
    --c-surface: #1e293b;
    --c-border:  #334155;
    --c-border-2:#475569;
    --c-text:    #f1f5f9;
    --c-muted:   #94a3b8;
    --c-subtle:  #64748b;
    --c-amber-l: #1c1205;
    --c-amber-m: #2d1f0a;

    background-color: #0c1220;
}

body.dark-mode header {
    background: rgba(12, 18, 32, 0.80);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
body.dark-mode .msg-user-bubble {
    background: linear-gradient(135deg,
        rgba(40, 25, 8, 0.92) 0%,
        rgba(55, 35, 12, 0.88) 100%);
    border-color: rgba(200, 129, 58, 0.2);
}
body.dark-mode .msg-assistant-bubble {
    background: rgba(30, 41, 59, 0.75);
    border-color: rgba(255, 255, 255, 0.08);
}
body.dark-mode #rich-input {
    background: rgba(30, 41, 59, 0.8);
    color: #f1f5f9;
    border-color: #334155;
}
body.dark-mode #input-area {
    background: rgba(12, 18, 32, 0.85);
    border-top-color: rgba(255, 255, 255, 0.06);
}
body.dark-mode header {
    background: rgba(15,23,42,0.95);
}
body.dark-mode .msg-user-bubble {
    background: linear-gradient(135deg, #1c1205 0%, #251808 100%);
    border-color: #2d1f0a;
}
body.dark-mode .msg-assistant-bubble {
    background: #1e293b;
    border-color: #334155;
}
body.dark-mode #rich-input {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}
body.dark-mode #input-area {
    background: rgba(15,23,42,0.97);
}
body.dark-mode .login-form-col {
    background: #1e293b;
}