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

:root {
    --bg:          #212121;
    --bg-sidebar:  #171717;
    --bg-surface:  #2f2f2f;
    --bg-input:    #2f2f2f;
    --accent:      #10a37f;
    --accent-dark: #0d8a6b;
    --text:        #ececec;
    --text-muted:  #8e8ea0;
    --border:      #3d3d3d;
    --radius:      12px;
    --radius-sm:   8px;
    --font:        'Söhne', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* 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;
    justify-content: space-between;
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

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

.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;
    overflow: hidden;
    position: relative;
}

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

.toolbar-selectors {
    display: flex;
    gap: 8px;
}

.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-picker-item {
    display: flex;
    align-items: center;
    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); }

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

.chat-welcome h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
}

.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: rgba(16,163,127,.06); }
.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; }
.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-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;
}

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

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

/* 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: rgba(16,163,127,.06);
    border-radius: 0 6px 6px 0;
}
.msg-content a { color: var(--accent); 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;
}

.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%;
    max-height: 200px;
    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;
}

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

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

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

.w-full { width: 100%; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

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

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

.admin-sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-sidebar .logo-text {
    font-size: 15px;
    padding: 8px 10px 16px;
    display: block;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

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

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

.table-wrap { overflow-x: auto; }

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

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: rgba(16,163,127,.15); color: #10a37f; }
.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: rgba(16,163,127,.12); color: #6ee7b7; border: 1px solid rgba(16,163,127,.3); }

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

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

/* 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 */
    .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 hamburger visible */
    .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); }

    /* Toolbar : selectors empilés */
    .chat-toolbar { padding: 8px 12px; }
    .toolbar-selectors { flex-wrap: wrap; gap: 6px; }
    .llm-picker-btn { font-size: 12px; }
    #profileSelect { font-size: 12px; }

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

    /* Input */
    .chat-input-wrap { padding: 8px 10px 10px; }
    .msg-textarea { font-size: 16px; } /* Empêche le zoom iOS */

    /* Welcome */
    .chat-welcome { padding: 24px 16px; }
    .chat-welcome h2 { font-size: 20px; }
    .welcome-actions { grid-template-columns: 1fr 1fr; }

    /* Admin */
    .admin-content { padding: 16px 12px; }
    .admin-content h1 { font-size: 20px; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modal */
    .modal-box { padding: 20px 16px; width: calc(100vw - 32px); }

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

/* ---- Avatar picker (admin profiles) ---- */
.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;
}
.avatar-opt input[type=radio] { display: none; }
.avatar-img-wrap {
    width: 52px;
    height: 52px;
    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;
}

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