/* =========================================================
   myLLM — Design system inspiré ChatGPT
   ========================================================= */

:root {
    --bg:          #212121;
    --bg-sidebar:  #171717;
    --bg-surface:  #2f2f2f;
    --bg-input:    #2f2f2f;
    --accent:      #10a37f;
    --accent-dark: #0d8a6b;
    --accent-dark: color-mix(in srgb, var(--accent) 82%, black);
    --text:        #ececec;
    --text-muted:  #8e8ea0;
    --border:      #3d3d3d;
    --radius:      12px;
    --radius-sm:   8px;
    --font:        'Söhne', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --viewer-width: min(680px, 48vw);
}

/* Light theme */
[data-theme="light"] {
    --bg:          #f5f5f5;
    --bg-sidebar:  #e8e8e8;
    --bg-surface:  #ffffff;
    --bg-input:    #ffffff;
    --text:        #1a1a1a;
    --text-muted:  #6b7280;
    --border:      #d1d5db;
    --bg-base:     #f5f5f5;
}
[data-theme="light"] .message-user .msg-body { background: #e8f4ef; }
[data-theme="light"] .msg-content pre        { background: #f0f0f0; border-color: #d1d5db; }
[data-theme="light"] .modal-box              { background: #ffffff; }
[data-theme="light"] .llm-picker-list        { background: #ffffff; border-color: #d1d5db; }
[data-theme="light"] .conv-item:hover        { background: rgba(0,0,0,.06); }
[data-theme="light"] .conv-item.active       { background: rgba(0,0,0,.1); }

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

/* ---- LAYOUT APP ---- */
body.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px 12px;
}

.sidebar-new-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(100% - 24px);
    margin: 0 12px 8px;
    padding: 8px 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity .15s;
    flex-shrink: 0;
}
.sidebar-new-btn:hover { opacity: .88; }

.sidebar-logo-wrap {
    position: relative;
    width: 70px;
    height: 70px;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    display: block;
}

.sidebar-logo-hover {
    position: absolute;
    inset: 0;
    width: 70px;
    height: 70px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    opacity: 0;
    pointer-events: none;
}

.sidebar-logo-wrap.has-hover-logo:hover .sidebar-logo { opacity: 0; }
.sidebar-logo-wrap.has-hover-logo:hover .sidebar-logo-hover { opacity: 1; }

.logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    letter-spacing: -0.3px;
}

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

.logo-tagline {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 13.5px;
    transition: background .15s;
    position: relative;
    cursor: pointer;
}
.conv-item:hover { background: var(--bg-surface); }
.conv-item.active { background: var(--bg-surface); }

.conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-color-bar {
    display: inline-block;
    width: 3px;
    height: 28px;
    border-radius: 2px;
    background: var(--conv-color, var(--accent));
    flex-shrink: 0;
    align-self: center;
}

.conv-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0;
    transition: opacity .15s;
}
.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: #ef4444; }

/* ---- Indicateur de génération en arrière-plan ---- */
.conv-item.conv-streaming .conv-title::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: 7px;
    vertical-align: middle;
    animation: conv-pulse 1.2s ease-in-out infinite;
}
@keyframes conv-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.3; transform: scale(0.7); }
}

/* ---- Spinner inline (chargement SPA) ---- */
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toasts de notification ---- */
.toast {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #fff;
    background: #374151;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s, transform .25s;
    max-width: 320px;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-error   { background: #ef4444; }

.conv-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--bg-surface); color: var(--text); }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s;
}
.btn-logout:hover { color: #ef4444; }

/* =========================================================
   CHAT MAIN
   ========================================================= */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-right .25s ease, box-shadow .2s ease;
    overflow: hidden;
    position: relative;
}

.chat-main::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid rgba(var(--profile-accent-rgb), 0.92);
    box-shadow: inset 0 0 28px rgba(var(--profile-accent-rgb), 0.16);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
    z-index: 20;
}

.chat-main.profile-accent-active::after {
    opacity: 1;
}

/* Toolbar */
.chat-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg);
}

.toolbar-selectors {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.toolbar-model-logo-wrap {
    width: 92px;
    min-width: 92px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    overflow: hidden;
}

.toolbar-model-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 8px;
}

.profile-lock-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
}

.profile-lock-avatar {
    width: 100px;
    height: 100px;
    border-radius: 10%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}

.profile-lock-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.profile-lock-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-lock-title-row h2 {
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.profile-lock-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.profile-lock-content p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
}

.profile-lock-llm {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
}

.profile-lock-llm code {
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 11px;
}

/* Colonne verticale des sélecteurs à droite de l'avatar */
.toolbar-selectors-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
    width: 100%;
}

/* Ligne couleur + sélecteur de profil */
.toolbar-profile-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.toolbar-row-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}
.toolbar-profile-row .selector {
    flex: 1;
    min-width: 180px;
    width: 100%;
}
.toolbar-profile-empty {
    margin: 0;
    font-size: 11px;
    color: var(--text-muted);
}
.toolbar-disclaimer {
    margin: 0;
    font-size: 11px;
    color: var(--text-muted);
}
.toolbar-meta-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.3;
}
.toolbar-meta-chip strong {
    color: var(--text-primary);
    font-weight: 600;
}
.toolbar-meta-model {
    min-width: 0;
    max-width: min(460px, 100%);
}
#topActiveModelLabel {
    display: inline-block;
    min-width: 0;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.toolbar-meta-cost {
    color: #f59e0b;
    letter-spacing: -0.5px;
    font-weight: 700;
}

.selector {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
}
.selector:focus { border-color: var(--accent); }

/* LLM Picker */
.llm-picker { position: relative; }
.llm-picker-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s;
}
.llm-picker-btn:hover { border-color: var(--accent); }
.llm-icon { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.llm-picker-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    list-style: none;
    margin: 0;
}
.llm-inline-picker .llm-picker-btn {
    padding: 3px 8px;
    font-size: 12px;
    gap: 5px;
}
.llm-inline-picker .llm-picker-btn span {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.llm-inline-picker .llm-picker-list {
    top: auto;
    bottom: calc(100% + 6px);
    max-width: min(92vw, 420px);
    max-height: 280px;
    overflow-y: auto;
}
.llm-picker-list-header {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
    pointer-events: none;
}
.llm-picker-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: background .1s;
}
.llm-picker-item:hover { background: var(--bg-hover); }
.llm-picker-item.active { background: var(--bg-active); }
.llm-picker-item-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.llm-cost-stars {
    font-size: 10px;
    color: #f59e0b;
    margin-left: auto;
    letter-spacing: -1px;
    flex-shrink: 0;
}
.llm-cost-legend {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--text-muted);
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    scroll-behavior: smooth;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    text-align: center;
    padding: 40px;
}

.welcome-icon { margin-bottom: 12px; }

.chat-welcome h2 {
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 24px;
}

/* Bouton "Conversation standard" */
.welcome-start-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, background .15s;
}
.welcome-start-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.welcome-start-btn > svg:first-child { color: var(--accent); flex-shrink: 0; }
.welcome-start-btn div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.welcome-start-btn strong { font-size: 14px; }
.welcome-start-btn span { font-size: 12px; color: var(--text-muted); }
.welcome-arrow { color: var(--text-muted); flex-shrink: 0; }

/* Label séparateur */
.welcome-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin: 20px 0 10px;
    align-self: flex-start;
    width: 100%;
    max-width: 480px;
}

.welcome-empty-note {
    width: 100%;
    max-width: 480px;
    margin: 0;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-surface) 85%, transparent);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

/* Grille profils */
.welcome-profiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 480px;
}
.welcome-profiles form { display: contents; }

.welcome-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, background .15s;
    border-left: 3px solid var(--profile-color, var(--border));
}
.welcome-profile-card:hover { border-color: var(--profile-color, var(--accent)); background: color-mix(in srgb, var(--accent) 6%, transparent); }

.welcome-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.welcome-profile-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.welcome-profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.welcome-profile-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.welcome-profile-info span   { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ancien .welcome-actions conservé pour compat */
.welcome-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    max-width: 700px;
    width: 100%;
    margin-top: 12px;
}

.welcome-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text);
}
.welcome-card:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.welcome-card strong { font-size: 13.5px; }
.welcome-card span { font-size: 12px; color: var(--text-muted); }

/* Message bubbles */
.message {
    display: flex;
    gap: 16px;
    padding: 12px 40px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.message-user {
    flex-direction: row-reverse;
}

.message-user .msg-body {
    align-items: flex-end;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}

.assistant-avatar {
    background: transparent;
    width: 50px;
    height: 50px;
}
.user-avatar-icon {
    background: var(--accent);
    color: white;
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.message-user .msg-body {
    max-width: 70%;
    flex: 0 1 auto;
}

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

.message-user .msg-content {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 10px 14px;
}

.msg-image-wrap {
    margin-bottom: 6px;
}
.msg-image {
    max-width: 320px;
    max-height: 240px;
    border-radius: var(--radius-sm);
    display: block;
    object-fit: contain;
    border: 1px solid var(--border);
}
.msg-image-generated .msg-image {
    max-width: min(480px, 100%);
    max-height: 480px;
}
.msg-image-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.msg-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
}

/* Images générées dans les messages */
.md-render img {
    max-width: min(100%, 480px);
    border-radius: 10px;
    display: block;
    margin-top: 8px;
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: opacity .2s;
}
.md-render img:hover { opacity: .92; }

/* Streaming cursor */
.msg-content.streaming::after {
    content: '▌';
    animation: blink .7s steps(1) infinite;
    color: var(--accent);
}

@keyframes blink { 50% { opacity: 0; } }

/* Indicateur de phase pendant le streaming */
.stream-phase {
    display: none;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}
.msg-content.streaming .stream-phase { display: inline-flex; }
.stream-phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    animation: stream-phase-pulse 1.2s ease-in-out infinite;
}
@keyframes stream-phase-pulse {
    0%, 100% { opacity: .3; transform: scale(1); }
    50%      { opacity: 1;  transform: scale(1.35); }
}

/* Message action buttons */
.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity .15s;
}
.message:hover .msg-actions { opacity: 1; }
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.msg-action-btn:hover { background: var(--bg-surface); color: var(--text); }
.msg-action-btn.copied { color: var(--accent); }

/* Markdown content */
.msg-content { white-space: normal; }
.message-user .msg-content { white-space: pre-wrap; }

.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
    margin: 1em 0 .4em;
    line-height: 1.3;
    font-weight: 600;
}
.msg-content h1 { font-size: 1.4em; }
.msg-content h2 { font-size: 1.2em; }
.msg-content h3 { font-size: 1.05em; }
.msg-content p { margin: .6em 0; }
.msg-content p:first-child { margin-top: 0; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul, .msg-content ol {
    padding-left: 1.5em;
    margin: .5em 0;
}
.msg-content li { margin: .2em 0; }
.msg-content li > ul, .msg-content li > ol { margin: .2em 0; }
.msg-content blockquote {
    border-left: 3px solid var(--accent);
    margin: .6em 0;
    padding: .4em .8em;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    border-radius: 0 6px 6px 0;
}
.msg-content a { color: var(--accent); text-decoration: underline; }
.msg-content a.citation-link {
    text-decoration: none;
    margin-left: 1px;
}
.msg-content a.citation-link sup {
    font-size: 0.72em;
    line-height: 0;
    vertical-align: super;
    font-weight: 600;
}
.msg-content a.citation-link:hover,
.msg-content a.citation-link:focus-visible {
    text-decoration: underline;
}
.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.msg-content strong { font-weight: 600; }
.msg-content em { font-style: italic; }
.msg-content table {
    border-collapse: collapse;
    width: 100%;
    margin: .8em 0;
    font-size: 13px;
}
.msg-content th, .msg-content td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}
.msg-content th { background: var(--bg-surface); font-weight: 600; }
.msg-content tr:nth-child(even) td { background: rgba(255,255,255,.02); }

/* Code blocks */
.msg-content code {
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: .88em;
    background: var(--bg-surface);
    border-radius: 4px;
    padding: 2px 5px;
    color: #e2b714;
}
.msg-content pre {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: .8em 0;
    overflow-x: auto;
    position: relative;
}
.msg-content pre code {
    background: none;
    padding: 14px 16px;
    display: block;
    color: #e2e8f0;
    font-size: .85em;
    line-height: 1.6;
    border-radius: 0;
}
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #111;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 11px;
    color: var(--text-muted);
}
.btn-copy-code {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background .1s, color .1s;
    display: flex; align-items: center; gap: 4px;
}
.btn-copy-code:hover { background: var(--bg-surface); color: var(--text); }
.btn-copy-code.copied { color: var(--accent); }

/* =========================================================
   INPUT
   ========================================================= */
.chat-input-wrap {
    padding: 16px 24px 12px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chat-input-form {
    width: 100%;
    max-width: 760px;
}

.conversation-credits-note {
    width: 100%;
    max-width: 760px;
    margin: 0;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1.3;
    color: #f59e0b;
    text-align: left;
}
.conversation-credits-note strong {
    font-size: 14px;
    color: #f59e0b;
}

.input-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color .15s;
}
.input-box:focus-within { border-color: var(--accent); }

.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.file-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#removeFile {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
#removeFile:hover { color: #ef4444; }

.msg-textarea {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    resize: none;
    outline: none;
    width: 100%;
    min-height: 2.1em; /* +30% environ par rapport a la hauteur de base */
    max-height: 260px;
    overflow-y: auto;
    line-height: 1.6;
}

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

.input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-actions-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Toggle Internet */
.web-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: color .15s, border-color .15s, background .15s;
    user-select: none;
}
.web-toggle input { display: none; }
.web-toggle:has(input:checked) {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.web-toggle:hover { color: var(--text); }
.web-toggle.disabled,
.img-gen-toggle.disabled {
    opacity: .35;
    cursor: not-allowed;
    pointer-events: none;
}
.web-toggle.active {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.img-tool-item:hover,
.tool-picker-item:hover {
    background: var(--bg-hover, rgba(255,255,255,.06));
}
.tool-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-picker-item-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tool-cost-stars {
    margin-left: auto;
    flex-shrink: 0;
}
.tool-picker-item.is-disabled {
    opacity: .45;
    color: var(--text-muted);
    cursor: not-allowed !important;
}
.tool-picker-item.is-disabled:hover {
    background: transparent;
}

/* =========================================================
   MSG HTML CARD
   ========================================================= */
.msg-html-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.msg-html-card-icon { color: var(--accent); flex-shrink: 0; }
.msg-html-card-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 80px; }
.msg-html-card-name { font-size: 13px; font-weight: 500; }
.msg-html-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.msg-video-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.msg-video-card-icon { color: #f87171; flex-shrink: 0; }
.msg-video-card-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 80px; }
.msg-video-card-name { font-size: 13px; font-weight: 500; }
.msg-video-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* =========================================================
   HTML VIEWER PANEL
   ========================================================= */
.html-viewer {
    position: fixed;
    top: 0; right: 0;
    width: var(--viewer-width);
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 400;
    display: none;
    flex-direction: column;
    box-shadow: -6px 0 28px rgba(0, 0, 0, .35);
    isolation: isolate;
    contain: layout paint style;
    overscroll-behavior: contain;
}
.html-viewer.open { display: flex; }
.viewer-open .chat-main { margin-right: var(--viewer-width); }

.html-viewer-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 46px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.html-viewer-title {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.html-viewer-tabs {
    display: flex;
    gap: 3px;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 2px;
}
.html-viewer-tab {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    border: none;
    display: inline-flex;
    align-items: center;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.html-viewer-tab.active {
    background: var(--bg-card);
    color: var(--text);
}

.html-viewer-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.html-viewer-btn:hover { background: var(--bg-hover, rgba(255,255,255,.07)); color: var(--text); }

.html-viewer-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 13px;
}
.html-viewer-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.html-viewer-code {
    flex: 1;
    overflow: auto;
    padding: 14px;
    background: var(--bg-input);
}
.html-viewer-code pre {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
    line-height: 1.55;
}

.html-viewer-iframe {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    display: block;
    border: none;
    background: #fff;
}

@media (max-width: 768px) {
    .html-viewer.open { width: 100%; }
    .video-viewer.open { width: 100%; }
    .sources-viewer.open { width: 100%; }
    .viewer-open .chat-main { margin-right: 0; }
}

/* =========================================================
   VIDEO VIEWER PANEL
   ========================================================= */
.video-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--viewer-width);
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 400;
    display: none;
    flex-direction: column;
    box-shadow: -6px 0 28px rgba(0, 0, 0, .35);
    isolation: isolate;
    contain: layout paint style;
    overscroll-behavior: contain;
}
.video-viewer.open { display: flex; }

.video-viewer-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 46px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.video-viewer-title {
    font-size: 13px;
    font-weight: 600;
}
.video-viewer-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.video-viewer-btn:hover { background: var(--bg-hover, rgba(255,255,255,.07)); color: var(--text); }

.video-viewer-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px;
    text-align: center;
}
.video-viewer-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: #f87171;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.video-viewer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
    gap: 10px;
}
.video-viewer-player {
    width: 100%;
    height: 100%;
    min-height: 220px;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.video-viewer-meta {
    color: var(--text-muted);
    font-size: 12px;
}

/* =========================================================
   SOURCES VIEWER PANEL (SONAR PRO)
   ========================================================= */
.sources-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--viewer-width);
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 400;
    display: none;
    flex-direction: column;
    box-shadow: -6px 0 28px rgba(0, 0, 0, .35);
    isolation: isolate;
    contain: layout paint style;
    overscroll-behavior: contain;
}
.sources-viewer.open { display: flex; }

.sources-viewer-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 46px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.sources-viewer-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.sources-viewer-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 7px;
    line-height: 1.2;
}
.sources-viewer-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, opacity .15s;
}
.sources-viewer-btn:hover { background: var(--bg-hover, rgba(255,255,255,.07)); color: var(--text); }
.sources-viewer-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.sources-viewer-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.sources-viewer-list {
    flex: 1;
    overflow: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sources-viewer-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.sources-viewer-item:hover {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.sources-viewer-item.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-input));
}
.sources-viewer-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sources-viewer-index {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    min-width: 24px;
}
.sources-viewer-domain {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sources-viewer-url {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: rgba(255,255,255,.06); }

.btn-send {
    background: var(--accent);
    border: none;
    color: white;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.btn-send:hover:not(:disabled) { background: var(--accent-dark); }
.btn-send:disabled { background: var(--bg-surface); color: var(--text-muted); cursor: not-allowed; }

.input-disclaimer {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Footer discret en bas du chat */
.chat-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 4px 16px 6px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg);
    opacity: 0.7;
    letter-spacing: 0.2px;
}
.chat-footer-link {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-footer-link:hover {
    color: var(--text);
}

/* ---- Page à propos ---- */
body.about-page {
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--bg);
    color: var(--text);
    overflow: auto;
}
.about-wrap {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 28px 14px 32px;
}
.about-card {
    background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
}
.about-top {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}
.about-logo {
    width: 136px;
    height: 136px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.about-kicker {
    color: var(--accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    margin-bottom: 4px;
}
.about-lead {
    color: var(--text-muted);
    margin-top: 6px;
}
.about-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.about-block {
    background: color-mix(in srgb, var(--bg) 45%, transparent);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}
.about-block h2 {
    font-size: 16px;
    margin-bottom: 8px;
}
.about-list {
    margin: 0;
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 14px;
}
.about-link {
    color: var(--accent);
    word-break: break-word;
}
.about-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

/* ---- Indicateurs de capacités LLM ---- */
.llm-info-bar,
.llm-caps-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 3px 0;
    min-height: 20px;
}
.llm-info-bar { padding: 5px 4px 2px; }

.llm-cap {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: .01em;
}
.llm-cap-ok { color: var(--accent); }
.llm-cap-no { color: #ef4444; }

/* =========================================================
   MODAL
   ========================================================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-box {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 400px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* Modale "Session expirée" — affichée quand une requête AJAX / SSE rencontre un 401 */
.session-expired-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    animation: session-expired-fade-in .18s ease-out;
}
.session-expired-box {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 22px;
    width: min(92vw, 380px);
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
.session-expired-box h2 {
    margin: 0 0 8px;
    font-size: 16px;
}
.session-expired-box p {
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}
.session-expired-box .session-expired-btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
}
@keyframes session-expired-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box-compact {
    width: min(92vw, 380px);
    gap: 12px;
}

.modal-box h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-box label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.modal-subtitle {
    margin: -8px 0 2px;
    font-size: 13px;
    color: var(--text-muted);
}

.new-chat-form-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.new-chat-divider {
    position: relative;
    text-align: center;
    margin: 2px 0;
}
.new-chat-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px solid var(--border);
}
.new-chat-divider span {
    position: relative;
    z-index: 1;
    padding: 0 8px;
    background: var(--bg-sidebar);
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.w-full { width: 100%; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}
.app-info-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}
.app-info-list {
    margin: 0 0 2px 18px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.app-info-list li {
    line-height: 1.5;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-danger {
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,.4);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-danger:hover {
    background: rgba(239,68,68,.2);
    border-color: rgba(239,68,68,.55);
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 40px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 380px;
    max-width: 90vw;
}

.login-logo { margin-bottom: 4px; }

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.btn-google {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: white;
    color: #1f1f1f;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow .15s;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}
.btn-google:hover { box-shadow: 0 2px 12px rgba(0,0,0,.3); }

.login-divider {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* =========================================================
   ADMIN
   ========================================================= */
body.admin-page {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Overlay sidebar mobile admin */
.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
}
.admin-overlay.active { display: block; }

/* Header mobile admin (caché sur desktop) */
.admin-mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}
.admin-burger {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
}
.admin-burger:hover { color: var(--text); background: var(--bg-surface); }

.admin-sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
}

.admin-sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.admin-sidebar .logo-text {
    padding: 0;
    border: 0;
    margin: 0;
    display: block;
}

.admin-nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
}

.admin-sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    background: var(--bg-sidebar);
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.admin-nav-link:hover, .admin-nav-link.active {
    background: var(--bg-surface);
    color: var(--text);
}

.admin-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

body.admin-page .admin-content > * {
    max-width: 100%;
    min-width: 0;
}

body.admin-page .admin-content a,
body.admin-page .admin-content code {
    overflow-wrap: anywhere;
}

body.admin-page .admin-content img,
body.admin-page .admin-content video,
body.admin-page .admin-content canvas,
body.admin-page .admin-content iframe {
    max-width: 100%;
    height: auto;
}

.admin-content h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
body.admin-page .card { box-shadow: 0 6px 20px rgba(0,0,0,.14); }
[data-theme="light"] body.admin-page .card { box-shadow: 0 4px 14px rgba(15,23,42,.06); }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: calc(var(--radius) - 2px);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(61,61,61,.5);
    vertical-align: middle;
}
body.admin-page td { word-break: break-word; }

tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.badge-green  { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-yellow { background: rgba(234,179,8,.15);  color: #ca8a04; }
.badge-red    { background: rgba(239,68,68,.15);  color: #ef4444; }
.badge-gray   { background: rgba(100,100,100,.2); color: var(--text-muted); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    width: 100%;
}
.alert-error   { background: rgba(239,68,68,.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }

/* Error pages */
body.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.error-box { text-align: center; }
.error-box h1 { font-size: 80px; font-weight: 700; color: var(--text-muted); }
.error-box p { color: var(--text-muted); margin: 8px 0 20px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =========================================================
   RESPONSIVE — MOBILE
   ========================================================= */

/* Fix 100vh iOS (barre d'adresse dynamique) */
body.app {
    height: 100dvh;
}

/* Header mobile — caché sur desktop */
.mobile-header {
    display: none;
}
.mobile-header-title {
    font-size: 15px;
    font-weight: 600;
}

/* Hamburger — caché sur desktop */
.btn-sidebar-toggle {
    display: none;
}

/* Bouton logo (à gauche) dans le mobile-header */
.btn-sidebar-logo {
    display: none; /* affiché uniquement dans le @media mobile */
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .2s;
}
.btn-sidebar-logo:hover { opacity: .7; }

.mobile-header-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

/* Overlay sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {

    /* Sidebar en drawer overlay */
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 280px;
        min-width: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.5);
    }

    /* Le chat prend toute la largeur */
    .chat-main { width: 100%; }

    /* Header mobile : logo + nom de l'app */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
        background: var(--bg-base);
        flex-shrink: 0;
    }

    /* Bouton-logo visible sur mobile */
    .btn-sidebar-logo {
        display: flex;
    }

    /* Bouton hamburger visible dans la toolbar */
    .btn-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 6px;
        border-radius: 6px;
        flex-shrink: 0;
    }
    .btn-sidebar-toggle:hover { background: var(--bg-surface); }

    /* Sur mobile, le header global (logo à gauche, burger à droite) reste visible. */
    #mobileHeader {
        display: flex;
    }

    /* Le burger de la toolbar n'est plus utilisé en mobile. */
    .chat-toolbar .btn-sidebar-toggle {
        display: none;
    }

    /* Toolbar : selectors empilés */
    .chat-toolbar { padding: 4px 10px; }
    .toolbar-selectors { flex-wrap: wrap; gap: 4px; }
    .toolbar-selectors-stack { gap: 3px; }
    .toolbar-disclaimer { display: none; }
    .llm-picker-btn { font-size: 12px; }
    .toolbar-profile-row .selector { min-width: 0; }
    #profileSelect { font-size: 12px; }
    .profile-lock-header {
        gap: 10px;
        padding: 8px 10px;
        align-items: flex-start;
    }
    .profile-lock-avatar {
        width: 100px;
        height: 100px;
    }
    .profile-lock-title-row h2 { font-size: 17px; }
    .profile-lock-content p { font-size: 12px; }
    .profile-lock-llm { font-size: 11px; gap: 8px; }

    /* Messages */
    .message { padding: 10px 12px; gap: 10px; }
    .message-user .msg-body { max-width: 85%; }
    .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
    .msg-avatar.assistant-avatar { width: 50px; height: 50px; }
    .msg-image { max-width: 100%; }

    /* Input */
    .chat-input-wrap { padding: 8px 10px 10px; }
    .conversation-credits-note { max-width: 100%; font-size: 11px; padding-inline: 2px; }
    .conversation-credits-note strong { font-size: 13px; }
    .msg-textarea {
        font-size: 16px; /* Empêche le zoom iOS */
        min-height: 2.8em;
        max-height: 320px;
    }
    .input-actions { gap: 8px; align-items: flex-end; }
    .input-actions-left { flex-wrap: wrap; row-gap: 6px; column-gap: 6px; }
    #webToggleLabel { display: none; }
    .llm-inline-picker .llm-picker-btn { max-width: 190px; }
    .llm-inline-picker .llm-picker-btn span { max-width: 120px; }
    .llm-inline-picker .llm-picker-list {
        left: auto;
        right: 0;
        max-width: min(94vw, 360px);
    }
    .toolbar-meta-bar { gap: 6px; }
    .toolbar-meta-chip { font-size: 10px; padding: 2px 7px; }
    #topActiveModelLabel { max-width: 150px; }
    .toolbar-model-logo-wrap { width: 70px; min-width: 70px; }
    .toolbar-model-logo { padding: 6px; }

    /* Welcome */
    .chat-welcome { padding: 24px 16px; }
    .chat-welcome h2 { font-size: 20px; }
    .welcome-actions { grid-template-columns: 1fr 1fr; }
    .welcome-profiles { grid-template-columns: 1fr; max-width: 100%; }
    .welcome-section-label, .welcome-start-btn { max-width: 100%; }
    .llm-file-hint, .llm-info-bar, .input-disclaimer { display: none; }

    /* Admin — sidebar drawer */
    .admin-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: min(86vw, 320px);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow: hidden;
        height: 100dvh;
        padding: max(16px, env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom));
    }
    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.5);
    }

    /* Admin layout — colonne sur mobile (sidebar hors flux) */
    body.admin-page {
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }
    .admin-mobile-header {
        display: flex;
        padding: 12px 14px;
        backdrop-filter: blur(8px);
    }
    .admin-mobile-header > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .admin-content {
        padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    body.admin-page .admin-content > *,
    body.admin-page .admin-content .card,
    body.admin-page .admin-content form,
    body.admin-page .admin-content table,
    body.admin-page .admin-content .table-wrap {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .admin-content h1 {
        font-size: 18px;
        line-height: 1.3;
        margin-bottom: 14px;
    }
    body.admin-page .card {
        padding: 14px;
        border-radius: 10px;
    }

    /* Formulaires admin: colonnes -> pile verticale */
    body.admin-page .admin-content form div[style*="display:grid"][style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    body.admin-page .admin-content form div[style*="display:flex"][style*="align-items:flex-end"] {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
    }
    body.admin-page .admin-content form .form-group {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    body.admin-page .admin-content form [style*="min-width"] {
        min-width: 0 !important;
    }
    body.admin-page .admin-content input,
    body.admin-page .admin-content select,
    body.admin-page .admin-content textarea {
        max-width: 100%;
        min-width: 0 !important;
    }
    body.admin-page .admin-content .card > form .btn-primary,
    body.admin-page .admin-content .card > form .btn-secondary,
    body.admin-page .admin-content .card > form .btn-danger {
        width: 100%;
        justify-content: center;
    }

    /* Tableaux scrollables dans les cards */
    body.admin-page .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.admin-page .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.admin-page .admin-content .table-wrap > table,
    body.admin-page .admin-content .card > table,
    body.admin-page .admin-content .card > div > table {
        min-width: 100%;
        table-layout: auto;
    }
    body.admin-page .admin-content th {
        padding: 8px 10px;
        font-size: 12px;
        white-space: normal;
    }
    body.admin-page .admin-content td {
        padding: 8px 10px;
        font-size: 12px;
        vertical-align: top;
        overflow-wrap: anywhere;
    }
    body.admin-page .admin-content .card > div[style*="display:flex"] { flex-wrap: wrap; }

    /* Admin users table: cartes lisibles sur mobile */
    .users-table thead {
        display: none;
    }
    .users-table tbody {
        display: block;
    }
    .users-table tbody tr {
        display: block;
        margin-bottom: 10px;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: color-mix(in srgb, var(--bg-surface) 75%, transparent);
    }
    .users-table tbody tr:last-child {
        margin-bottom: 0;
    }
    .users-table td {
        display: grid;
        grid-template-columns: minmax(84px, 38%) 1fr;
        gap: 8px;
        align-items: start;
        padding: 7px 0 !important;
        border-bottom: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
        min-width: 0 !important;
    }
    .users-table td:last-child {
        border-bottom: none;
        padding-bottom: 0 !important;
    }
    .users-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .02em;
        line-height: 1.35;
        padding-top: 2px;
    }
    .users-table td > * {
        min-width: 0;
    }
    .users-table td[data-label="Actions"] > div,
    .users-table td[data-label="Actions"] form {
        width: 100%;
    }
    .users-table td[data-label="Actions"] form[style*="display:flex"] {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .users-table td[data-label="Actions"] button,
    .users-table td[data-label="Actions"] select,
    .users-table td[data-label="Actions"] input[type="number"] {
        width: 100%;
    }
    .users-table td[data-label="Actions"] div[style*="align-items:center"] {
        flex-direction: column;
        align-items: stretch !important;
        gap: 6px !important;
    }
    .users-table td[data-label="Actions"] span[style*="k créd/mois"] {
        font-size: 11px !important;
        text-align: left;
    }
    .users-table .badge {
        width: fit-content;
        max-width: 100%;
    }

    /* Admin profiles table: cartes lisibles sur mobile (même principe que users-table) */
    .profiles-table thead {
        display: none;
    }
    .profiles-table tbody {
        display: block;
    }
    .profiles-table tbody tr {
        display: block;
        margin-bottom: 10px;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: color-mix(in srgb, var(--bg-surface) 75%, transparent);
    }
    .profiles-table tbody tr:last-child {
        margin-bottom: 0;
    }
    .profiles-table td {
        display: grid;
        grid-template-columns: minmax(72px, 32%) 1fr;
        gap: 8px;
        align-items: start;
        padding: 7px 0 !important;
        border-bottom: 1px dashed color-mix(in srgb, var(--border) 70%, transparent);
        min-width: 0 !important;
    }
    .profiles-table td:last-child {
        border-bottom: none;
        padding-bottom: 0 !important;
    }
    .profiles-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .02em;
        line-height: 1.35;
        padding-top: 2px;
    }
    .profiles-table td > * {
        min-width: 0;
    }
    .profiles-table td[data-label="Nom"] > div {
        flex-wrap: wrap;
    }
    .profiles-table td[data-label="Nom"] strong {
        overflow-wrap: anywhere;
    }
    .profiles-table td[data-label="Actions"] .btn-edit-profile {
        width: 100%;
    }
    .profiles-table .badge {
        width: fit-content;
        max-width: 100%;
    }

    /* Assistants : modale édition — documents de référence */
    #mpDocumentsList > div {
        flex-wrap: wrap;
    }
    #mpDocumentsList > div > div:first-child {
        flex: 1 1 100%;
    }
    #mpDocumentsList > div > button {
        width: 100%;
    }
    #uploadProfileDocForm {
        flex-direction: column;
        align-items: stretch !important;
    }
    #uploadProfileDocForm .btn-primary {
        width: 100%;
    }

    /* Admin — tests page */
    .test-card table { min-width: 100%; }
    #llm-pie { width: 160px; height: 160px; }
    .usage-tab {
        flex: 1;
        text-align: center;
    }
    .admin-nav-link {
        padding: 11px 12px;
        font-size: 14px;
    }
    .admin-mobile-header a {
        display: inline-flex;
        align-items: center;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 4px 8px;
        background: var(--bg-surface);
    }

    /* Dashboard + blocs KPI */
    body.admin-page .admin-content div[style*="grid-template-columns:repeat(auto-fit"] {
        gap: 10px !important;
    }
    body.admin-page .admin-content div[style*="font-size:32px"],
    body.admin-page .admin-content div[style*="font-size:28px"] {
        font-size: 24px !important;
        line-height: 1.2;
    }

    /* Usage (donut + légende) */
    body.admin-page .card:has(#llm-pie) {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 14px !important;
    }
    #llm-legend {
        width: 100%;
        gap: 6px !important;
    }
    #llm-legend > div {
        flex-wrap: wrap;
        row-gap: 2px;
    }

    /* Tests LLM */
    body.admin-page .admin-content div[style*="justify-content:space-between"]:has(#runAllBtn) {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
        margin-bottom: 16px !important;
    }
    #runAllBtn {
        width: 100%;
        justify-content: center;
    }
    #globalScore {
        display: inline-block;
        min-height: 18px;
    }

    /* Logs */
    body.admin-page .card > div[style*="font-family:monospace"] {
        font-size: 11px !important;
        line-height: 1.55 !important;
        padding: 12px !important;
    }

    /* Profils */
    .avatar-picker {
        gap: 10px 8px;
    }
    .avatar-img-wrap {
        width: 64px;
        height: 64px;
    }
    .avatar-none-symbol {
        line-height: 64px;
    }
    .avatar-label {
        max-width: 66px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .profile-admin-avatar {
        width: 80px;
        height: 40px;
    }

    /* Modal */
    body.admin-page .modal {
        padding: 12px;
        align-items: flex-end;
    }
    body.admin-page .modal-box {
        padding: 20px 16px;
        width: min(100%, 720px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    body.admin-page .modal-actions {
        display: flex;
        flex-direction: column-reverse;
    }
    body.admin-page .modal-actions .btn-primary,
    body.admin-page .modal-actions .btn-secondary,
    body.admin-page .modal-actions .btn-danger {
        width: 100%;
        justify-content: center;
    }
    body.admin-page .card > div[style*="max-height:700px"] {
        max-height: min(58dvh, 520px) !important;
    }

    /* Markdown : code blocks scrollables */
    .msg-content pre { max-width: calc(100vw - 80px); }
}

@media (max-width: 420px) {
    body.admin-page .admin-mobile-header {
        gap: 8px;
        padding: 10px 10px;
    }
    body.admin-page .admin-mobile-header > span {
        font-size: 14px !important;
    }
    body.admin-page .admin-content {
        padding: 10px 8px calc(14px + env(safe-area-inset-bottom));
    }
    body.admin-page .admin-content h1 {
        font-size: 17px;
    }
    body.admin-page .admin-content .card,
    body.admin-page .modal-box {
        padding: 12px;
    }
    body.admin-page .admin-content .table-wrap > table,
    body.admin-page .admin-content .card > table,
    body.admin-page .admin-content .card > div > table,
    body.admin-page .test-card table {
        min-width: 100%;
    }
    body.admin-page .admin-content .btn-primary,
    body.admin-page .admin-content .btn-secondary,
    body.admin-page .admin-content .btn-danger,
    body.admin-page .admin-content .btn-test,
    body.admin-page .admin-content .btn-activate,
    body.admin-page .admin-content .btn-deactivate {
        min-height: 38px;
    }
}

@media (max-width: 900px) {
    .about-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Avatar picker (admin profiles) ---- */
.admin-collapse {
    margin: 0;
}

.admin-collapse summary {
    list-style: none;
}

.admin-collapse summary::-webkit-details-marker {
    display: none;
}

.admin-collapse-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.admin-collapse-caret {
    display: inline-block;
    transition: transform .2s;
}

.admin-collapse[open] .admin-collapse-caret {
    transform: rotate(90deg);
}

.admin-collapse-content {
    margin-top: 16px;
}

.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.avatar-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
}
.avatar-opt input[type=radio] { display: none; }
.avatar-img-wrap {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: 2px solid var(--border);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
    background: var(--bg-surface);
}
.avatar-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.avatar-opt input[type=radio]:checked + .avatar-img-wrap {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.avatar-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
}

.avatar-delete-btn {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.2);
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

.avatar-delete-btn:hover {
    background: #dc2626;
}

.avatar-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.avatar-library-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: var(--bg-base);
    text-align: center;
}

.avatar-library-image-wrap {
    position: relative;
    width: 90px;
    margin: 0 auto 8px;
}

.avatar-library-image {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.avatar-library-name {
    font-size: 11px;
    font-weight: 600;
    word-break: break-word;
}

.avatar-library-meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.avatar-library-system {
    margin-top: 4px;
    font-size: 10px;
    color: var(--accent);
    font-weight: 600;
}

.avatar-none-symbol {
    font-size: 27px;
    line-height: 78px;
    display: block;
    text-align: center;
    color: var(--text-muted);
}

.modal-box-profile-edit {
    width: min(780px, 95vw);
    max-width: 780px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.profile-admin-avatar {
    width: 80px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.profile-admin-color-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,.15);
}

/* ---- File chips (multi-fichiers) ---- */
.file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 2px;
}
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 8px 3px 5px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 180px;
}
.file-chip-loading { opacity: .6; }
.chip-thumb {
    width: 20px; height: 20px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}
.chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.chip-remove {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px; line-height: 1;
    padding: 0; flex-shrink: 0;
    transition: color .15s;
}
.chip-remove:hover { color: #ef4444; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip-spinner {
    display: inline-block;
    width: 10px; height: 10px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex-shrink: 0;
}

/* ---- Drag & Drop ---- */
.input-box.drag-over {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--bg-surface));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* ---- Hint compatibilité LLM ---- */
.llm-file-hint {
    font-size: 12px;
    color: #92400e;
    background: rgba(245,158,11,.1);
    border: 1px solid rgba(245,158,11,.3);
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 4px;
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}
[data-theme="dark"] .llm-file-hint { color: #fcd34d; }

/* Quota EUR (sidebar chat) */

/* Admin users — quota en euros */
.quota-eur-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Admin crédits — paramètres avancés */
details#advancedParams > summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 0;
    user-select: none;
    margin-top: 10px;
}
details#advancedParams > summary:hover { color: var(--text-primary); }
.advanced-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding-top: 8px;
}

/* Admin crédits — toggle vue */
.view-toggle-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-view-toggle { padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-muted); cursor: pointer; font-size: 13px; }
.btn-view-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.model-view-provider { font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
.model-view-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.model-view-table th,
.model-view-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-view-table th:nth-child(1) { width: 28%; }
.model-view-table th:nth-child(2) { width: 10%; }
.model-view-table th:nth-child(3),
.model-view-table th:nth-child(5) { width: 18%; }
.model-view-table th:nth-child(4),
.model-view-table th:nth-child(6) { width: 13%; }
.model-stars { color: #f59e0b; letter-spacing: -1px; }
.tool-view-provider { font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
.tool-view-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.tool-view-table th,
.tool-view-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-view-table th:nth-child(1) { width: 22%; }
.tool-view-table th:nth-child(2) { width: 11%; }
.tool-view-table th:nth-child(3) { width: 22%; }
.tool-view-table th:nth-child(4) { width: 31%; }
.tool-view-table th:nth-child(5) { width: 14%; }
.tool-view-table .tool-view-wrap { white-space: normal; }
.tool-stars { color: #f59e0b; letter-spacing: -1px; }
