@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-void: #04070e;
  --bg-panel: rgba(11, 16, 30, 0.78);
  --bg-elevated: rgba(19, 28, 49, 0.88);
  --bg-glass: rgba(9, 14, 26, 0.76);
  --border-subtle: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.15);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.2);
  --sky: #0ea5e9;
  --indigo: #818cf8;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --active-accent: #10b981;
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

*, ::before, ::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Scrollbars ultra-fines invisibles au repos (Fini les barres blanches Windows !) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.18) transparent;
}
*::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 9999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.5);
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-void);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
  font-family: 'Outfit', sans-serif;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}
button:active {
  transform: scale(0.97);
}

input, select, textarea {
  outline: none;
  background: var(--bg-void);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 16px; /* Anti-zoom iOS strict */
  padding: 0 12px;
  min-height: 44px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
@media (min-width: 768px) {
  input, select, textarea {
    font-size: 13.5px;
    min-height: 38px;
  }
}
input:focus, select:focus, textarea:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-glow);
}

.hidden { display: none !important; }

/* Classes utilitaires Safe Area & Hauteur Viewport (/agent-mobile) */
.pt-safe { padding-top: env(safe-area-inset-top, 0px); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }
.pl-safe { padding-left: env(safe-area-inset-left, 0px); }
.pr-safe { padding-right: env(safe-area-inset-right, 0px); }

.h-mobile-screen {
  height: 100vh;
  height: 100dvh;
}

.modal-scroll-container {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Layout Principal Full-Bleed 100dvh */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Topbar Command Center */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  min-height: 58px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
}
@media (min-width: 768px) {
  .topbar {
    flex-wrap: nowrap;
    gap: 12px;
    padding: 0 16px;
    height: 58px;
  }
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.brand-bolt {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.status-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-pill.live {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}
.status-pill.off {
  background: rgba(244, 63, 94, 0.12);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.35);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.session-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-form-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
}
.login-input {
  width: 100%;
  min-width: 0;
}
@media (min-width: 768px) {
  .login-form-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
  }
  .login-input {
    width: 120px;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
@media (min-width: 768px) {
  .btn {
    min-height: 38px;
    min-width: 0;
    padding: 0 13px;
  }
}
@media (max-width: 767px) {
  .topbar-actions .btn-label,
  .chat-header-actions .btn-label {
    display: none;
  }
  .topbar-actions .btn,
  .chat-header-actions .btn {
    padding: 0 10px;
  }
  .user-pill #currentUserRole {
    display: none;
  }
}

.touch-icon-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .touch-icon-btn {
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
  }
}

@media (min-width: 768px) {
  .mobile-only-btn {
    display: none !important;
  }
}

.btn-emerald {
  background: var(--emerald);
  color: #022c22;
  font-weight: 700;
}
.btn-emerald:hover { background: #34d399; }
.btn-surface {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border-strong);
}
.btn-surface:hover { border-color: var(--emerald); }
.btn-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.btn-sky {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.4);
}

/* Workspace Split 2-Panneaux Fluides */
.workspace {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Colonne Gauche Unique (Zéro empilement de scrollbars !) */
.sidebar {
  width: 100%;
  height: 100%;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
@media (min-width: 768px) {
  .sidebar {
    width: 390px;
  }
}
@media (min-width: 1280px) {
  .sidebar {
    width: 430px;
  }
}

/* Navigation Segmentée dans la Sidebar (Masquée sur mobile au profit de la Bottom Nav Thumb Zone) */
.sidebar-nav {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 12px 6px;
  background: var(--bg-panel);
}
@media (min-width: 768px) {
  .sidebar-nav {
    display: grid;
    gap: 6px;
  }
}

.seg-btn {
  min-height: 48px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
@media (min-width: 768px) {
  .seg-btn {
    min-height: 40px;
  }
}
.seg-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Bottom Navigation Bar Mobile (Thumb Zone < 768px — /agent-mobile) */
.mobile-bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 8px max(8px, env(safe-area-inset-bottom, 8px));
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 25;
}
@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
}
.mob-nav-btn {
  min-height: 48px;
  min-width: 48px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.mob-nav-btn.active {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

/* Filtres Rapides Plateformes */
.filter-strip {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 6px 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) {
  .filter-strip {
    flex-wrap: wrap;
    gap: 5px;
    overflow-x: hidden;
  }
}

.chip {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-void);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .chip {
    min-height: 28px;
    min-width: 0;
    padding: 0 9px;
    font-size: 11px;
  }
}
.chip.active {
  background: var(--emerald-glow);
  color: #34d399;
  border-color: var(--emerald);
}

/* Liste Unique Scrollable dans la Sidebar */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Item de Conversation (Thread Card) */
.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.thread-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.thread-item.unread {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.28);
  border-left: 3.5px solid var(--emerald);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.thread-item.unread.platform-telegram {
  background: rgba(14, 165, 233, 0.07);
  border-color: rgba(14, 165, 233, 0.3);
  border-left-color: var(--sky);
}
.thread-item.unread.platform-discord {
  background: rgba(129, 140, 248, 0.08);
  border-color: rgba(129, 140, 248, 0.32);
  border-left-color: var(--indigo);
}
.thread-item.unread.platform-sms {
  background: rgba(245, 158, 11, 0.07);
  border-color: rgba(245, 158, 11, 0.3);
  border-left-color: var(--amber);
}
.thread-item.unread .thread-name {
  font-weight: 800;
  color: #ffffff;
}
.thread-item.unread .thread-preview {
  color: #e2e8f0;
  font-weight: 600;
}
.thread-item.unread .avatar-circle {
  border-color: var(--emerald);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.22);
}
.thread-item.active {
  background: rgba(16, 185, 129, 0.14);
  border-color: var(--emerald);
}

.unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  color: #34d399;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.unread-divider::before,
.unread-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.5), transparent);
}

.msg-row.is-new-unread .msg-bubble {
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.16);
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  position: relative;
}

.platform-dot {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--bg-panel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.platform-dot svg {
  width: 11px;
  height: 11px;
}
.dot-whatsapp { background: var(--emerald); color: #022c22; }
.dot-telegram { background: var(--sky); color: #082f49; }
.dot-discord { background: var(--indigo); color: #1e1b4b; }
.dot-sms { background: var(--amber); color: #451a03; }

.thread-body {
  flex: 1;
  min-width: 0;
}

.thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.thread-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.platform-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 7px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.platform-tag svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.tag-whatsapp { background: rgba(16, 185, 129, 0.14); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.tag-telegram { background: rgba(14, 165, 233, 0.14); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.25); }
.tag-discord { background: rgba(129, 140, 248, 0.14); color: #a5b4fc; border: 1px solid rgba(129, 140, 248, 0.25); }
.tag-sms { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }

.unread-pill {
  background: currentColor;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}
.tag-whatsapp .unread-pill { background: #10b981; color: #022c22; }
.tag-telegram .unread-pill { background: #0ea5e9; color: #082f49; }
.tag-discord .unread-pill { background: #818cf8; color: #1e1b4b; }
.tag-sms .unread-pill { background: #f59e0b; color: #451a03; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  height: 36px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 12.5px;
  font-weight: 600;
  color: #34d399;
  white-space: nowrap;
}
.user-role-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.svg-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.thread-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

/* Panneau Principal de Conversation (Stage Droite) */
.chat-stage {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--active-accent) 14%, transparent), transparent 62%),
    radial-gradient(circle at 85% 90%, rgba(14, 165, 233, 0.06), transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, transparent 100%),
    var(--bg-void);
  position: relative;
  overflow: hidden;
  transition: background 0.4s ease;
}

@media (max-width: 767px) {
  .workspace.mobile-chat-open .sidebar {
    display: none;
  }
  .workspace:not(.mobile-chat-open) .chat-stage {
    display: none;
  }
}

.chat-header {
  min-height: 62px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}
@media (min-width: 768px) {
  .chat-header {
    height: 62px;
    padding: 0 18px;
    gap: 12px;
  }
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .chat-header-actions {
    gap: 6px;
  }
}

/* Scène 3D WebGL Interactive (/agent-3d) — Nexus de Mutualisation */
.empty-stage-3d {
  position: absolute;
  inset: 62px 0 72px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 3;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.empty-stage-3d.in-background {
  opacity: 0.16;
  pointer-events: none;
  z-index: 1;
}
.empty-stage-3d.in-background .nexus-hero-badge,
.empty-stage-3d.in-background .nexus-hud-footer,
.empty-stage-3d.in-background .orb-Hud-pill {
  display: none !important;
}

.nexus-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.15);
  margin-bottom: 6px;
}
.nexus-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: nexusPulse 2s infinite;
}
@keyframes nexusPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.55; }
}

.nexus-3d-orbital-wrap {
  position: relative;
  width: min(310px, calc(100vw - 32px));
  height: min(310px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-height: 740px) {
  .nexus-3d-orbital-wrap {
    width: 230px;
    height: 230px;
  }
}

#mux3dCanvas {
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: grab;
  filter: drop-shadow(0 0 28px rgba(16, 185, 129, 0.18));
}

.orb-Hud-pill {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(11, 16, 30, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  z-index: 4;
}
@media (min-width: 768px) {
  .orb-Hud-pill {
    min-height: 34px;
    padding: 6px 11px;
  }
}
.orb-Hud-pill:hover,
.orb-Hud-pill.is-pulsing {
  transform: translateY(-2px) scale(1.05);
  border-color: var(--emerald);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}
.orb-pos-tl { top: 8px; left: 0px; }
.orb-pos-tr { top: 8px; right: 0px; }
.orb-pos-bl { bottom: 12px; left: 0px; }
.orb-pos-br { bottom: 12px; right: 0px; }
@media (min-width: 768px) {
  .orb-pos-tl { top: 14px; left: -24px; }
  .orb-pos-tr { top: 14px; right: -24px; }
  .orb-pos-bl { bottom: 20px; left: -28px; }
  .orb-pos-br { bottom: 20px; right: -28px; }
}

.orb-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.orb-state {
  font-size: 9.5px;
  color: var(--text-secondary);
  padding-left: 4px;
  border-left: 1px solid var(--border-subtle);
}

.nexus-hud-footer {
  max-width: 520px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.nexus-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nexus-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 440px;
}
.nexus-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 2px;
}
.nexus-kpi-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.kpi-val {
  font-size: 17px;
  font-weight: 700;
  color: #34d399;
}
.kpi-lbl {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.nexus-cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Flux des Messages */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}
@media (min-width: 768px) {
  .messages-viewport {
    padding: 18px 20px;
  }
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
@media (max-width: 767px) {
  .msg-row { max-width: 88%; }
}
.msg-row.from-me {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-row.from-them {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  word-break: break-word;
  border: 1px solid var(--border-subtle);
}
.msg-row.from-me .msg-bubble {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  border-color: rgba(52, 211, 153, 0.3);
}
.msg-row.from-them .msg-bubble {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* Barre de Réponse Multimédia Sticky Bottom */
.composer-bar {
  padding: 10px 12px max(12px, env(safe-area-inset-bottom, 12px));
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  position: relative;
}
@media (min-width: 768px) {
  .composer-bar {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

.picker-popover {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  height: 62dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 65;
}
@media (min-width: 768px) {
  .picker-popover {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 16px;
    right: auto;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 350px;
    border-radius: 16px;
    padding-top: 0;
    padding-bottom: 0;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    z-index: 35;
  }
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
@media (min-width: 768px) {
  .emoji-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
  }
}

.emoji-cell {
  min-height: 48px;
  min-width: 44px;
  border-radius: 10px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 768px) {
  .emoji-cell {
    min-height: 36px;
    min-width: 36px;
    font-size: 20px;
    border-radius: 8px;
  }
}
.emoji-cell:hover {
  background: var(--bg-elevated);
  transform: scale(1.15);
}

.gif-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.gif-cell {
  position: relative;
  height: 105px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-void);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}
.gif-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gif-cell:hover {
  border-color: var(--emerald);
}

.composer-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.composer-tools {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.composer-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
@media (min-width: 768px) {
  .composer-controls {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .composer-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
  }
  .composer-input-row {
    flex: 1;
    min-width: 0;
  }
}

.icon-btn {
  min-width: 44px;
  min-height: 48px;
  border-radius: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .icon-btn {
    min-height: 44px;
  }
}
.icon-btn:hover {
  border-color: var(--emerald);
}
.icon-btn.recording {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--rose);
  color: #fb7185;
}

/* Modales & Bottom Sheets (/agent-mobile) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(8px);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 768px) {
  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.38);
  margin: 2px auto 12px;
  flex-shrink: 0;
  cursor: grab;
}
@media (min-width: 768px) {
  .sheet-handle {
    display: none;
  }
}

.sheet-modal {
  width: 100%;
  max-width: 1080px;
  max-height: 90dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 14px 16px max(20px, env(safe-area-inset-bottom, 20px));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  transition: transform 0.22s ease;
}
@media (min-width: 768px) {
  .sheet-modal {
    border-radius: 18px;
    padding: 20px;
  }
}

.tuto-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
@media (min-width: 720px) {
  .tuto-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1180px) {
  .tuto-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.tuto-card {
  background: var(--bg-void);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  min-width: 0;
  overflow: hidden;
}

/* Réactions Natives sur les Messages */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.38);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
@media (min-width: 768px) {
  .reaction-chip {
    min-height: 26px;
    min-width: 0;
    padding: 2px 7px;
    font-size: 13px;
  }
}
.reaction-chip:hover {
  transform: scale(1.08);
  background: rgba(16, 185, 129, 0.28);
}
.quick-react-bar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 8px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.quick-react-btn {
  min-width: 40px;
  min-height: 40px;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
@media (min-width: 768px) {
  .quick-react-btn {
    min-width: 30px;
    min-height: 30px;
    font-size: 15px;
    padding: 2px 5px;
  }
}
.quick-react-btn:hover {
  transform: scale(1.22);
  background: rgba(255, 255, 255, 0.08);
}
