/* ==========================================================
   SOPHIA - Design system 2026
   Vars + composants + motion
   ========================================================== */

:root {
  /* Couleurs */
  --bg: #FBFBF9;
  --bg-elev: #FFFFFF;
  --bg-soft: #F5F5F7;
  --bg-hover: rgba(0,0,0,.035);
  --text: #1A1A1A;
  --text-2: #5A6270;
  --text-3: #8A93A6;
  --line: rgba(0,0,0,.06);
  --line-strong: rgba(0,0,0,.10);
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --danger: #d32f2f;
  --success: #2e7d32;

  /* Espacement (grille 4px) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-12: 48px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-full: 999px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms;
  --t: 220ms;
  --t-slow: 380ms;
}

body.dark {
  --bg: #0B0D14;
  --bg-elev: #151824;
  --bg-soft: #1A1E2B;
  --bg-hover: rgba(255,255,255,.05);
  --text: #E5E9F0;
  --text-2: #B8BCC2;
  --text-3: #8A93A6;
  --line: rgba(255,255,255,.06);
  --line-strong: rgba(255,255,255,.10);
  --accent: #8AB4F8;
  --accent-hover: #A6C8FF;
}

/* ==========================================================
   Reset & base
   ========================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }

/* ==========================================================
   Header
   ========================================================== */

.header .nom { color: var(--text); }

.btn-register {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.btn-register:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--line-strong);
  transform: scale(1.04);
}

/* ==========================================================
   Main / Greeting
   ========================================================== */
.main {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.greeting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px var(--s-6) 200px;
  text-align: center;
  transition: opacity var(--t-slow) var(--ease);
}
.greeting.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.greeting .logo-big {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3.2rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--s-5);
  letter-spacing: -.02em;
  animation: fadeUp var(--t-slow) var(--ease-out);
}
.greeting .message {
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: var(--s-8);
  letter-spacing: -.015em;
  background: linear-gradient(90deg, var(--accent), #a142f4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeUp var(--t-slow) var(--ease-out) 80ms backwards;
  max-width: 520px;
}
.greeting .suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
  max-width: 420px;
  animation: fadeUp var(--t-slow) var(--ease-out) 160ms backwards;
}
.suggestion-chip {
  padding: 12px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: .92rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.suggestion-chip:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Chat area
   ========================================================== */
.chat-area {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 80px 16px 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-padding-top: 80px;
  scroll-padding-bottom: 180px;
  scrollbar-width: thin;
}
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

@media (min-width: 768px) {
  .chat-area { padding: 80px max(16px, calc(50% - 380px)) 180px; }
}

/* ==========================================================
   Messages
   ========================================================== */
.message {
  max-width: 100%;
  line-height: 1.65;
  font-size: .96rem;
  color: var(--text);
  word-wrap: break-word;
  animation: msgIn var(--t) var(--ease-out);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* User : bulle à droite */
.message.user {
  align-self: flex-end;
  max-width: 82%;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-radius: var(--r-lg);
  border-bottom-right-radius: 6px;
  color: var(--text);
  margin: var(--s-2) 0 var(--s-3);
}
body.dark .message.user { background: #232735; }

/* Sophia : pas de bulle, texte aéré */
.message.sophia {
  align-self: stretch;
  padding: var(--s-3) 0 var(--s-4);
  border-bottom: 1px solid var(--line);
}
.message.sophia:last-child { border-bottom: 0; }
.message.sophia .contenu {
  display: block;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: .98rem;
  line-height: 1.65;
  letter-spacing: -.005em;
}
.message.sophia .contenu a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color var(--t-fast) var(--ease);
  word-break: break-all;
  overflow-wrap: anywhere;
}
.message.sophia .contenu a:hover { border-bottom-color: var(--accent); }

.message .timestamp {
  display: block;
  font-size: .68rem;
  color: var(--text-3);
  margin-top: var(--s-2);
}
.message .status {
  display: block;
  font-size: .82rem;
  color: var(--text-3);
  font-style: italic;
  margin-bottom: var(--s-2);
}

/* Typing */
.message.typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 6px;
}
.dots-typing { display: flex; gap: 5px; align-items: center; height: 8px; }
.dots-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: dotPulse 1.3s infinite ease-in-out;
}
.dots-typing span:nth-child(2) { animation-delay: .18s; }
.dots-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes dotPulse {
  0%, 60%, 100% { opacity: .3; transform: scale(.75); }
  30% { opacity: 1; transform: scale(1); }
}

/* ==========================================================
   Actions sur message
   ========================================================== */
.message .actions {
  display: flex;
  gap: 2px;
  margin-top: var(--s-3);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.message:hover .actions,
.message.sophia .actions { opacity: 1; }

.message .actions button {
  background: none;
  border: none;
  color: var(--text-3);
  padding: 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.message .actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
  transform: translateY(-1px);
}
.message .actions button svg { stroke: currentColor; }

/* ==========================================================
   Thinking block
   ========================================================== */
.thinking-block {
  margin: var(--s-3) 0 var(--s-4);
  padding: 10px 14px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  font-size: .86rem;
  transition: all var(--t) var(--ease);
  animation: msgIn var(--t-slow) var(--ease-out);
}
.thinking-block .thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  cursor: pointer;
  font-weight: 500;
  font-size: .82rem;
  user-select: none;
  transition: color var(--t-fast) var(--ease);
}
.thinking-block .thinking-header:hover { color: var(--text-2); }
.thinking-block .thinking-header svg:first-child {
  animation: brainPulse 2s ease-in-out infinite;
}
@keyframes brainPulse {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}
.thinking-block .thinking-title { flex: 1; }
.thinking-block .thinking-chevron {
  transition: transform var(--t) var(--ease);
}
.thinking-block.collapsed .thinking-chevron { transform: rotate(-90deg); }
.thinking-block .thinking-content {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-style: italic;
  font-size: .84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  animation: fadeIn var(--t) var(--ease);
}
.thinking-block.collapsed .thinking-content { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.thinking-block .thinking-header .sources-in-thinking {
  margin: 0 4px;
  padding: 3px 10px 3px 4px;
  font-size: .72rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}
.thinking-block .thinking-header .sources-in-thinking .favicons img {
  width: 14px; height: 14px;
}

/* ==========================================================
   Sources button (badge favicons)
   ========================================================== */
.sources-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-size: .78rem;
  color: var(--text-2);
  cursor: pointer;
  margin: var(--s-2) 0 var(--s-3);
  transition: all var(--t-fast) var(--ease);
  font-family: inherit;
}
.sources-btn:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.sources-btn .favicons { display: flex; }
.sources-btn .favicons img {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--bg-elev);
  margin-left: -6px;
  object-fit: cover;
}
.sources-btn .favicons img:first-child { margin-left: 0; }
.sources-btn .count { font-weight: 500; }

/* ==========================================================
   Bottom input
   ========================================================== */
.bas-fixe {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding-top: 24px;
  pointer-events: none;
}
.bas-fixe .input-area {
  padding: 0 var(--s-4) var(--s-3);
  max-width: 800px;
  margin: 0 auto;
  pointer-events: auto;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 6px 6px 6px 8px;
  transition: all var(--t-fast) var(--ease);
  box-shadow: 0 2px 12px rgba(0,0,0,.03);
}
.input-wrapper:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 4px 20px rgba(0,0,0,.05);
}
body.dark .input-wrapper { box-shadow: 0 2px 12px rgba(0,0,0,.15); }

.input-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.input-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  transform: scale(1.06);
}
.input-btn svg { stroke: currentColor; }

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: .96rem;
  padding: 8px 4px;
  background: transparent;
  max-height: 160px;
  line-height: 1.5;
  color: var(--text);
  scrollbar-width: none;
}
#messageInput::-webkit-scrollbar { display: none; }
#messageInput::placeholder { color: var(--text-3); }

.premium-badge {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: #C9A227;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.premium-badge:hover { background: rgba(201,162,39,.1); transform: scale(1.06); }
.premium-badge svg { stroke: currentColor; }
.premium-badge.hidden { display: none; }

.send-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: var(--r-full);
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.send-btn:active:not(:disabled) { transform: scale(.96); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn svg { stroke: currentColor; }

.quota-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px var(--s-4) var(--s-2);
  font-size: .72rem;
  color: var(--text-3);
  max-width: 800px;
  margin: 0 auto;
}

/* ==========================================================
   Overlay + Sidebar
   ========================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.32);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.overlay.visible { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--bg-elev);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--s-4) var(--s-3);
  gap: 2px;
  transform: translateX(-100%);
  transition: transform var(--t-slow) var(--ease-out);
  box-shadow: 2px 0 24px rgba(0,0,0,.04);
}
.sidebar.open { transform: translateX(0); }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) var(--s-2) var(--s-4);
  margin-bottom: var(--s-2);
  border-bottom: 1px solid var(--line);
}
.sidebar-header .user-info {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  flex: 1;
}
.sidebar-header .user-avatar {
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent), #a142f4);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: .95rem;
  flex-shrink: 0;
}
.sidebar-header .user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-header .user-details strong {
  font-size: .88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.sidebar-header .user-details span {
  font-size: .75rem;
  color: var(--text-3);
}
.sidebar-header .close-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-header .close-btn:hover { background: var(--bg-hover); color: var(--text); }

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: .9rem;
  font-weight: 400;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: all var(--t-fast) var(--ease);
  font-family: inherit;
}
.menu-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.menu-item .icon {
  width: 20px;
  display: flex; align-items: center; justify-content: center;
  color: currentColor;
  flex-shrink: 0;
}
.menu-item .icon svg { stroke: currentColor; }
.menu-item .label { flex: 1; }
.menu-item .tag {
  font-size: .65rem;
  padding: 2px 7px;
  background: var(--bg-soft);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: .02em;
}
.menu-item.new-conv { color: var(--text); font-weight: 500; }
.menu-item.bientot { opacity: .55; cursor: default; }
.menu-item.bientot:hover { background: none; }

.menu-separator {
  height: 1px;
  background: var(--line);
  margin: var(--s-2) var(--s-3);
}

/* ==========================================================
   Panneaux (Chats, Insights, Paramètres, Admin)
   ========================================================== */
.panneau {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: none;
  flex-direction: column;
  transition: opacity var(--t) var(--ease);
}
.panneau.visible {
  display: flex;
  animation: panneauIn var(--t-slow) var(--ease-out);
}
@keyframes panneauIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panneau .contenu {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) 100px;
  flex: 1;
  overflow-y: auto;
}
.panneau h3 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 var(--s-2);
  color: var(--text);
}
.panneau .sous-titre {
  display: block;
  font-size: .88rem;
  color: var(--text-3);
  margin-bottom: var(--s-6);
}
.panneau .fermer {
  width: 100%;
  padding: 12px;
  margin-top: var(--s-6);
  background: var(--bg-soft);
  border: none;
  border-radius: var(--r-md);
  color: var(--text);
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.panneau .fermer:hover { background: var(--line-strong); }

.panneau-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-6);
}
.panneau-header h3 { margin: 0; }
.panneau-header .close-x {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.panneau-header .close-x:hover { background: var(--bg-hover); color: var(--text); }

/* Conversations */
.recherche-conv {
  width: 100%;
  padding: 10px 14px 10px 38px;
  margin-bottom: var(--s-3);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: .9rem;
  outline: none;
  color: var(--text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A93A6' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.35-4.35'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: all var(--t-fast) var(--ease);
  font-family: inherit;
}
.recherche-conv:focus {
  background-color: var(--bg-elev);
  border-color: var(--accent);
}

.nouvelle-conv-panneau {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: var(--s-4);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: .92rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--t-fast) var(--ease);
  font-family: inherit;
}
.nouvelle-conv-panneau:hover { background: var(--bg-hover); }
.nouvelle-conv-panneau i { color: var(--text-3); font-size: .85rem; }

.groupe-date {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s-4) 10px var(--s-2);
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  background: transparent;
  border: none;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.session-item.active .session-info .titre { color: var(--accent); font-weight: 500; }

.session-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.session-item:hover .session-actions,
.session-item.active .session-actions { opacity: 1; }
.session-actions button {
  padding: 5px;
  background: none;
  border: none;
  color: var(--text-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.session-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}
@media (max-width: 600px) {
  .session-actions { opacity: 1; }
}

/* ==========================================================
   Paramètres (dans panneau)
   ========================================================== */
.param-section { margin-bottom: var(--s-6); }
.param-label {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--s-2);
  padding: 0 var(--s-1);
}
.ligne-param {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  font-size: .92rem;
  color: var(--text);
}
.valeur-param {
  color: var(--text-3);
  font-size: .88rem;
}

/* ==========================================================
   Modal sources
   ========================================================== */
.sources-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 3000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn var(--t) var(--ease);
}
.sources-modal.open { display: flex; }
.sources-modal-content {
  background: var(--bg-elev);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-5);
  overflow-y: auto;
  animation: slideUp var(--t-slow) var(--ease-out);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sources-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-4);
}
.sources-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0;
}
.sources-modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease);
}
.sources-modal-close:hover { background: var(--bg-hover); }

.source-item {
  display: flex;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast) var(--ease);
  border-radius: var(--r-sm);
}
.source-item:last-child { border-bottom: 0; }
.source-item:hover { background: var(--bg-hover); }
.source-item .fav {
  width: 24px; height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
}
.source-item .body { flex: 1; min-width: 0; }
.source-item .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--text-3);
  margin-bottom: 4px;
}
.source-item .meta .num {
  background: var(--bg-soft);
  border-radius: var(--r-full);
  padding: 1px 7px;
  font-size: .7rem;
}
.source-item .title {
  font-size: .92rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 600px) {
  .chat-area { padding: 76px 12px 170px; }
  .message.user { max-width: 86%; }
  .greeting .message { font-size: 1.15rem; }
  .greeting .logo-big { font-size: 2.6rem; }
  .message .actions { opacity: 1; }
  .sidebar { width: 300px; }
}

/* ==========================================================
   Accessibility
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Fix liens dans Parametres */
a.ligne-param {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
a.ligne-param > span:first-child {
  color: var(--text);
  font-size: .92rem;
}
a.ligne-param .valeur-param,
a.ligne-param > span:last-child {
  color: var(--accent);
  font-size: .88rem;
}
a.ligne-param:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
}

/* Force couleurs dans Parametres (protege contre d'autres blocs inline) */
a.ligne-param,
a.ligne-param:visited {
  color: var(--text) !important;
}
a.ligne-param > span:first-child {
  color: var(--text) !important;
}
a.ligne-param .valeur-param,
a.ligne-param > span:last-child {
  color: var(--accent) !important;
}
body.dark a.ligne-param {
  color: var(--text) !important;
  background: var(--bg-elev) !important;
}
body.dark a.ligne-param > span:first-child {
  color: var(--text) !important;
}
body.dark a.ligne-param .valeur-param,
body.dark a.ligne-param > span:last-child {
  color: var(--accent) !important;
}

/* Toggle pills (Recherche / Reflexion) */
.toggles-bar {
  display: flex;
  gap: 8px;
  padding: 8px 4px 4px;
}
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: .78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.toggle-pill svg { stroke: currentColor; }
.toggle-pill:hover {
  background: var(--bg-soft);
  color: var(--text-2);
}
.toggle-pill.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
}
body.dark .toggle-pill.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Input toggles (Verifier / Reflexion dans la barre) */
.input-toggle {
  position: relative;
}
.input-toggle .dot-state {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  transition: background var(--t-fast) var(--ease);
}
.input-toggle.active {
  color: var(--accent);
}
.input-toggle.active .dot-state {
  background: var(--accent);
}
.input-toggle:not(.active) {
  opacity: .45;
}

/* Menu conversation "..." */
.session-menu-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.session-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.session-menu {
  position: fixed;
  z-index: 5000;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  animation: fadeIn var(--t-fast) var(--ease);
}
.session-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.session-menu button:hover {
  background: var(--bg-hover);
}
.session-menu button.danger {
  color: var(--danger);
}
.session-menu button.danger:hover {
  background: rgba(211,47,47,.08);
}
.session-menu button svg {
  stroke: currentColor;
  flex-shrink: 0;
}


/* ==========================================================
   Header
   ========================================================== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  background: rgba(251,251,249,.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
body.dark .header { background: rgba(11,13,20,.78); }

.header .brand {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-left: 4px;
}
.header .logo-s { color: var(--accent); font-weight: 600; }
.header .brand #headerTitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
}
.header .header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.header .btn-register,
.header .btn-new-conv {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.header .btn-register:hover,
.header .btn-new-conv:hover { background: var(--bg-hover); }
.header .btn-register svg,
.header .btn-new-conv svg { stroke: currentColor; }

/* Barre de saisie : alleger les icones */
.input-wrapper .premium-badge {
  display: none !important;
}
.input-wrapper #messageInput {
  min-width: 80px;
}
.input-toggle {
  width: 32px !important;
  height: 32px !important;
}
.input-toggle svg {
  width: 18px !important;
  height: 18px !important;
}

/* Menu flottant + */
.input-wrapper { position: relative; }
.plus-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  display: none;
  z-index: 50;
}
.plus-menu.open { display: block; animation: fadeIn var(--t-fast) var(--ease); }
.plus-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.plus-menu button:hover { background: var(--bg-hover); }
.plus-menu button svg { stroke: currentColor; color: var(--text-3); flex-shrink: 0; }

/* Liste conversations style Claude */
.section-recents {
  font-size: .78rem;
  color: var(--text-3);
  padding: 4px 12px 8px;
  font-weight: 400;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.session-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.session-icon {
  color: var(--text-3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.session-icon svg { stroke: currentColor; }
.session-info .titre {
  font-size: .92rem;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item.active .session-info .titre { color: var(--accent); font-weight: 500; }

.session-actions { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.session-item:hover .session-actions { opacity: 1; }
.session-menu-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
}
.session-menu-btn:hover { background: var(--bg-hover); color: var(--text); }
@media (max-width: 600px) {
  .session-actions { opacity: 1; }
}


/* ==========================================================
   Piste 2 : points pulsants (signature Sophia)
   ========================================================== */
.session-item .session-icon {
  width: 16px;
  height: 16px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.session-item .session-icon .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(138,147,166,.35);
  transition: all var(--t) var(--ease);
  display: block;
}
.session-item:hover .session-icon .dot {
  background: rgba(26,115,232,.45);
}
.session-item.active .session-icon .dot {
  background: var(--accent);
  width: 10px;
  height: 10px;
  animation: dotPulseSophia 2s ease-in-out infinite;
}
@keyframes dotPulseSophia {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,115,232,.5); }
  50% { box-shadow: 0 0 0 6px rgba(26,115,232,0); }
}
body.dark .session-item .session-icon .dot { background: rgba(138,147,166,.3); }
body.dark .session-item.active .session-icon .dot { background: var(--accent); }


/* ==========================================================
   Parametres : refonte complete (style 2026)
   ========================================================== */

/* Force : ligne-param en row */
.panneau .ligne-param,
.panneau a.ligne-param {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 14px 16px !important;
    background: var(--bg-elev) !important;
    border: 1px solid var(--line) !important;
    border-radius: 12px !important;
    margin-bottom: 6px !important;
    text-decoration: none !important;
    color: var(--text) !important;
    font-size: .94rem !important;
    line-height: 1.4 !important;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease) !important;
    cursor: pointer !important;
}
.panneau a.ligne-param:hover,
.panneau .ligne-param:hover {
    background: var(--bg-soft) !important;
    border-color: var(--line-strong) !important;
}

.panneau .ligne-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    flex: 1 !important;
    min-width: 0 !important;
    text-align: left !important;
}
.panneau .ligne-icon {
    color: var(--text-3) !important;
    flex-shrink: 0 !important;
    stroke: currentColor !important;
}
.panneau .ligne-left span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.panneau .valeur-param {
    color: var(--text-3) !important;
    font-size: .88rem !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}
.panneau .chevron {
    color: var(--text-3) !important;
    font-size: 1.4rem !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    font-weight: 300 !important;
}

/* Sections */
.panneau .param-section {
    margin-bottom: 24px !important;
}
.panneau .param-label {
    font-size: .7rem !important;
    font-weight: 500 !important;
    letter-spacing: .09em !important;
    text-transform: uppercase !important;
    color: var(--text-3) !important;
    margin-bottom: 8px !important;
    padding: 0 4px !important;
}

/* Switch theme */
.panneau .switch-theme {
    display: flex !important;
    background: var(--bg-soft) !important;
    border-radius: 999px !important;
    padding: 2px !important;
    flex-shrink: 0 !important;
}
.panneau .switch-theme .cote {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    color: var(--text-3) !important;
    cursor: pointer !important;
    font-size: .9rem !important;
    transition: all var(--t-fast) var(--ease) !important;
}
.panneau .switch-theme .cote.soleil {
    background: var(--accent) !important;
    color: #fff !important;
}

/* Bouton deconnexion */
.btn-logout-panel {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 14px 16px !important;
    background: transparent !important;
    border: 1px solid var(--line) !important;
    border-radius: 12px !important;
    color: var(--danger) !important;
    font-size: .94rem !important;
    font-weight: 400 !important;
    font-family: inherit !important;
    cursor: pointer !important;
    text-align: left !important;
    transition: background var(--t-fast) var(--ease) !important;
}
.btn-logout-panel:hover {
    background: color-mix(in srgb, var(--danger) 8%, transparent) !important;
}
.btn-logout-panel svg {
    stroke: currentColor !important;
    flex-shrink: 0 !important;
}

/* Footer */
.panneau .param-footer {
    margin-top: 40px !important;
    padding: 20px 0 40px !important;
    text-align: center !important;
    color: var(--text-3) !important;
    font-size: .78rem !important;
    line-height: 1.7 !important;
}

/* Cacher l'ancienne deconnexion dans panneauCompte (elle est maintenant dans Parametres) */
#btnLogout-old, #panneauCompte #btnLogout {
    /* on garde si tu veux la retirer plus tard */
}

/* ==========================================================
   Compte en pied de sidebar (style 2026)
   ========================================================== */
.sidebar-compte-pied {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  border-radius: 8px;
  margin-bottom: 4px;
}
.sidebar-compte-pied:hover { background: var(--bg-hover); }

.compte-pied-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a142f4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .85rem;
  flex-shrink: 0;
}

.compte-pied-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.compte-pied-email {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compte-pied-role {
  font-size: .7rem;
  color: var(--text-3);
}

.compte-pied-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.compte-pied-btn:hover { background: var(--bg-hover); color: var(--text); }
.compte-pied-btn svg { stroke: currentColor; }

.compte-menu {
  position: fixed;
  bottom: 70px;
  left: 12px;
  min-width: 200px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 5000;
  display: none;
}
.compte-menu.open {
  display: block;
  animation: fadeIn var(--t-fast) var(--ease);
}
.compte-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.compte-menu button:hover { background: var(--bg-hover); }
.compte-menu button.danger { color: var(--danger); }
.compte-menu button.danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.compte-menu button svg { stroke: currentColor; flex-shrink: 0; color: var(--text-3); }
.compte-menu button.danger svg { color: var(--danger); }


/* Sidebar header minimal : juste bouton fermer */
.sidebar-header-minimal {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  padding: 4px 4px 12px !important;
  margin-bottom: 8px !important;
  border-bottom: 1px solid var(--line) !important;
}


/* ==========================================================
   Sidebar allegee + recherche en haut
   ========================================================== */
.sidebar .menu-item { padding: 9px 12px !important; }
.sidebar .menu-separator { margin: 6px 12px !important; }
.sidebar { padding: 12px 10px !important; }

.panneau .contenu {
  display: flex;
  flex-direction: column;
}
.panneau .recherche-conv { order: -1; margin-bottom: 12px; }

/* Groupes de dates */
.groupe-date {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 10px 6px;
  text-align: left;
}

/* ==========================================================
   Compte pied de sidebar
   ========================================================== */
.sidebar-compte-pied {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  border-radius: 8px;
  margin-bottom: 4px;
}
.sidebar-compte-pied:hover { background: var(--bg-hover); }
.compte-pied-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a142f4);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
  flex-shrink: 0;
}
.compte-pied-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.compte-pied-email {
  font-size: .82rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.compte-pied-role { font-size: .7rem; color: var(--text-3); }
.compte-pied-btn {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; padding: 4px 6px; border-radius: 6px;
  display: flex; align-items: center; flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.compte-pied-btn:hover { background: var(--bg-hover); color: var(--text); }
.compte-pied-btn svg { stroke: currentColor; }

/* Menu flottant du compte */
.compte-menu {
  position: fixed;
  bottom: 70px;
  left: 12px;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 5000;
  display: none;
}
.compte-menu.open {
  display: block;
  animation: fadeIn var(--t-fast) var(--ease);
}
.compte-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: none; border: none; border-radius: 8px;
  color: var(--text); font-size: .9rem; font-family: inherit;
  cursor: pointer; text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.compte-menu button:hover { background: var(--bg-hover); }
.compte-menu button svg { stroke: currentColor; flex-shrink: 0; color: var(--text-3); }

/* Header sidebar minimal + brand */
.sidebar-header-clean {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 4px 4px 14px !important;
  margin-bottom: 8px !important;
  border-bottom: 1px solid var(--line) !important;
}
.sidebar-brand {
  display: flex; align-items: center;
  font-size: 1.05rem; font-weight: 500;
  letter-spacing: -.01em; color: var(--text);
  padding-left: 8px;
}
.sidebar-brand .logo-s { color: var(--accent); font-weight: 600; }
.sidebar-header-clean .close-btn {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; padding: 6px; border-radius: 6px;
  display: flex; align-items: center;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-header-clean .close-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Recents dans la sidebar (sans lignes) */
.sidebar-recents {
  margin-top: 24px;
  padding: 0 4px;
}
.sidebar-recents-titre {
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px 8px;
}
.sidebar-recents-liste {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.recent-item:hover {
  background: var(--bg-hover);
}
.recent-item.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.recent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  opacity: .5;
}
.recent-item.active .recent-dot {
  background: var(--accent);
  opacity: 1;
}
.recent-titre {
  font-size: .88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.recent-item.active .recent-titre {
  color: var(--accent);
  font-weight: 500;
}
.sidebar-recents-plus {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: .82rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-recents-plus:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Recherche en haut de la sidebar */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-soft);
  border-radius: 10px;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-search svg {
  stroke: var(--text-3);
  flex-shrink: 0;
}
.sidebar-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  padding: 4px 0;
}
.sidebar-search input::placeholder {
  color: var(--text-3);
}
.sidebar-search:focus-within {
  background: var(--bg-elev);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ==========================================================
   COMPACT SIDEBAR (style DeepSeek/Claude 2026)
   ========================================================== */

/* Container sidebar : moins d'air */
.sidebar {
  padding: 10px 8px !important;
  gap: 0 !important;
}

/* Header minimal */
.sidebar-header-clean,
.sidebar-header {
  padding: 4px 6px 10px !important;
  margin-bottom: 6px !important;
  min-height: 0 !important;
}

/* Barre de recherche : moins haute */
.sidebar-search {
  padding: 7px 10px !important;
  margin-bottom: 10px !important;
  border-radius: 8px !important;
}
.sidebar-search input {
  font-size: .85rem !important;
  padding: 2px 0 !important;
}

/* Items du menu : plus serres */
.sidebar .menu-item {
  padding: 8px 10px !important;
  min-height: 0 !important;
  font-size: .9rem !important;
  border-radius: 6px !important;
  margin: 0 !important;
}
.sidebar .menu-item .icon {
  width: 18px !important;
}
.sidebar .menu-item .icon svg {
  width: 16px !important;
  height: 16px !important;
}

/* Recents : compacts */
.sidebar-recents {
  margin-top: 14px !important;
  padding: 0 !important;
}
.sidebar-recents-titre {
  padding: 0 10px 4px !important;
  font-size: .66rem !important;
}
.recent-item {
  padding: 7px 10px !important;
  gap: 8px !important;
}
.recent-titre {
  font-size: .86rem !important;
}
.sidebar-recents-plus {
  padding: 7px 10px !important;
  font-size: .78rem !important;
  margin-top: 2px !important;
}

/* Pied de compte : compact */
.sidebar-compte-pied {
  padding: 8px 10px !important;
  margin-bottom: 0 !important;
}
.compte-pied-avatar {
  width: 28px !important;
  height: 28px !important;
  font-size: .78rem !important;
}
.compte-pied-email {
  font-size: .8rem !important;
}
.compte-pied-role {
  font-size: .68rem !important;
}

/* === Sidebar : patch final === */
#sidebar .sidebar-header-minimal {
  display: flex !important; justify-content: space-between !important;
  align-items: center !important; padding: 2px 4px 10px !important;
  margin: 0 !important; min-height: 0 !important; height: auto !important;
}
#sidebar .sidebar-brand { display: flex !important; align-items: center; padding-left: 6px; color: var(--text); }
#sidebar .sidebar-brand .logo-s { font-size: 1.7rem !important; letter-spacing: -1px !important; line-height: 1; color: var(--accent); }
#sidebar .sidebar-brand .nom { font-size: 1.05rem; font-weight: 500; color: var(--text); }
.recent-groupe { font-size: .66rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 12px 10px 4px; }
.recent-more { background: none; border: none; color: var(--text-3); padding: 4px; border-radius: 6px; display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.recent-more:hover { background: var(--bg-hover); color: var(--text); }
.conv-menu { position: fixed; min-width: 170px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 32px rgba(0,0,0,.12); z-index: 5000; display: none; }
.conv-menu.open { display: block; }
.conv-menu button { display: block; width: 100%; padding: 10px 12px; background: none; border: none; border-radius: 8px; color: var(--text); font-size: .9rem; font-family: inherit; text-align: left; cursor: pointer; }
.conv-menu button:hover { background: var(--bg-hover); }
.conv-menu button.danger { color: #d93025; }

/* === Sidebar : tailles proches des grandes IA === */
#sidebar { width: 320px !important; max-width: 88vw !important; }
#sidebar .sidebar-search { padding: 10px 12px !important; }
#sidebar .sidebar-search input { font-size: .95rem !important; }
#sidebar .menu-item { font-size: 1rem !important; padding: 12px !important; gap: 14px !important; }
#sidebar .menu-item .icon { width: 22px !important; }
#sidebar .menu-item .icon svg { width: 20px !important; height: 20px !important; }
#sidebar .recent-item { padding: 10px 12px !important; }
#sidebar .recent-titre { font-size: .95rem !important; }
#sidebar .recent-groupe, #sidebar .sidebar-recents-titre { font-size: .72rem !important; }
#sidebar .sidebar-recents-plus { font-size: .85rem !important; padding: 10px 12px !important; }
#sidebar .compte-pied-email { font-size: .9rem !important; }
#sidebar .compte-pied-role { font-size: .75rem !important; }

/* === Apercu des fichiers envoyes === */

.fichier-carte { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 0 0 8px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; max-width: 260px; }
.fichier-carte-icone { flex-shrink: 0; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 8px; background: #d93025; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; letter-spacing: .04em; }
.fichier-carte-info { display: flex; flex-direction: column; min-width: 0; }
.fichier-carte-nom { font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.fichier-carte-taille { font-size: .72rem; color: var(--text-3); }

/* === Bouton export PDF === */
.actions .pdf-btn { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; align-items: center; }
.actions .pdf-btn:hover { background: var(--bg-hover); color: var(--text); }
.actions .pdf-btn:disabled { opacity: .5; cursor: wait; }

/* === Menu d'export (PDF / Word / Excel) === */
.export-menu { position: fixed; min-width: 170px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 32px rgba(0,0,0,.12); z-index: 5000; display: none; }
.export-menu.open { display: block; }
.export-menu button { display: block; width: 100%; padding: 10px 12px; background: none; border: none; border-radius: 8px; color: var(--text); font-size: .9rem; font-family: inherit; text-align: left; cursor: pointer; }
.export-menu button:hover { background: var(--bg-hover); }


/* ==========================================================
   SIDEBAR CLEAN 2026 (Override final - Zero suppression)
   ========================================================== */

/* 1. Conteneur global : compact, sans gap */
#sidebar, .sidebar {
  padding: 12px 10px !important;
  gap: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* 2. Header : Brand à gauche, X à droite, sans ligne de séparation */
.sidebar-header, .sidebar-header-minimal {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 4px 6px 16px !important;
  margin-bottom: 4px !important;
  border-bottom: none !important;
  min-height: 40px !important;
}
.sidebar-brand {
  display: flex !important;
  align-items: center !important;
  padding-left: 4px !important;
}
.sidebar-brand .logo-s {
  color: #3E7BFA !important;
  font-size: 1.5rem !important;
  font-weight: 600 !important;
  line-height: 1 !important;
}
.sidebar-brand .nom {
  font-size: 1.05rem !important;
  font-weight: 500 !important;
  color: var(--text) !important;
}

/* 3. Bouton fermer */
.sidebar-header .close-btn {
  padding: 6px !important;
  border-radius: 6px !important;
  color: var(--text-3) !important;
}

/* 4. Recherche : compacte */
.sidebar-search {
  padding: 8px 12px !important;
  margin-bottom: 12px !important;
  border-radius: 8px !important;
  background: var(--bg-soft) !important;
}
.sidebar-search input {
  font-size: .85rem !important;
  padding: 0 !important;
}

/* 5. Items du menu : serrés, pas de marges */
.sidebar .menu-item {
  padding: 9px 10px !important;
  margin: 0 0 2px 0 !important;
  border-radius: 6px !important;
  font-size: .9rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  border: none !important;
}
.sidebar .menu-item .icon {
  width: 18px !important;
  display: flex !important;
  justify-content: center !important;
}

/* 6. Recents : style compact */
.sidebar-recents {
  margin-top: 20px !important;
  padding: 0 !important;
}
.sidebar-recents-titre {
  font-size: .68rem !important;
  padding: 0 8px 6px !important;
  color: var(--text-3) !important;
}
.recent-item {
  padding: 8px 10px !important;
  border-radius: 6px !important;
  margin-bottom: 1px !important;
}
.recent-titre {
  font-size: .85rem !important;
}

/* 7. Pied de compte : propre, collé en bas */
.sidebar-compte-pied {
  margin-top: auto !important;
  padding: 12px 8px !important;
  border-top: 1px solid var(--line) !important;
  border-radius: 0 !important;
  margin-bottom: 0 !important;
  background: transparent !important;
}
.compte-pied-avatar {
  width: 28px !important;
  height: 28px !important;
  font-size: .8rem !important;
}
.compte-pied-email {
  font-size: .82rem !important;
}
.compte-pied-role {
  font-size: .7rem !important;
}


/* ==========================================================
   LOOK 2026 : Barre de saisie & Réflexion (Claude Style)
   ========================================================== */

/* 1. La barre de saisie (Pill shape, ombre douce, focus lumineux) */
.input-wrapper {
  border-radius: 24px !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  background: var(--bg-elev) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04) !important;
  padding: 6px 8px 6px 16px !important;
  transition: all 0.2s ease !important;
}
.input-wrapper:focus-within {
  border-color: var(--accent) !important;
  box-shadow: 0 4px 20px rgba(62,123,250,0.15), 0 0 0 1px var(--accent) !important;
}
.input-wrapper .send-btn {
  border-radius: 50% !important;
  background: var(--accent) !important;
  color: #fff !important;
  transition: transform 0.1s ease !important;
}
.input-wrapper .send-btn:active {
  transform: scale(0.92) !important;
}

/* 2. Le bloc de réflexion (Léger, aéré, effet glassmorphism) */
.thinking-block {
  background: rgba(240, 244, 249, 0.6) !important;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.04) !important;
  border-radius: 12px !important;
  padding: 10px 14px !important;
  margin-bottom: 16px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02) !important;
}
.thinking-block .thinking-header {
  color: var(--text-2) !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  letter-spacing: -0.01em !important;
  padding: 0 !important;
}
.thinking-block .thinking-header svg:first-child {
  color: var(--accent) !important; /* L'icône sparkle en bleu signature */
  opacity: 0.9;
}
.thinking-block .thinking-content {
  border-left: 2px solid rgba(62,123,250,0.2) !important;
  margin-left: 6px !important;
  padding-left: 12px !important;
  margin-top: 10px !important;
  color: var(--text-3) !important;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
}

/* Adaptation Mode Sombre */
body.dark .input-wrapper {
  background: var(--bg-soft) !important;
  border-color: rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2) !important;
}
body.dark .thinking-block {
  background: rgba(30, 33, 74, 0.4) !important;
  border-color: rgba(255,255,255,0.05) !important;
}

/* ==========================================================
   LOOK 2026 : Le S qui respire & Barre de saisie épurée
   ========================================================== */

/* 1. LE S QUI RESPIRE (Animation organique style Anthropic) */
.s-thinking {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  margin-right: 2px;
  animation: breatheS 2.5s ease-in-out infinite;
}

@keyframes breatheS {
  0% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; text-shadow: 0 0 10px rgba(62,123,250,0.4); }
  100% { transform: scale(1); opacity: 0.7; }
}

/* 2. LE CADRE DE REFLEXION (Ultra épuré) */
.thinking-block {
  background: transparent !important; /* Plus de fond coloré moche */
  border: none !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  margin-bottom: 12px !important;
  box-shadow: none !important;
}
.thinking-block .thinking-header {
  color: var(--text-3) !important;
  font-size: 0.85rem !important;
  font-weight: 400 !important;
  gap: 8px !important;
}
.thinking-block .thinking-content {
  border-left: none !important; /* On enlève la barre bleue */
  padding-left: 24px !important; /* On aligne sous le S */
  color: var(--text-3) !important;
  font-size: 0.85rem !important;
  font-style: italic;
}

/* 3. LA BARRE DE SAISIE (Zéro contour bleu agressif, focus subtil) */
.input-wrapper {
  border-radius: 24px !important;
  border: 1px solid rgba(0,0,0,0.06) !important;
  background: #FFFFFF !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02) !important;
  transition: all 0.3s ease !important;
}
/* Quand on clique dedans, on ne met pas de bleu, on fait juste une ombre douce */
.input-wrapper:focus-within {
  border-color: rgba(0,0,0,0.1) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06) !important;
  background: #FFFFFF !important;
}

body.dark .input-wrapper {
  background: #1A1E30 !important;
  border-color: rgba(255,255,255,0.08) !important;
}
body.dark .input-wrapper:focus-within {
  border-color: rgba(255,255,255,0.15) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
  background: #1A1E30 !important;
}

/* ==========================================================
   LOOK 2026 : Input Area Epurée & Menu Popover
   ========================================================== */

/* 1. La barre de saisie (Pill shape propre) */
.input-wrapper {
  border-radius: 24px !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  background: #FFFFFF !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03) !important;
  padding: 6px 8px 6px 8px !important;
  transition: border-color 0.2s ease !important;
}
.input-wrapper:focus-within {
  border-color: rgba(0,0,0,0.15) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06) !important;
}
body.dark .input-wrapper {
  background: #1A1E30 !important;
  border-color: rgba(255,255,255,0.1) !important;
}

/* 2. Le bouton Trombone */
#btn-plus-menu {
  color: var(--text-3) !important;
  transition: all 0.2s ease !important;
}
#btn-plus-menu:hover {
  background: rgba(0,0,0,0.04) !important;
  color: var(--text) !important;
}

/* 3. Le Menu Popover */
.plus-menu {
  position: absolute !important;
  bottom: 100% !important;
  left: 0 !important;
  margin-bottom: 12px !important;
  background: #FFFFFF !important;
  border: 1px solid rgba(0,0,0,0.06) !important;
  border-radius: 16px !important;
  padding: 8px !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08) !important;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
}
.plus-menu.open { display: flex !important; }

.plus-menu button {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-align: left !important;
  transition: background 0.15s ease !important;
}
.plus-menu button:hover {
  background: rgba(0,0,0,0.04) !important;
}
.plus-menu button svg {
  color: var(--text-3) !important;
}

/* 4. Les options à l'intérieur du menu (Réflexion / Recherche) */
.menu-option {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  background: transparent !important;
  border: none !important;
  width: 100% !important;
}
.menu-option:hover {
  background: rgba(0,0,0,0.04) !important;
}

/* L'indicateur ON/OFF */
.dot-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D1D5DB;
  transition: background 0.2s;
}
.menu-option.active .dot-state {
  background: #3E7BFA;
  box-shadow: 0 0 8px rgba(62,123,250,0.4);
}

/* Mode sombre */
body.dark .plus-menu {
  background: #1A1E30 !important;
  border-color: rgba(255,255,255,0.08) !important;
}
body.dark .plus-menu button:hover, body.dark .menu-option:hover {
  background: rgba(255,255,255,0.06) !important;
}
body.dark .dot-state { background: #4B5563; }

/* ==========================================================
   MENU 2026 : Toggles iOS & Popover Propre
   ========================================================== */

/* Le menu global */
.plus-menu {
  background: #FFFFFF !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  box-shadow: 0 12px 48px rgba(0,0,0,0.12) !important;
  border-radius: 16px !important;
  padding: 8px !important;
  backdrop-filter: none !important;
}

/* La ligne séparatrice */
.menu-divider {
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: 6px 4px;
}

/* Tous les boutons du menu */
.plus-menu button {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px !important;
  border-radius: 10px !important;
  color: #1A1A1A !important;
  font-size: 0.95rem !important;
  font-weight: 500 !important;
  transition: background 0.15s !important;
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  cursor: pointer !important;
}
.plus-menu button:hover {
  background: rgba(0,0,0,0.04) !important;
}
.plus-menu button svg {
  color: #6B7280 !important;
}

/* Le VRAI Toggle Switch (Style iOS) */
.toggle-switch {
  width: 44px;
  height: 24px;
  background: #E5E7EB;
  border-radius: 24px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}
.toggle-switch.active {
  background: #3E7BFA;
}
.toggle-switch.active::after {
  transform: translateX(20px);
}

/* Mode sombre */
body.dark .plus-menu {
  background: #1A1E30 !important;
  border-color: rgba(255,255,255,0.1) !important;
}
body.dark .menu-divider { background: rgba(255,255,255,0.08); }
body.dark .plus-menu button { color: #F6F4EE !important; }
body.dark .plus-menu button:hover { background: rgba(255,255,255,0.06) !important; }
body.dark .plus-menu button svg { color: #9CA3AF !important; }
body.dark .toggle-switch { background: #374151; }

/* ==========================================================
   BOUTON ENVOYER 2026 (ChatGPT / Claude Style)
   ========================================================== */

#sendBtn {
  background: transparent !important;
  color: #C7C7CC !important;
  border: none !important;
  box-shadow: none !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
}

/* Quand l'utilisateur tape du texte (classe ajoutee par JS) */
#sendBtn.has-text {
  background: #3E7BFA !important; /* Le bleu Sophia */
  color: #FFFFFF !important;
}

body.dark #sendBtn { color: #4A4A52 !important; }
body.dark #sendBtn.has-text { background: #3E7BFA !important; color: #fff !important; }

/* Mode sombre */
body.dark .message .actions-toggle { color: #8A8A92 !important; }
body.dark .message .actions-toggle:hover { background: rgba(255,255,255,0.06) !important; color: #F6F4EE !important; }
body.dark .message .actions-menu {
  background: #1A1E30;
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
body.dark .message .actions-menu button { color: #F6F4EE !important; }
body.dark .message .actions-menu button:hover { background: rgba(255,255,255,0.06) !important; }
body.dark .message .actions-menu button svg { color: #9CA3AF !important; }

/* Le bouton "..." (créé par notre script JS plus bas) */
.actions-dots-btn {
  background: transparent !important;
  border: none !important;
  color: #8A8A92 !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: background 0.15s !important;
}
.actions-dots-btn:hover {
  background: rgba(0,0,0,0.05) !important;
  color: #1A1A1A !important;
}

/* On cache les anciens boutons et on les transforme en menu */
.message .actions {
  position: relative !important;
  display: flex !important;
  justify-content: flex-end !important;
}

.message .actions button:not(.actions-dots-btn) {
  display: none; /* Cachés par défaut */
}

/* Quand on clique sur "..." on affiche le menu */
.message .actions.open {
  flex-direction: column !important;
  align-items: flex-end !important;
}

.message .actions.open button:not(.actions-dots-btn) {
  display: flex !important;
  align-items: center !important;
  width: auto !important;
  height: auto !important;
  padding: 8px 12px !important;
  background: #FFFFFF !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  border-radius: 8px !important;
  margin-top: 6px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
  color: #1A1A1A !important;
  font-size: 0.85rem !important;
  gap: 8px !important;
}

/* Mode sombre */
body.dark .message .actions.open button:not(.actions-dots-btn) {
  background: #1A1E30 !important;
  border-color: rgba(255,255,255,0.1) !important;
  color: #F6F4EE !important;
}

/* Aligné à droite */
  align-items: center !important;
  gap: 12px !important; /* Espacement entre les icônes */
  margin-top: 12px !important;
  opacity: 1 !important;
}

.message .actions button {
  background: transparent !important;
  border: none !important;
  color: #9AA0A6 !important; /* Gris discret */
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.message .actions button:hover {
  background: rgba(0,0,0,0.05) !important;
  color: #1A1A1A !important;
}

.message .actions button svg {
  width: 16px !important;
  height: 16px !important;
}

/* Mode sombre */
body.dark .message .actions button { color: #8A93A6 !important; }
body.dark .message .actions button:hover { background: rgba(255,255,255,0.06) !important; color: #F6F4EE !important; }

/* Espacement entre les icônes */
  margin-top: 12px !important;
  width: 100% !important;
}

/* L'astuce magique : le 3ème bouton pousse tout le reste à droite */
.message .actions button:nth-child(3) {
  margin-right: auto !important;
}

/* On agrandit un peu les boutons et les icônes */
.message .actions button {
  background: transparent !important;
  border: none !important;
  color: #9AA0A6 !important;
  width: 36px !important;
  height: 36px !important;
  padding: 6px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.message .actions button:hover {
  background: rgba(0,0,0,0.05) !important;
  color: #1A1A1A !important;
}

.message .actions button svg {
  width: 18px !important; /* Icônes plus grandes */
  height: 18px !important;
}

/* Mode sombre */
body.dark .message .actions button { color: #8A93A6 !important; }
body.dark .message .actions button:hover { background: rgba(255,255,255,0.06) !important; color: #F6F4EE !important; }

/* ==========================================================
   ACTIONS DES RÉPONSES : 2 à gauche, 5 à droite (Style Pro)
   ========================================================== */
.message .actions {
  display: flex !important;
  align-items: center !important;
  gap: 2px !important; /* Espacement réduit et propre */
  margin-top: 12px !important;
  width: 100% !important;
  justify-content: flex-start !important;
}

/* C'est ICI que ça se joue : on pousse le 3ème bouton vers la droite */
.message .actions button:nth-child(3) {
  margin-left: auto !important; 
}

/* Taille optimale des boutons */
.message .actions button {
  background: transparent !important;
  border: none !important;
  color: #9AA0A6 !important;
  width: 32px !important;
  height: 32px !important;
  padding: 6px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.message .actions button:hover {
  background: rgba(0,0,0,0.06) !important;
  color: #1A1A1A !important;
}

.message .actions button svg {
  width: 18px !important;
  height: 18px !important;
}

/* Mode sombre */
body.dark .message .actions button { color: #8A93A6 !important; }
body.dark .message .actions button:hover { background: rgba(255,255,255,0.08) !important; color: #F6F4EE !important; }



/* Sur la page decouvrir qui est sombre */
body .nav, body nav {
    background: rgba(14, 16, 36, 0.9) !important;
}

/* ==========================================================
   FIX FINAL : LAYOUT MOBILE & VIGNETTE (Ajout isolé)
   ========================================================== */

/* 1. Le chat prend toute la largeur sur mobile */
@media (max-width: 768px) {
    .main {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
    
    /* La sidebar est cachée par défaut */
    .sidebar {
        transform: translateX(-100%) !important;
        position: fixed !important;
        z-index: 2000 !important;
        box-shadow: none !important;
    }
    
    /* La sidebar glisse par-dessus quand on l'ouvre */
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1) !important;
    }

    /* On cache le menu contextuel qui flottait au milieu */
    .session-actions {
        display: none !important;
    }
}

/* 2. L'image dans le chat devient une petite vignette */

    max-width: 160px !important;
    max-height: 160px !important;
    border-radius: 12px !important;
    margin: 0 0 8px 0 !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
}

/* === CORRECTION LAYOUT MOBILE ET CARTE FICHIER === */
@media (max-width: 768px) {
    .main {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    .chat-area, .bas-fixe {
        width: 100% !important;
        max-width: 100% !important;
    }
}
/* Style pour la carte de fichier dans l'historique */
.carte-fichier-message {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(62, 123, 250, 0.1);
    border: 1px solid rgba(62, 123, 250, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #3E7BFA;
    margin-bottom: 6px;
    font-weight: 500;
}

/* === MENU D'UPLOAD STYLE CAPTURE 2 === */
.plus-menu {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    border-radius: 24px 24px 0 0 !important; /* Bords arrondis en haut */
    padding: 24px !important;
    background: #FFFFFF !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1) !important;
    z-index: 9999 !important;
    max-width: 100% !important;
}

/* La grille de 3 boutons */
.upload-grid {
    display: flex !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 24px !important;
}

.upload-btn {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 16px 8px !important;
    background: #F8F9FA !important;
    border-radius: 16px !important;
    border: none !important;
    color: #1A1A1A !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
}
.upload-btn:hover {
    background: #F0F2F5 !important;
}
.upload-btn svg {
    color: #5F6368 !important;
}
.upload-btn span {
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    text-align: center !important;
}

/* Mode sombre */
body.dark .plus-menu { background: #1A1E30 !important; }
body.dark .upload-btn { background: #23273A !important; color: #F6F4EE !important; }
body.dark .upload-btn svg { color: #B4B7DE !important; }

/* === AJUSTEMENT DU MENU (BOTTOM SHEET) === */

/* 1. Le menu prend 60% max et laisse la barre de saisie */
.plus-menu {
    max-height: 65vh !important; /* Ne dépasse pas 65% de l'écran */
    overflow-y: auto !important;
    padding: 12px 20px 80px 20px !important; /* Marge en bas pour la barre de saisie */
}

/* 2. La petite poignée en haut (Drag Handle) */
.plus-menu::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 0 auto 16px auto;
}

/* 3. Les 3 boutons plus compacts */
.upload-grid {
    margin-bottom: 16px !important;
}
.upload-btn {
    padding: 12px 8px !important;
}
.upload-btn span {
    font-size: 0.75rem !important;
}

/* 4. Les interrupteurs en dessous, bien alignés */
.menu-option {
    padding: 12px !important;
}

/* Mode sombre */
body.dark .plus-menu::before {
    background: #4A4A52;
}

/* === NETTOYAGE DU MENU : Suppression du vide et compacité === */
.plus-menu {
    height: auto !important;
    max-height: none !important;
    padding: 16px 20px 24px 20px !important; /* Marges normales, plus de 80px en bas */
    overflow: visible !important;
}

/* On s'assure que les boutons et les toggles n'ont pas d'espaces bizarres */
.upload-grid {
    margin-bottom: 12px !important;
}

/* On ajoute un peu d'espace entre les toggles */
.menu-option {
    padding: 14px 12px !important;
}

/* === FINITION MENU : Léger, fin, style 2026 === */
.plus-menu {
    padding: 16px 20px 20px 20px !important; /* Moins d'espace en bas */
    background: rgba(255, 255, 255, 0.98) !important; /* Blanc très très légèrement transparent */
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05) !important; /* Ombre plus douce */
}

/* La poignée en haut, plus discrète */
.plus-menu::before {
    width: 32px !important;
    height: 3px !important;
    background: rgba(0, 0, 0, 0.1) !important;
    margin-bottom: 20px !important;
}

/* Les boutons d'upload : plus fins, icônes plus petites */
.upload-grid {
    gap: 8px !important;
    margin-bottom: 16px !important;
}
.upload-btn {
    padding: 14px 8px !important;
    background: #F7F7F9 !important; /* Gris très clair, style Apple */
    border-radius: 12px !important;
}
.upload-btn svg {
    width: 20px !important;
    height: 20px !important;
    margin-bottom: 4px !important;
    color: #5F6368 !important;
}
.upload-btn span {
    font-size: 0.75rem !important;
    font-weight: 400 !important; /* Texte plus fin */
    color: #3C4043 !important;
}

/* Les options (Réflexion, Recherche) plus serrées */
.menu-divider {
    margin: 12px 0 !important;
}
.menu-option {
    padding: 12px 4px !important; /* Pas de padding latéral */
}
.menu-option span {
    font-size: 0.9rem !important;
    font-weight: 400 !important;
}

/* L'interrupteur iOS un peu plus petit */
.toggle-switch {
    width: 38px !important;
    height: 22px !important;
}
.toggle-switch::after {
    width: 18px !important;
    height: 18px !important;
}
.toggle-switch.active::after {
    transform: translateX(16px) !important;
}

/* Mode sombre */
body.dark .plus-menu {
    background: rgba(26, 30, 48, 0.98) !important;
}
body.dark .plus-menu::before {
    background: rgba(255, 255, 255, 0.1) !important;
}
body.dark .upload-btn {
    background: #23273A !important;
}
body.dark .upload-btn svg,
body.dark .upload-btn span {
    color: #B4B7DE !important;
}

/* === MENU DARK PREMIUM 2026 (Le vrai look) === */
.plus-menu {
    background: #121212 !important; /* Fond sombre profond */
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important; /* Bordure fine */
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3) !important;
}

/* Poignée de drag */
.plus-menu::before {
    background: rgba(255, 255, 255, 0.2) !important; 
}

/* Boutons d'upload */
.upload-btn {
    background: #1E1E1E !important; /* Gris très foncé */
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}
.upload-btn:hover {
    background: #2C2C2C !important;
}
.upload-btn svg {
    color: #E0E0E0 !important; /* Icônes blanches */
}
.upload-btn span {
    color: #E0E0E0 !important; /* Texte blanc */
}

/* Ligne séparatrice */
.menu-divider {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Options (Réflexion, Recherche) */
.menu-option span {
    color: #E0E0E0 !important;
}
.menu-option:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Les interrupteurs (Toggles) en mode sombre */
.toggle-switch {
    background: #3A3A3C !important; /* Gris sombre quand éteint */
}
.toggle-switch::after {
    background: #FFFFFF !important;
}
.toggle-switch.active {
    background: #3E7BFA !important; /* Le bleu Sophia reste */
}

/* === MENU BLANC PROPRE (Style DeepSeek / Capture 1) === */

/* 1. Le fond du menu : Blanc pur avec une ombre douce */
.plus-menu {
    background: #FFFFFF !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.08) !important;
}

/* 2. La poignée du haut : gris clair */
.plus-menu::before {
    background: #E5E7EB !important;
}

/* 3. Les 3 boutons (Appareil photo, Album, Document) */
.upload-btn {
    background: #F4F4F5 !important; /* Gris ultra clair */
    border: none !important;
    border-radius: 12px !important;
    padding: 16px 8px !important;
}

/* 4. Les icônes : noires */
.upload-btn svg {
    color: #1A1A1A !important;
    width: 22px !important;
    height: 22px !important;
    margin-bottom: 6px !important;
}

/* 5. Le texte : noir */
.upload-btn span {
    color: #1A1A1A !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
}

/* 6. Les textes du bas (Réflexion, Recherche web) */
.menu-option span {
    color: #1A1A1A !important;
}

/* 7. Les interrupteurs (Toggles) */
.toggle-switch {
    background: #E5E7EB !important;
}
.toggle-switch.active {
    background: #3E7BFA !important;
}

/* === BOUTONS UPLOAD : LE VRAI LOOK DE LA CAPTURE 1 === */

/* 1. On donne un fond gris et des bordures aux 3 boutons */
.upload-btn {
    background: #F4F4F5 !important; /* Le gris clair de DeepSeek */
    border: 1px solid #E5E5E5 !important; /* Bordure subtile pour délimiter */
    border-radius: 12px !important; /* Bords arrondis */
    padding: 20px 10px !important; /* Plus haut pour faire "carte" */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) !important; /* Petite ombre */
    flex: 1 !important;
}

/* 2. On s'assure que la grille prend toute la largeur */
.upload-grid {
    display: flex !important;
    gap: 10px !important;
    width: 100% !important;
    margin-bottom: 20px !important;
}

/* 3. On rend les icônes bien visibles et le texte lisible */
.upload-btn svg {
    color: #111 !important; /* Icône noire profonde */
    width: 24px !important;
    height: 24px !important;
}
.upload-btn span {
    color: #111 !important; /* Texte noir */
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    text-align: center !important;
}

/* 4. On réduit le vide en bas du menu */
.plus-menu {
    padding-bottom: 20px !important; /* Moins d'espace vide */
    height: auto !important; /* On laisse le menu s'adapter au contenu */
}

/* === CONTRASTE BOUTONS UPLOAD (On force le gris) === */
.plus-menu .upload-btn {
    background: #F0F2F5 !important; /* Un gris un peu plus soutenu */
    border: 1px solid #D1D5DB !important; /* Bordure bien visible */
    border-radius: 14px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important; /* Ombre plus marquée */
    padding: 16px 8px !important;
    transition: background 0.2s !important;
}

/* Au survol (ou au clic sur mobile), ça s'assombrit légèrement */
.plus-menu .upload-btn:hover, 
.plus-menu .upload-btn:active {
    background: #E5E7EB !important;
    border-color: #9CA3AF !important;
}

/* On s'assure que les icônes et textes restent bien noirs */
.plus-menu .upload-btn svg {
    color: #1A1A1A !important;
    margin-bottom: 6px !important;
}
.plus-menu .upload-btn span {
    color: #1A1A1A !important;
    font-weight: 500 !important;
}

/* Mode sombre (si jamais tu actives le thème sombre un jour) */
body.dark .plus-menu .upload-btn {
    background: #2A2D35 !important;
    border-color: #3A3D45 !important;
}
body.dark .plus-menu .upload-btn svg,
body.dark .plus-menu .upload-btn span {
    color: #F6F4EE !important;
}

/* CADRAGE STRICT DES IMAGES DANS LE CHAT */

    max-width: 220px !important;
    max-height: 220px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    display: block !important;
    margin: 0 0 8px 0 !important;
}

/* === PASTILLE FICHIER EN ATTENTE (Style 2026) === */
.pastille-fichier {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #F3F4F6 !important; /* Gris très clair */
    border: 1px solid #E5E7EB !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    margin: 0 12px 8px 12px !important;
    font-size: 0.85rem !important;
    color: #1A1A1A !important;
    font-weight: 500 !important;
}
.pastille-fichier-nom {
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
}
.pastille-fichier-croix {
    background: transparent !important;
    border: none !important;
    font-size: 1.2rem !important;
    line-height: 1 !important;
    cursor: pointer !important;
    color: #6B7280 !important;
    padding: 0 4px !important;
    margin-left: 8px !important;
    transition: color 0.2s !important;
}
.pastille-fichier-croix:hover {
    color: #EF4444 !important; /* Rouge au survol */
}

/* Mode sombre */
body.dark .pastille-fichier {
    background: #2A2D35 !important;
    border-color: #3A3D45 !important;
    color: #F6F4EE !important;
}
body.dark .pastille-fichier-croix { color: #9CA3AF !important; }

/* === TAILLE STRICTE DE L'IMAGE (Style DeepSeek) === */

    max-width: 200px !important;
    max-height: 200px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    display: block !important;
    margin: 0 0 8px 0 !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
}

/* Sur mobile, on ajuste un peu */
@media (max-width: 600px) {

        max-width: 180px !important;
        max-height: 180px !important;
    }
}

/* === FIX DÉFINITIF IMAGE & BORDURES === */

/* 1. On force la taille de l'image, peu importe où elle est */

    max-width: 200px !important;
    max-height: 200px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    margin: 0 0 8px 0 !important;
    display: block !important;
}

/* 2. On vire le trait bizarre (bordure) sur les messages qui contiennent des images */

    border-top: none !important;
    border-bottom: none !important;
    padding-top: 0 !important;
}
.message.user {
    border-top: none !important; /* Au cas où */
}

/* 3. On s'assure que la bulle ne fait pas de saut de ligne bizarre */
.message.user .contenu {
    display: flex !important;
    flex-direction: column !important;
}

/* === NETTOYAGE FINAL IMAGE ET MESSAGE === */

    max-width: 180px !important;
    max-height: 180px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    margin: 0 0 8px 0 !important;
    display: block !important;
    border: none !important;
}

/* On tue la ligne bizarre */
.message.user, .message.user .contenu, .message.user .contenu * {
    border-top: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* On s'assure que le conteneur ne casse pas le design */
.message.user .contenu {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
}

/* === CORRECTION FINALE : Image et Trait === */

    max-width: 180px !important;
    max-height: 180px !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    display: block !important;
    margin-bottom: 4px !important;
    border: none !important;
}

/* On supprime toutes les lignes bizarres */
.message, .message.user, .message .contenu {
    border-top: none !important;
    border-bottom: none !important;
}

/* === RÈGLE UNIQUE ET DÉFINITIVE POUR L'IMAGE === */
img.fichier-apercu-img {
    max-width: 180px !important;
    max-height: 180px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    margin: 0 0 8px 0 !important;
    display: block !important;
    border: none !important;
}

/* === Aperçu fichier moderne === */
.pf-carte { position: relative; display: flex; align-items: center; width: fit-content; max-width: calc(100% - 48px); margin: 0 24px 8px 24px; animation: pf-entree .18s ease-out; }
@keyframes pf-entree { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
.pf-img { width: 68px; height: 68px; }
.pf-vignette { width: 68px; height: 68px; object-fit: cover; border-radius: 16px; display: block; border: 1px solid rgba(0,0,0,.06); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.pf-doc { gap: 10px; padding: 8px 14px 8px 8px; background: #f3f4f6; border: 1px solid rgba(0,0,0,.08); border-radius: 16px; }
.pf-doc-icone { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; background: #e5453a; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; justify-content: center; }
.pf-doc-info { display: flex; flex-direction: column; min-width: 0; }
.pf-doc-nom { font-size: 14px; font-weight: 600; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.pf-doc-taille { font-size: 12px; color: #6b7280; margin-top: 2px; }
.pf-croix { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid #fff; background: #111; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
body.dark .pf-doc { background: #2a2b2e; border-color: rgba(255,255,255,.1); }
body.dark .pf-doc-nom { color: #f3f4f6; }
body.dark .pf-doc-taille { color: #9ca3af; }
body.dark .pf-croix { background: #e5e7eb; color: #111; border-color: #1f2023; }

/* Image dans la conversation */
.message img.fichier-apercu-img { max-width: min(240px, 100%) !important; max-height: 300px !important; border-radius: 16px !important; margin: 0 0 8px 0 !important; box-shadow: 0 1px 4px rgba(0,0,0,.15) !important; cursor: zoom-in !important; }
.contenu > img.fichier-apercu-img + br { display: none; }

/* Image compacte dans la conversation (style Gemini) */
.message img.fichier-apercu-img { max-width: 150px !important; max-height: 190px !important; border-radius: 14px !important; margin: 0 0 6px 0 !important; box-shadow: none !important; }

/* Image hors de la bulle, alignée à droite (style Gemini/DeepSeek) */
.message.user.a-image { background: transparent !important; box-shadow: none !important; border: none !important; padding: 0 !important; display: flex !important; flex-direction: column; align-items: flex-end; gap: 6px; }
.message.user.a-image img.fichier-apercu-img { margin: 0 !important; max-width: 140px !important; max-height: 180px !important; border-radius: 14px !important; border: 1px solid rgba(0,0,0,.12) !important; box-shadow: none !important; }
.message.user.a-image .contenu { display: block; background: #f3f4f6; padding: 10px 16px; border-radius: 20px; }
.message.user.a-image.sans-texte .contenu { display: none; }
.message.user.a-image .timestamp { align-self: flex-end; }
body.dark .message.user.a-image img.fichier-apercu-img { border-color: rgba(255,255,255,.15) !important; }
body.dark .message.user.a-image .contenu { background: #2a2b2e; }

/* Suppression du trait de séparation entre les messages */
.message, .message.sophia, .message.user,
.message .actions, .message.sophia .actions,
body.dark .message, body.dark .message .actions {
    border-top: none !important;
    border-bottom: none !important;
}
.message .actions::before, .message .actions::after { display: none !important; }
.message + .message { border-top: none !important; }
#chatArea hr, .chat-area hr, .message hr { display: none !important; }
