/* ─── VARIABLES ───────────────────────────────────────────────── */
:root {
  --bg:       #212121;
  --sidebar:  #171717;
  --card:     #2d2d2d;
  --hover:    rgba(255,255,255,0.06);
  --text:     #ececec;
  --muted:    #8e8ea0;
  --accent:   #10a37f;
  --accent-h: #0d8a6c;
  --border:   rgba(255,255,255,0.08);
  --error:    #ef4444;
  --radius:   8px;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  height: 100vh;
  height: 100dvh;   /* iOS Safari : tient compte de la barre d'adresse */
  display: flex;
  overflow: hidden;
}

/* ─── SIDEBAR ──────────────────────────────────────────────────── */

.sidebar {
  width: 256px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 14px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header h1 { font-size: 14px; font-weight: 600; }

.user-badge {
  background: var(--accent);
  color: #fff;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.sidebar-actions { padding: 8px; flex-shrink: 0; }

.btn-new {
  width: 100%;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s;
}
.btn-new:hover { background: var(--accent-h); }

.sidebar-convs {
  flex: 1;
  overflow-y: auto;
  padding: 2px 5px;
  min-height: 0;
}

.sidebar-convs::-webkit-scrollbar { width: 3px; }
.sidebar-convs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.section-label {
  padding: 10px 8px 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.conv-item {
  padding: 8px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 1px;
  transition: background 0.12s;
  position: relative;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: rgba(255,255,255,0.09); }

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

.conv-actions { display: none; gap: 2px; flex-shrink: 0; }
/* Survol seulement sur appareils à pointeur (desktop) */
@media (hover: hover) {
  .conv-item:hover .conv-actions { display: flex; }
}
/* Tactile : toujours visible → évite le "double tap" iOS pour ouvrir une discussion */
@media (hover: none) {
  .conv-actions { display: flex; }
}

.conv-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: color 0.15s, background 0.15s;
}
.conv-actions button:hover { color: var(--text); background: rgba(255,255,255,0.08); }

.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.sidebar-footer a,
.sidebar-footer button.lnk {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-family: var(--font);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.sidebar-footer a:hover,
.sidebar-footer button.lnk:hover { color: var(--text); }
.sidebar-footer .sep { color: rgba(255,255,255,0.12); font-size: 12px; }

/* ─── MAIN CONTENT ─────────────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── WELCOME ──────────────────────────────────────────────────── */

#welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
  overflow-y: auto;
}

.welcome-icon { font-size: 48px; line-height: 1; }
#welcome-screen h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }
#welcome-screen p { color: var(--muted); max-width: 400px; font-size: 14px; line-height: 1.7; }

.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ─── CHAT VIEW ────────────────────────────────────────────────── */

#chat-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

#chat-view.active { display: flex; }

.chat-header {
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.chat-header-title {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Bouton menu (mobile uniquement) */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.menu-toggle:hover { background: var(--hover); }

/* Fond semi-transparent derrière la sidebar (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ─── MESSAGES ─────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.chat-message {
  padding: 12px 24px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: background 0.1s;
}

.chat-message:hover { background: rgba(255,255,255,0.02); }

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

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

.chat-message-user .msg-avatar {
  background: var(--accent);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0;
}

.chat-message-assistant .msg-avatar {
  background: #19c37d22;
  font-size: 16px;
}

.msg-body { flex: 1; min-width: 0; }

.chat-message-user .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-bubble {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px 14px 2px 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 600px;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Assistant messages: no bubble, full width */
.chat-message-assistant .msg-body {
  max-width: 720px;
}

.msg-content {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}

/* ─── MARKDOWN CONTENT ─────────────────────────────────────────── */

.msg-content p { margin-bottom: 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1,.msg-content h2,.msg-content h3 { margin: 16px 0 8px; font-weight: 600; }
.msg-content h1 { font-size: 18px; }
.msg-content h2 { font-size: 16px; }
.msg-content h3 { font-size: 15px; }
.msg-content ul,.msg-content ol { padding-left: 20px; margin-bottom: 12px; }
.msg-content li { margin-bottom: 4px; }
.msg-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
  margin: 12px 0;
}
.msg-content a { color: var(--accent); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }
.msg-content strong { font-weight: 600; color: #fff; }

/* Inline code */
.msg-content code {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #e8d9b5;
}

/* Code blocks */
.msg-content pre {
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
  position: relative;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.code-lang {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  text-transform: lowercase;
}

.code-copy {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.code-copy:hover { color: var(--text); background: rgba(255,255,255,0.08); }

.msg-content pre code {
  background: none;
  border: none;
  padding: 14px;
  display: block;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  color: #e8e8e8;
  font-family: var(--mono);
}

/* ─── IMAGES (DALL-E) ──────────────────────────────────────────── */

.msg-image-wrap {
  margin-top: 10px;
  position: relative;
  display: inline-block;
}

.msg-image {
  max-width: min(512px, 100%);
  border-radius: 10px;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
  border: 1px solid rgba(255,255,255,0.08);
}
.msg-image:hover { opacity: 0.9; }

.img-download {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  font-family: var(--font);
}
.msg-image-wrap:hover .img-download { opacity: 1; }

/* ─── STREAMING CURSOR ─────────────────────────────────────────── */

.streaming-cursor::after {
  content: "▋";
  animation: blink 0.7s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ─── INPUT AREA ───────────────────────────────────────────────── */

.chat-input-area {
  flex-shrink: 0;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
}
.chat-input-wrapper:focus-within { border-color: rgba(255,255,255,0.22); }

.chat-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.6;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}
.chat-textarea::placeholder { color: var(--muted); }
.chat-textarea::-webkit-scrollbar { width: 3px; }
.chat-textarea::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.chat-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  background: var(--accent);
  color: #fff;
}
.chat-send-btn:hover { background: var(--accent-h); }
.chat-send-btn:disabled { background: rgba(255,255,255,0.1); cursor: not-allowed; color: var(--muted); }

.chat-stop-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.chat-stop-btn:hover { background: rgba(255,255,255,0.08); }
.chat-stop-btn.visible { display: flex; }

/* ─── Bouton joindre + miniatures ──────────────────────────────── */
.chat-attach-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
.chat-attach-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.attach-preview:empty { display: none; }

.attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb.uploading img { opacity: 0.4; }
.attach-thumb.error { border-color: #e5534b; }
.attach-thumb .thumb-spin {
  position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px;
}
.attach-thumb-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-thumb-remove:hover { background: rgba(0,0,0,0.9); }

/* Images jointes dans un message utilisateur : plus compactes */
.chat-message-user .msg-image { max-width: 260px; }

.chat-input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}

.model-select {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  padding: 0;
}
.model-select option { background: #1a1a1a; color: var(--text); }

.chat-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  text-align: center;
  flex: 1;
}

/* ─── COMMON BUTTONS ───────────────────────────────────────────── */

.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,0.11); }
.btn-danger { background: transparent; color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--error); color: #fff; }

/* ─── LOADING/EMPTY ────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  justify-content: center;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.img-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px dashed var(--border, rgba(255,255,255,0.12));
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  width: fit-content;
}
.img-pending .spinner { display: inline-block; }

.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.error-state { padding: 12px 14px; color: var(--error); font-size: 13px; border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius); margin: 8px; background: rgba(239,68,68,0.05); }

/* ─── MODALS ───────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal h3 { font-size: 17px; font-weight: 600; }
.modal-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--muted); font-weight: 500; }

.input-std {
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.input-std:focus { border-color: var(--accent); }

.prefix-row { display: flex; align-items: stretch; }
.prefix-pill {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-right: none;
  padding: 10px 10px;
  border-radius: var(--radius) 0 0 var(--radius);
  font-family: monospace;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.prefix-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.prefix-input:focus { border-color: var(--accent); }

/* ─── LOGIN ────────────────────────────────────────────────────── */

body.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.login-box {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 42px 38px;
  width: 100%;
  max-width: 370px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.login-logo { text-align: center; }
.login-logo .logo-icon { font-size: 38px; line-height: 1; }
.login-logo h1 { font-size: 21px; font-weight: 600; margin-top: 10px; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-box form { display: flex; flex-direction: column; gap: 13px; }
.login-box .btn-primary { width: 100%; padding: 12px; font-size: 14px; justify-content: center; margin-top: 4px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #f87171; padding: 10px 13px; border-radius: var(--radius); font-size: 13px; }

/* ─── ADMIN ────────────────────────────────────────────────────── */

body.admin-body { display: block; height: auto; overflow: auto; }
.admin-page { max-width: 740px; margin: 0 auto; padding: 32px 20px 60px; display: flex; flex-direction: column; gap: 24px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; }
.admin-top h2 { font-size: 19px; font-weight: 600; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; display: flex; align-items: center; gap: 4px; transition: color 0.15s; }
.back-link:hover { color: var(--text); }
.admin-section { background: #1a1a1a; border: 1px solid var(--border); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.admin-section h3 { font-size: 14px; font-weight: 600; }
.admin-hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.admin-hint a { color: var(--accent); text-decoration: none; }
.admin-hint code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.token-form { display: flex; gap: 8px; }
.token-form input { flex: 1; background: var(--bg); border: 1px solid rgba(255,255,255,0.12); color: var(--text); padding: 9px 11px; border-radius: var(--radius); font-size: 13px; font-family: monospace; outline: none; transition: border-color 0.15s; }
.token-form input:focus { border-color: var(--accent); }
.token-set { color: var(--accent); font-size: 12px; }
.token-missing { color: var(--error); font-size: 12px; }
.token-preview { font-family: monospace; font-size: 11px; color: var(--muted); background: rgba(255,255,255,0.04); padding: 4px 8px; border-radius: 5px; display: inline-block; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 500; font-size: 11px; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 9px; font-size: 11px; font-weight: 600; }
.badge-admin { background: rgba(16,163,127,0.15); color: var(--accent); }
.badge-user { background: rgba(255,255,255,0.06); color: var(--muted); }
.create-form { display: flex; gap: 7px; align-items: flex-end; flex-wrap: wrap; }
.create-form .form-group { flex: 1; min-width: 100px; }
.cb-group { display: flex; align-items: center; gap: 5px; padding-bottom: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.model-form { display: flex; gap: 8px; align-items: center; }
.model-form select { background: var(--bg); border: 1px solid rgba(255,255,255,0.12); color: var(--text); padding: 9px 11px; border-radius: var(--radius); font-size: 13px; font-family: var(--font); outline: none; }

/* ─── IMAGE LIGHTBOX ───────────────────────────────────────────── */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ─── SCROLLBAR GLOBAL ─────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ─── RESPONSIVE (mobile) ──────────────────────────────────────── */

@media (max-width: 768px) {
  /* Empêche TOUTE la page de scroller quand le clavier s'ouvre :
     body fixe → rien à scroller, la hauteur (réglée en JS) gère le clavier. */
  html { height: 100%; overflow: hidden; }
  body {
    position: fixed;
    top: 0; left: 0; right: 0;
    width: 100%;
    overscroll-behavior: none;
  }

  /* Sidebar coulissante hors écran par défaut */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    width: 82%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }

  /* Backdrop visible quand la sidebar est ouverte */
  .sidebar-backdrop.show { display: block; }

  /* Le contenu principal prend tout l'écran */
  .main-content { width: 100%; }

  /* Bouton menu visible */
  .menu-toggle { display: flex; }

  /* Header un peu plus compact */
  .chat-header { padding: 10px 14px; gap: 10px; }
  .chat-messages { padding-left: 14px; padding-right: 14px; }
  .chat-input-area { padding: 10px 14px 12px; }

  /* ≥16px : empêche le zoom automatique d'iOS au focus du champ */
  .chat-textarea { font-size: 16px; }
  .prefix-input  { font-size: 16px; }
}
