/* ══════════════════════════════════════════
   SWAPI FREE — free.css
   Design inspiré Premium, palette bleue
   ══════════════════════════════════════════ */

/* ══════════════════════════════════════════
   VARIABLES & BASE
══════════════════════════════════════════ */
:root {
    --c-bg:        #f7f9fc;
    --c-surface:   #ffffff;
    --c-border:    #e2e8f0;
    --c-border-2:  #cbd5e1;
    --c-text:      #1e293b;
    --c-muted:     #64748b;
    --c-subtle:    #94a3b8;

    /* Bleu brand */
    --c-brand:     #0284c7;
    --c-brand-d:   #0369a1;
    --c-brand-l:   #f0f9ff;
    --c-brand-m:   #bae6fd;

    /* Amber pour les CTA premium */
    --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', 'Inter', ui-sans-serif, system-ui, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   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,255,255,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    flex-shrink: 0; z-index: 20;
    box-shadow: var(--shadow);
}
.header-left  { display: flex; align-items: center; gap: 10px; }
.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-free {
    font-size: 8px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--c-brand);
    background: var(--c-brand-l); border: 1px solid var(--c-brand-m);
    padding: 2px 6px; border-radius: 99px;
}

/* Bouton toggle sidebar PC */
#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-brand);
    background: var(--c-brand-l); border: 1px solid var(--c-brand-m);
    padding: 3px 9px; border-radius: 99px;
}

/* Bouton CTA Premium dans le header */
.header-premium-cta {
    display: flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; border: none;
    padding: 5px 12px; border-radius: 9px;
    font-size: .73rem; font-weight: 700; cursor: pointer;
    font-family: inherit; text-decoration: none;
    transition: all .15s; box-shadow: 0 2px 8px rgba(217,119,6,.3);
}
.header-premium-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(217,119,6,.4);
}

.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; }
}

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

/* ══════════════════════════════════════════
   SIDEBAR (identique Premium, palette bleue)
══════════════════════════════════════════ */
#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); 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; 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; }

/* ── CTA Premium dans la sidebar ── */
.sidebar-premium-cta {
    margin: 12px 12px 0;
    padding: 11px 13px;
    background: var(--c-amber-l);
    border: 1px solid var(--c-amber-m);
    border-radius: 11px;
    display: flex; flex-direction: column; gap: 6px;
}
.sidebar-premium-cta-title {
    font-size: .72rem; font-weight: 700; color: var(--c-amber);
    display: flex; align-items: center; gap: 5px;
}
.sidebar-premium-cta-text {
    font-size: .69rem; color: #7c4b1a; line-height: 1.55;
}
.sidebar-premium-cta-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; border: none; border-radius: 8px;
    padding: 6px 12px; font-size: .71rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
    text-decoration: none; transition: all .15s;
    box-shadow: 0 2px 6px rgba(217,119,6,.25);
    margin-top: 2px;
}
.sidebar-premium-cta-btn:hover { transform: translateY(-1px); }

/* ══════════════════════════════════════════
   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); cursor: pointer; }
.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-brand); 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; opacity: 1; }

.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 — style identique Premium (bleu)
══════════════════════════════════════════ */
/* Bulle utilisateur : ton bleu clair */
.msg-user { display: flex; gap: 10px; justify-content: flex-end; align-items: flex-end; }
.msg-user-bubble {
    max-width: 70%;
    background: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 100%);
    border: 1px solid #bae6fd;
    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: var(--shadow);
}
.msg-user-actions {
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid rgba(2,132,199,.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(2,132,199,.08); border: none; border-radius: 7px;
    padding: 3px 7px; font-size: .68rem; font-weight: 500;
    color: var(--c-brand); cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.msg-action-btn:hover { background: rgba(2,132,199,.16); }
.msg-action-btn.active { background: rgba(2,132,199,.2); outline: 1px solid rgba(2,132,199,.3); }
.msg-badge-anon {
    font-size: .66rem; color: var(--c-subtle);
    display: flex; align-items: center; gap: 3px; margin-right: auto;
}

.msg-text-content { word-break: break-word; line-height: 1.6; white-space: pre-wrap; }

/* Bulle assistant */
.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: var(--c-surface);
    border: 1px solid var(--c-border);
    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: var(--shadow);
}
.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-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-brand); background: white; }

/* Markdown */
.md-content h1,.md-content h2,.md-content h3 { font-weight: 700; margin: .7em 0 .3em; line-height: 1.3; }
.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: #0369a1;
}
.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-brand); 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,255,255,0.95);
    border-top: 1px solid var(--c-border);
    flex-shrink: 0;
}

/* Prompt ribbon */
#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-brand); color: var(--c-brand); }
.prompt-card.selected { background: var(--c-brand-l); border-color: var(--c-brand-m); color: var(--c-brand); font-weight: 600; }

/* Prompt premium grisé */
.prompt-card.premium-locked {
    opacity: .5; cursor: pointer;
    border-style: dashed;
}
.prompt-card.premium-locked:hover {
    border-color: var(--c-amber);
    color: var(--c-amber);
    opacity: .85;
    border-style: dashed;
}

#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-brand);
    background: var(--c-brand-l); border: 1px solid var(--c-brand-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-brand); box-shadow: 0 0 0 3px rgba(2,132,199,.1); }
#rich-input:empty::before { content: attr(placeholder); color: var(--c-subtle); pointer-events: none; display: block; }

#send-btn {
    flex-shrink: 0; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; border: none;
    background: var(--c-brand); color: white; cursor: pointer; transition: all .15s;
}
#send-btn:hover:not(:disabled) { background: var(--c-brand-d); transform: translateY(-1px); box-shadow: var(--shadow-md); }
#send-btn:disabled { background: var(--c-border-2); cursor: not-allowed; }

.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
══════════════════════════════════════════ */
.word-token {
    display: inline;
    border-bottom: 2.5px solid currentColor;
    border-radius: 2px; padding: 0 2px;
    position: relative; line-height: 1.4;
    cursor: pointer; transition: background .15s;
}
.word-token:hover { filter: brightness(.92); }

/* ══════════════════════════════════════════
   CATEGORY POPOVER
══════════════════════════════════════════ */
#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
══════════════════════════════════════════ */
#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;
}

/* ══════════════════════════════════════════
   MODALS
══════════════════════════════════════════ */
.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;
}
.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-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-brand); color: white; }
.modal-btn-primary:hover { background: var(--c-brand-d); }
.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); }

/* Modal "Paramètres" version Free (upsell) */
.upsell-modal-box {
    background: var(--c-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 440px;
    border: 1px solid var(--c-border); overflow: hidden;
}
.upsell-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 22px 22px 18px;
    position: relative; overflow: hidden;
}
.upsell-header::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 80% 20%, rgba(200,129,58,.2) 0%, transparent 60%);
}
.upsell-header-content { position: relative; z-index: 1; }
.upsell-logo { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.upsell-logo-text { font-size: 1.1rem; font-weight: 900; color: white; letter-spacing: -.02em; }
.upsell-logo-plus { color: #f59e0b; }
.upsell-tagline { font-size: .82rem; color: rgba(255,255,255,.55); line-height: 1.6; }

.upsell-features { padding: 14px 22px 10px; display: flex; flex-direction: column; gap: 8px; }
.upsell-feature {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 11px; border-radius: 10px;
    background: var(--c-bg); border: 1px solid var(--c-border);
}
.upsell-feature-icon {
    width: 28px; height: 28px; border-radius: 7px;
    background: var(--c-amber-l); border: 1px solid var(--c-amber-m);
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; flex-shrink: 0;
}
.upsell-feature-title { font-size: .78rem; font-weight: 700; color: var(--c-text); margin-bottom: 2px; }
.upsell-feature-desc { font-size: .7rem; color: var(--c-muted); line-height: 1.5; }
.upsell-feature-icon {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--c-amber-l); border: 1px solid var(--c-amber-m);
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem; flex-shrink: 0;
}
.upsell-feature-title { font-size: .8rem; font-weight: 700; color: var(--c-text); margin-bottom: 2px; }
.upsell-feature-desc { font-size: .72rem; color: var(--c-muted); line-height: 1.55; }

.upsell-footer {
    padding: 14px 22px 20px;
    border-top: 1px solid var(--c-border);
    display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.upsell-cta-btn {
    width: 100%; padding: 12px; border-radius: 11px; border: none;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white; font-size: .88rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    text-decoration: none; transition: all .15s;
    box-shadow: 0 3px 12px rgba(217,119,6,.3);
}
.upsell-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(217,119,6,.4); }
.upsell-cta-note { font-size: .69rem; color: var(--c-subtle); }

/* Modal prompt premium */
.prompt-upsell-box {
    background: var(--c-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 360px;
    border: 1px solid var(--c-border); overflow: hidden;
    padding: 24px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center;
}
.prompt-upsell-icon { font-size: 2rem; }
.prompt-upsell-title { font-size: .95rem; font-weight: 800; color: var(--c-text); }
.prompt-upsell-desc { font-size: .78rem; color: var(--c-muted); line-height: 1.65; }

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

/* ══════════════════════════════════════════
   CONFIRM CLEAR
══════════════════════════════════════════ */
.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;
}
.confirm-icon {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--c-brand-l); border: 2px solid var(--c-brand-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; }
.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); }
.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; }
.animate-pop-in { animation: fadeUp .12s cubic-bezier(.16,1,.3,1) forwards; }

/* Ghost */
#ghost-element {
    position: absolute;
    pointer-events: none;
    transition: opacity 1.5s ease, left 4s ease, top 4s ease;
    animation: nodeFloat 9s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.4);
}
@keyframes nodeFloat {
    0%, 100% { transform: translateY(0) scale(1);    opacity: 0; }
    20%       { opacity: 0.18; }
    50%       { transform: translateY(-14px) scale(1.3); opacity: 0.12; }
    80%       { opacity: 0.18; }
}

/* ══════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════ */
@media (max-width: 640px) {
    #messages-list { padding: 14px; gap: 14px; }
    .msg-user-bubble, .msg-assistant-bubble { max-width: 92%; }
    #input-inner { padding: 10px 12px; gap: 7px; }
    .input-hint { display: none; }
    .header-btn span { display: none; }
}

/* ══════════════════════════════════════════
   DECODE MODAL
══════════════════════════════════════════ */
.decode-textarea {
    width: 100%; min-height: 100px; max-height: 220px; 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: vertical; outline: none; transition: border .15s;
    overflow-y: auto;
}
.decode-textarea:focus { border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(2,132,199,.08); }
.decode-result {
    min-height: 60px; max-height: 240px; overflow-y: auto; padding: 11px 13px;
    background: var(--c-brand-l); border: 1px solid var(--c-brand-m);
    border-radius: 10px; font-size: .82rem; color: var(--c-text);
    line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}

/* ══════════════════════════════════════════
   BUBBLE SWAP (FREE — MÊME STYLE QUE PREMIUM)
══════════════════════════════════════════ */
.BSWAP-ALIAS {
    FONT-FAMILY: 'GEIST MONO', MONOSPACE;
    FONT-SIZE: 0.88EM; FONT-WEIGHT: 600;
    PADDING: 1PX 5PX; BORDER-RADIUS: 4PX;
    DISPLAY: INLINE; BOX-SHADOW: 0 1PX 2PX RGBA(0,0,0,.05);
}

/* ══════════════════════════════════════════
   SERVICE DATA SECTION
══════════════════════════════════════════ */
.service-data-section { border-top: 1px dashed var(--c-border); 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);
    list-style: none; user-select: none;
}
.service-data-section summary::-webkit-details-marker { display: none; }
.service-data-section summary:hover { background: var(--c-bg); }
.service-data-count {
    background: var(--c-border); color: var(--c-muted);
    font-size: .62rem; font-weight: 700; padding: 1px 6px; border-radius: 99px;
}

/* ══════════════════════════════════════════
   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-brand-l:  #0c2a3d;
    --c-brand-m:  #164e63;

    background-image:
        radial-gradient(at 0% 0%, hsla(210,50%,8%,1) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(220,50%,10%,1) 0, transparent 50%);
}
body.dark-mode header {
    background: rgba(15,23,42,0.95);
}
body.dark-mode .msg-user-bubble {
    background: linear-gradient(135deg, #0c2a3d 0%, #0c3151 100%);
    border-color: #164e63;
}
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);
}