    :root {
      --safe-top: env(safe-area-inset-top, 0px);
      --safe-bottom: env(safe-area-inset-bottom, 0px);

      --bg: #eef3f9;
      --bg2: #f7faff;
      --panel: rgba(255, 255, 255, 0.92);
      --panel-strong: rgba(255, 255, 255, 0.97);
      --panel-soft: #f8fbff;
      --panel-glow: rgba(255,255,255,0.55);
      --border: #dbe6f3;
      --border-strong: #cad8eb;
      --text: #17324d;
      --muted: #6d7f97;
      --primary: #1e4d99;
      --primary-2: #2f6ef0;
      --primary-soft: #edf4ff;
      --success: #1ea463;
      --warning: #d58b00;
      --danger: #d64045;
      --shadow: 0 18px 50px rgba(27, 60, 108, 0.10);
      --shadow-soft: 0 10px 24px rgba(27, 60, 108, 0.07);
      --shadow-card: 0 8px 20px rgba(27, 60, 108, 0.06);
      --radius-xl: 28px;
      --radius-lg: 22px;
      --radius-md: 18px;
      --radius-sm: 14px;
      --surface-dark: #0f1724;
      --surface-dark-border: #223149;
      --surface-dark-text: #e8eef9;
      --transition: 180ms ease;
    }

    html[data-theme="dark"] {
      --bg: #0d1623;
      --bg2: #111d2e;
      --panel: rgba(20, 31, 47, 0.88);
      --panel-strong: rgba(20, 31, 47, 0.95);
      --panel-soft: #162335;
      --panel-glow: rgba(255,255,255,0.03);
      --border: #27384e;
      --border-strong: #304664;
      --text: #edf4ff;
      --muted: #97a8bf;
      --primary: #7db0ff;
      --primary-2: #5a92f1;
      --primary-soft: #19304f;
      --success: #3bd18a;
      --warning: #f0b23a;
      --danger: #ff7075;
      --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
      --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.20);
      --shadow-card: 0 8px 20px rgba(0,0,0,0.18);
      --surface-dark: #0a1320;
      --surface-dark-border: #2a3c52;
      --surface-dark-text: #edf4ff;
    }

    * {
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    html, body {
      margin: 0;
      padding: 0;
      min-height: 100%;
      font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at top left, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 38%),
        linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
    }

    body {
      overflow: hidden;
    }

    button, input, textarea {
      font: inherit;
    }

    .messages,
    .dock-panel,
    .sidebar,
    .snapshot-box {
      scrollbar-width: thin;
      scrollbar-color: rgba(125, 176, 255, 0.24) transparent;
    }

    .messages::-webkit-scrollbar,
    .dock-panel::-webkit-scrollbar,
    .sidebar::-webkit-scrollbar,
    .snapshot-box::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    .messages::-webkit-scrollbar-track,
    .dock-panel::-webkit-scrollbar-track,
    .sidebar::-webkit-scrollbar-track,
    .snapshot-box::-webkit-scrollbar-track {
      background: transparent;
    }

    .messages::-webkit-scrollbar-thumb,
    .dock-panel::-webkit-scrollbar-thumb,
    .sidebar::-webkit-scrollbar-thumb,
    .snapshot-box::-webkit-scrollbar-thumb {
      background: rgba(125, 176, 255, 0.22);
      border-radius: 999px;
      border: 2px solid transparent;
      background-clip: padding-box;
    }

    .messages::-webkit-scrollbar-thumb:hover,
    .dock-panel::-webkit-scrollbar-thumb:hover,
    .sidebar::-webkit-scrollbar-thumb:hover,
    .snapshot-box::-webkit-scrollbar-thumb:hover {
      background: rgba(125, 176, 255, 0.38);
      border: 2px solid transparent;
      background-clip: padding-box;
    }

    .app-shell {
height: 100dvh; /* Force l'app à occuper exactement la hauteur visible, dynamique */
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  /* On s'assure que le grid ne déborde pas */
  overflow: hidden;
    }

    .sidebar,
    .main-panel,
    .dock-panel,
    .modal-card {
      background: var(--panel);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid rgba(255,255,255,0.18);
      box-shadow: var(--shadow);
      border-radius: var(--radius-xl);
    }

    .sidebar {
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      gap: 14px;
      padding: 16px;
      overflow: auto;
      position: relative;
    }

    .sidebar::before,
    .main-panel::before {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      border-radius: inherit;
      background: linear-gradient(180deg, var(--panel-glow) 0%, transparent 24%);
      opacity: 0.8;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 2px 4px 14px;
      border-bottom: 1px solid var(--border);
      position: relative;
      z-index: 1;
    }

    .brand-logo {
      width: 56px;
      height: 56px;
      border-radius: 16px;
      object-fit: contain;
      background: #fff;
      border: 1px solid var(--border);
      padding: 6px;
      flex: 0 0 auto;
      box-shadow: var(--shadow-soft);
    }

    .brand h1 {
      margin: 0;
      font-size: 1.34rem;
      line-height: 1;
      color: var(--primary);
      white-space: nowrap;
      letter-spacing: -0.02em;
    }

    .brand p {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 0.92rem;
    }

    .card {
      background: linear-gradient(180deg, var(--panel-strong) 0%, var(--panel) 100%);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 14px;
      box-shadow: var(--shadow-card);
      position: relative;
      z-index: 1;
      transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    }

    .card:hover {
      transform: translateY(-1px);
      box-shadow: var(--shadow-soft);
      border-color: var(--border-strong);
    }

    .card-title {
      margin: 0 0 12px;
      font-size: 0.8rem;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
    }

    .assistant-card {
      text-align: center;
    }

    .avatar-card {
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 22px;
      padding: 12px;
      display: flex;
      justify-content: center;
      align-items: center;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
    }

    .assistant-figure {
      width: 100%;
      max-width: 132px;
      aspect-ratio: 3 / 5;
      border-radius: 18px;
      background: #ffffff;
      display: grid;
      place-items: center;
      position: relative;
      overflow: hidden;
    }

    .assistant-figure img {
      width: 78%;
      height: auto;
      object-fit: contain;
      display: block;
      background: #ffffff;
      border-radius: 12px;
    }

    .pulse-dot {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 11px;
      height: 11px;
      border-radius: 999px;
      background: var(--success);
      box-shadow: 0 0 0 0 rgba(30,164,99,0.5);
      animation: pulse 1.8s infinite;
    }

    @keyframes pulse {
      0% { box-shadow: 0 0 0 0 rgba(30,164,99,0.5); }
      70% { box-shadow: 0 0 0 12px rgba(30,164,99,0); }
      100% { box-shadow: 0 0 0 0 rgba(30,164,99,0); }
    }

    .chip-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .chip {
      border-radius: 999px;
      padding: 7px 11px;
      font-weight: 700;
      font-size: 0.84rem;
      border: 1px solid transparent;
      background: var(--primary-soft);
      color: var(--primary);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
      white-space: nowrap;
    }

    .chip.success {
      background: rgba(30,164,99,0.10);
      color: var(--success);
      border-color: rgba(30,164,99,0.18);
    }

    .chip.warning {
      background: rgba(213,139,0,0.10);
      color: var(--warning);
      border-color: rgba(213,139,0,0.18);
    }

    .chip.danger {
      background: rgba(214,64,69,0.10);
      color: var(--danger);
      border-color: rgba(214,64,69,0.18);
    }

    .atelier-kpis {
      display: grid;
      gap: 10px;
    }

    .kpi-box {
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      border-radius: 18px;
      padding: 12px 14px;
      position: relative;
      overflow: hidden;
      transition: transform var(--transition), border-color var(--transition), background var(--transition);
    }

    .kpi-box::after {
      content: "";
      position: absolute;
      inset: auto 0 0 0;
      height: 2px;
      background: linear-gradient(90deg, transparent, var(--primary), transparent);
      opacity: 0.25;
    }

    .kpi-box:hover {
      transform: translateY(-1px);
      border-color: var(--border-strong);
    }

    .kpi-label {
      font-size: 0.74rem;
      color: var(--muted);
      margin-bottom: 6px;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      font-weight: 800;
    }

    .kpi-value {
      font-size: 1.5rem;
      line-height: 1;
      font-weight: 800;
      letter-spacing: -0.03em;
    }

    .kpi-sub {
      margin-top: 6px;
      font-size: 0.86rem;
      color: var(--muted);
    }

    .status-list {
      display: grid;
      gap: 10px;
    }

    .status-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      font-size: 0.95rem;
    }

    .status-left {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .status-dot {
      width: 10px;
      height: 10px;
      border-radius: 999px;
      flex: 0 0 auto;
    }

    .status-dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(30,164,99,0.45); }
    .status-dot.warn { background: var(--warning); box-shadow: 0 0 8px rgba(213,139,0,0.35); }
    .status-dot.danger { background: var(--danger); box-shadow: 0 0 8px rgba(214,64,69,0.30); }
    .status-dot.off { background: #7e90a8; }

    .status-value {
      color: var(--primary);
      font-weight: 700;
      font-size: 0.92rem;
      white-space: nowrap;
    }

    .config-card input,
    .dock-input {
      width: 100%;
      border-radius: 16px;
      border: 1px solid var(--border);
      padding: 12px 14px;
      outline: none;
      background: rgba(255,255,255,0.05);
      color: var(--text);
      margin-bottom: 10px;
      transition: border-color var(--transition), box-shadow var(--transition);
    }

    .config-card input:focus,
    .dock-input:focus,
    .composer textarea:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(47,110,240,0.12);
    }

    .btn-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .btn {
      border: 0;
      border-radius: 16px;
      padding: 12px 14px;
      font-weight: 800;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), filter var(--transition);
      text-decoration: none;
    }

    .btn:hover {
      transform: translateY(-1px);
      filter: brightness(1.03);
    }

    .btn:active { transform: translateY(0); }

    .btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
      transform: none;
    }

    .btn.primary {
      background: linear-gradient(180deg, var(--primary-2) 0%, var(--primary) 100%);
      color: #fff;
      box-shadow: 0 12px 24px rgba(31,75,153,0.24);
    }

    .btn.secondary {
      background: rgba(255,255,255,0.06);
      color: var(--primary);
      border: 1px solid var(--border);
    }

    .btn.ghost {
      background: var(--primary-soft);
      color: var(--primary);
      border: 1px solid var(--border);
    }

    .main-panel {
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      height: calc(100dvh - 36px);
      position: relative;
    }

    .main-header {
      padding: 18px 24px 14px;
      border-bottom: 1px solid var(--border);
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 14px;
      flex: 0 0 auto;
      background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
      position: relative;
      z-index: 1;
    }

    .main-header-left {
      min-width: 0;
    }

    .main-header h2 {
      margin: 0;
      font-size: 2.15rem;
      line-height: 1.02;
      letter-spacing: -0.04em;
      color: var(--primary);
    }

    .main-header p {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 0.98rem;
    }

    .main-header-right {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .theme-toggle {
      width: 46px;
      height: 46px;
      border-radius: 999px;
      padding: 0;
      font-size: 1.05rem;
      flex: 0 0 auto;
    }

    .hero-summary {
      padding: 14px 24px;
      border-bottom: 1px solid var(--border);
      display: grid;
      gap: 10px;
      flex: 0 0 auto;
      position: relative;
      z-index: 1;
    }

    .hero-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
    }

    .hero-title strong {
      font-size: 1rem;
      letter-spacing: -0.01em;
    }

    .chat-area {
display: flex;
  flex-direction: column;
  flex: 1; /* Prend tout l'espace disponible mais pas plus */
  overflow: hidden; /* Empêche tout débordement global */
    }

    .messages {
flex: 1;
  overflow-y: auto; /* Le scroll se fait uniquement ici */
    }

    .bubble {
      max-width: 84%;
      border-radius: 22px;
      padding: 16px 18px;
      border: 1px solid var(--border);
      line-height: 1.55;
      font-size: 1.04rem;
      white-space: pre-wrap;
      box-shadow: var(--shadow-soft);
      word-break: break-word;
      overflow-wrap: anywhere;
      animation: bubbleIn 220ms ease;
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-width: 0;
    }

    @keyframes bubbleIn {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .bubble.assistant {
      margin-left: 5px; /* Décolle légèrement du bord gauche */
      margin-right: 12%; /* Force un espace à droite pour les messages de l'IA */
      justify-self: start;
      background: linear-gradient(180deg, rgba(125,176,255,0.10) 0%, rgba(125,176,255,0.04) 100%);
    }

    .bubble.user {
      margin-right: 5px; /* Décolle légèrement du bord droit */
      margin-left: 12%; /* Force un espace à gauche pour les messages utilisateur */
      justify-self: end;
      background: rgba(255,255,255,0.06);
      color: var(--primary);
      font-weight: 700;
    }

    .bubble.error {
      background: rgba(214,64,69,0.10);
      border-color: rgba(214,64,69,0.24);
      color: var(--danger);
    }

    .bubble.thinking {
      background: rgba(255,255,255,0.04);
      color: var(--muted);
      border-style: dashed;
      display: inline-flex;
      align-items: center;
      gap: 12px;
      min-width: 220px;
      max-width: 330px;
      white-space: normal;
      padding: 12px 16px;
    }

    .bubble-card-title {
      display: block;
      margin: 0;
      font-size: 0.82rem;
      text-transform: uppercase;
      color: var(--muted);
      font-weight: 800;
      letter-spacing: 0.06em;
      line-height: 1.1;
      flex: 0 0 auto;
    }

    .bubble-body {
      display: block;
      width: 100%;
      min-width: 0;
      white-space: pre-wrap;
    }

    .thinking-inline {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
    }

    .thinking-label {
      font-weight: 700;
      color: var(--primary);
      white-space: nowrap;
    }

    .thinking-dots {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .thinking-dots span {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: var(--primary);
      opacity: 0.25;
      display: inline-block;
      animation: thinking 1.2s infinite ease-in-out;
    }

    .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
    .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

    @keyframes thinking {
      0%, 80%, 100% { transform: scale(0.8); opacity: 0.25; }
      40% { transform: scale(1.15); opacity: 1; }
    }

    .typing-cursor::after {
      content: "";
      display: inline-block;
      width: 2px;
      height: 1em;
      margin-left: 4px;
      vertical-align: -2px;
      background: var(--primary);
      animation: blinkCursor 0.9s infinite;
    }

    @keyframes blinkCursor {
      0%, 50% { opacity: 1; }
      50.01%, 100% { opacity: 0; }
    }

    .quick-actions {
      padding: 8px 24px 0;
      display: flex;
      gap: 8px;
      flex: 0 0 auto;
      min-width: 0;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-x;
      scrollbar-width: none;
      margin-bottom: 10px;
      position: relative;
      z-index: 1;
      cursor: grab;
      user-select: none;
      flex-wrap: nowrap;
    }

    .quick-actions:active {
      cursor: grabbing;
    }

    .quick-actions::-webkit-scrollbar {
      display: none;
    }

    .quick-btn {
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.05);
      color: var(--primary);
      border-radius: 999px;
      padding: 10px 13px;
      font-weight: 800;
      cursor: pointer;
      font-size: 0.92rem;
      box-shadow: var(--shadow-soft);
      white-space: nowrap;
      flex: 0 0 auto;
      transition: transform var(--transition), border-color var(--transition), background var(--transition);
    }

    .quick-btn:hover {
      transform: translateY(-1px);
      border-color: var(--border-strong);
      background: rgba(255,255,255,0.08);
    }

    .composer {
padding: 12px 24px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
  
  /* --- NOUVEAUX RÉGLAGES POUR ANCRAGE --- */
  background: var(--panel); /* Force le fond pour cacher les messages dessous */
  position: relative;
  z-index: 5; /* Assure qu'il passe au-dessus des messages si besoin */
  flex-shrink: 0; /* Empêche le bloc de rétrécir si la zone de chat grandit */
  margin-top: auto; /* Pousse le bloc vers le bas si le parent est en flex */
    }

    .composer textarea {
      width: 100%;
      min-height: 72px;
      max-height: 120px;
      resize: none;
      border-radius: 20px;
      border: 1px solid var(--border);
      padding: 14px 16px;
      outline: none;
      background: rgba(255,255,255,0.05);
      color: var(--text);
      transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    }

    .composer-bottom {
      display: grid;
      gap: 10px;
    }

    .composer-actions-main {
      display: flex;
      gap: 10px;
      width: 100%;
      min-width: 0;
    }

    .composer-actions-main .btn {
      flex: 1 1 0;
      min-height: 48px;
    }

    .dock-panel {
      position: fixed;
      right: 0;
      top: 0;
      bottom: 0;
      width: min(92vw, 430px);
      background: var(--panel-strong);
      border-left: 1px solid var(--border);
      box-shadow: -12px 0 30px rgba(20,40,75,0.12);
      z-index: 40;
      transform: translateX(100%);
      transition: transform 0.28s ease;
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      overflow: auto;
      border-radius: 0;
      min-width: 0;
    }

    .dock-panel.open {
      transform: translateX(0);
    }

    .dock-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }

    .dock-title {
      margin: 0;
      font-size: 0.95rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
      font-weight: 800;
    }

    .question-grid {
      display: grid;
      gap: 12px;
    }

    .question-card {
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      border-radius: 18px;
      padding: 14px;
      display: grid;
      gap: 12px;
      box-shadow: var(--shadow-soft);
      transition: transform var(--transition), border-color var(--transition);
    }

    .question-card:hover {
      transform: translateY(-1px);
      border-color: var(--border-strong);
    }

    .question-text {
      font-weight: 700;
      line-height: 1.4;
    }

    .question-actions {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }

    .question-actions .btn {
      padding: 11px 12px;
      font-size: 0.9rem;
      border-radius: 14px;
    }

    .drawer-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(19,38,62,0.34);
      z-index: 39;
    }

    .drawer-overlay.open {
      display: block;
    }

    .modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(19,38,62,0.45);
      z-index: 50;
      padding: 20px;
      align-items: center;
      justify-content: center;
    }

    .modal.open {
      display: flex;
    }

    .modal-card {
      width: min(980px, 100%);
      max-height: 85vh;
      overflow: auto;
      padding: 20px;
    }

    .modal-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      margin-bottom: 14px;
    }

    .modal-head h3 {
      margin: 0;
      color: var(--primary);
      font-size: 1.35rem;
    }

    .snapshot-box {
      background: var(--surface-dark);
      color: var(--surface-dark-text);
      border-radius: 18px;
      padding: 16px;
      overflow: auto;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.92rem;
      line-height: 1.5;
      white-space: pre-wrap;
      border: 1px solid var(--surface-dark-border);
    }

    .mobile-topbar {
      display: none;
    }

    @media (max-width: 1200px) {
      .app-shell {
        grid-template-columns: 275px minmax(0, 1fr);
      }

      .main-header h2 {
        font-size: 1.95rem;
      }
    }

    @media (pointer: coarse) and (max-height: 900px) {
      .app-shell {
        grid-template-columns: 210px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
        height: 100dvh;
      }

      .sidebar {
        padding: 10px;
        gap: 10px;
      }

      .brand {
        gap: 8px;
        padding: 0 2px 8px;
      }

      .brand-logo {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        padding: 4px;
      }

      .brand h1 {
        font-size: 0.92rem;
        line-height: 1.05;
      }

      .brand p {
        font-size: 0.74rem;
        margin-top: 3px;
        line-height: 1.15;
      }

      .main-panel {
        height: 100dvh; /* Vital pour que le calcul de hauteur soit dynamique avec la barre mobile */
        /*height: calc(100dvh - 20px);*/
      }

      .main-header {
        padding: 12px 16px 10px;
      }

      .main-header h2 {
        font-size: 1.6rem;
      }

      .main-header p {
        font-size: 0.9rem;
        margin-top: 4px;
      }

      .hero-summary {
padding: 14px 24px 20px; /* On passe de 14px à 20px pour le bas */
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px; /* Un petit décalage supplémentaire pour aérer */
      }

      .messages {
padding: 20px 30px; /* Augmente le padding latéral (24px) pour décoller les bulles des bords */
  display: flex;
  flex-direction: column;
  gap: 16px; /* Espace entre chaque bulle de message */
      }

      .bubble {
margin-left: 2px;
    margin-right: 2px;
    max-width: 88%; /* On réduit légèrement la largeur max pour garantir un espace à l'opposé */
      }

      .quick-actions {
        padding: 8px 16px 0;
        margin-bottom: 8px;
      }

      .quick-btn {
        font-size: 0.84rem;
        padding: 9px 11px;
      }

      .composer {
        padding: 8px 16px calc(10px + var(--safe-bottom));
        gap: 8px;
      }

      .composer textarea {
        min-height: 58px;
        max-height: 82px;
        padding: 12px 14px;
        font-size: 0.92rem;
      }

      .composer-actions-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
      }

      .composer-actions-main .btn {
        min-height: 42px;
        padding: 10px 12px;
        font-size: 0.9rem;
      }
    }

    @media (min-width: 769px) and (max-width: 1180px) {
      .app-shell {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 12px;
        padding: 12px;
      }

      .sidebar {
        padding: 12px;
        gap: 10px;
      }

      .brand {
        gap: 10px;
        padding: 0 2px 10px;
      }

      .brand-logo {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        padding: 4px;
      }

      .brand h1 {
        font-size: 1rem;
        line-height: 1.05;
        white-space: normal;
      }

      .brand p {
        margin-top: 4px;
        font-size: 0.78rem;
        line-height: 1.2;
      }

      .card {
        padding: 12px;
      }

      .assistant-figure {
        max-width: 112px;
      }

      .chip {
        font-size: 0.76rem;
        padding: 6px 9px;
      }

      .main-panel {
        height: calc(100dvh - 24px);
      }

      .main-header {
        padding: 14px 18px 10px;
      }

      .main-header h2 {
        font-size: 1.8rem;
      }

      .main-header p {
        font-size: 0.9rem;
      }

      .hero-summary {
        padding: 10px 18px;
      }

      .messages {
        padding: 12px 18px 6px;
      }

      .bubble {
        max-width: 90%;
        font-size: 0.96rem;
      }

      .quick-actions {
        padding: 8px 18px 0;
        margin-bottom: 8px;
      }

      .quick-btn {
        font-size: 0.84rem;
        padding: 9px 11px;
      }

      .composer {
        padding: 10px 18px calc(10px + var(--safe-bottom));
        gap: 8px;
      }

      .composer textarea {
        min-height: 64px;
        max-height: 100px;
        font-size: 0.94rem;
        padding: 12px 14px;
      }

      .composer-actions-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
      }

      .composer-actions-main .btn {
        min-height: 46px;
        padding: 10px 12px;
        font-size: 0.92rem;
      }
    }

    @media (max-width: 980px) {
      body {
        overflow: auto;
      }

      .app-shell {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
        height: auto;
        min-height: 100dvh;
      }

      .sidebar {
        display: none;
      }

      .main-panel {
        height: calc(100dvh - 24px);
      }

      .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: calc(12px + var(--safe-top)) 16px 10px;
        border-bottom: 1px solid var(--border);
      }

      .mobile-topbar-title {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
      }

      .mobile-topbar-title img {
        width: 38px;
        height: 38px;
        border-radius: 12px;
        object-fit: contain;
        background: #fff;
        border: 1px solid var(--border);
        padding: 4px;
      }

      .mobile-topbar-title strong {
        display: block;
        color: var(--primary);
        font-size: 1rem;
        line-height: 1.1;
      }

      .mobile-topbar-title span {
        color: var(--muted);
        font-size: 0.82rem;
      }

      .mobile-topbar-actions {
        display: flex;
        gap: 8px;
      }

      .mobile-topbar .btn {
        padding: 10px 12px;
        border-radius: 14px;
      }
    }

    @media (max-width: 768px) {
      .messages,
      .dock-panel,
      .snapshot-box {
        scrollbar-width: none;
      }

      .messages::-webkit-scrollbar,
      .dock-panel::-webkit-scrollbar,
      .snapshot-box::-webkit-scrollbar {
        display: none;
      }

      .app-shell {
height: 100dvh; /* Vital pour que les boutons restent visibles au-dessus de la barre de navigation */

}

      .main-panel {
        border-radius: 0;
        height: 100dvh;
        border: 0;
      }

      .main-header {
        padding: 12px 16px;
        gap: 12px;
      }

      .main-header h2 {
        font-size: 1.45rem;
      }

      .main-header p {
        font-size: 0.9rem;
        margin-top: 6px;
      }

      .main-header-right {
        width: 100%;
        justify-content: flex-start;
      }

      #themeBtn {
        display: none !important;
      }

      .hero-summary {
        padding: 10px 14px;
      }

      .hero-title {
        align-items: flex-start;
      }

      #heroChips {
        margin-top: 12px; /* Ajoute l'espace sous le titre uniquement là où il y a les puces */
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
      }

      .messages {
padding: 15px 18px; /* Un peu moins de marge sur mobile pour garder de la lisibilité */
        gap: 12px;
      }

      .bubble {
        max-width: 92%;
        font-size: 0.98rem;
        padding: 14px 15px;
      }

      .quick-actions {
        padding: 8px 16px 0;
        margin-bottom: 12px;
      }

      .quick-btn {
        padding: 9px 12px;
        font-size: 0.86rem;
      }

      .composer {
        padding: 12px 16px calc(14px + var(--safe-bottom));
      }

      .composer textarea {
        min-height: 64px;
        max-height: 96px;
        font-size: 0.98rem;
      }

      .composer-actions-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
      }

      .question-actions {
        grid-template-columns: 1fr;
      }

      .bubble.thinking {
        min-width: 0;
        max-width: 100%;
      }
    }

    @media (max-width: 520px) {
      .main-header {
        padding: 8px 14px 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
      }

      .main-header h2 {
        font-size: 0.98rem;
        line-height: 1.05;
        margin-bottom: 2px;
      }

      .main-header p {
        display: none;
      }

      .main-header-right {
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
      }

      .hero-summary {
        padding: 8px 12px;
        gap: 8px;
      }

      .hero-title strong {
        font-size: 0.88rem;
      }

      #heroChips {
        gap: 6px;
        margin-top: 4px;
      }

      #heroChips .chip:first-child {
        font-size: 0.78rem;
        padding: 6px 10px;
        line-height: 1.25;
      }

      #heroChips .chip {
        font-size: 0.74rem;
        padding: 5px 9px;
      }

      .messages {
        padding: 8px 12px 6px;
        gap: 10px;
      }

      .bubble {
        max-width: 100%;
        font-size: 0.92rem;
        line-height: 1.42;
        padding: 12px 14px;
        border-radius: 16px;
        gap: 6px;
      }

      .bubble-card-title {
        margin: 0;
        font-size: 0.74rem;
        letter-spacing: 0.05em;
        line-height: 1.05;
      }

      .bubble-body {
        font-size: 0.92rem;
        line-height: 1.42;
      }

      .messages > .bubble.assistant:first-child {
        min-height: 0;
        padding-top: 10px;
        padding-bottom: 10px;
        
      }

      .quick-actions {
        padding: 6px 12px 0;
        margin-bottom: 8px;
      }

      .quick-btn {
        font-size: 0.84rem;
        padding: 9px 11px;
      }

      .composer {
        padding: 10px 12px calc(10px + var(--safe-bottom));
        gap: 8px;
      }

      .composer textarea {
        min-height: 64px;
        max-height: 92px;
        padding: 12px 14px;
        border-radius: 18px;
      }

      .dock-panel {
        width: 100vw;
      }
    }

    @media (max-width: 400px) {
      .main-header h2 {
        font-size: 0.92rem;
      }
    }

/* --- CORRECTIFS D'ESPACEMENT CIBLÉS --- */

/* 1. Décolle la première bulle du bloc "Vue synthétique" */
.hero-summary {
    margin-bottom: 25px !important;
}

/* 2. Décolle les bulles des bords gauche et droit du panneau */
.messages {
    padding-left: 30px !important;
    padding-right: 30px !important;
    gap: 20px !important; /* Espace vertical entre les bulles */
}

/* 3. Sécurité pour que les bulles ne touchent jamais le bord opposé */
.bubble.assistant {
    margin-right: 15% !important;
}
.bubble.user {
    margin-left: 15% !important;
}    


/* --- CORRECTIF FINAL TAILLE DES BULLES --- */

/* Force la bulle à coller au texte */
.bubble {
    display: table !important; /* Solution de secours ultra-compatible pour coller au contenu */
    width: auto !important;
    max-width: 85% !important;
    min-width: 0 !important;
}

/* Aligne le texte à l'intérieur */
.bubble-body {
    display: block !important;
    text-align: left !important;
}

/* Gère le placement gauche/droite dans le conteneur */
.messages {
    display: flex !important;
    flex-direction: column !important;
}

.bubble.assistant {
    align-self: flex-start !important;
}

.bubble.user {
    align-self: flex-end !important;
}

/* --- FIX RADICAL MOBILE : PLUS DE SCROLL / BOUTONS EN BAS --- */
@media (max-width: 768px) {
    /* 1. On supprime les marges blanches sur les bords de l'app */
    html, body {
        position: fixed;
        overflow: hidden;
        width: 100%;
        height: 100%;
    }

    .app-shell {
        height: 100dvh !important; /* Hauteur dynamique réelle */
        padding: 0 !important;      /* Supprime les espaces sur les bords */
        gap: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* 2. On force le panneau principal à prendre toute la place */
    .main-panel {
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* 3. La zone de messages prend ce qu'il reste, le reste est poussé en bas */
    .chat-area {
        flex: 1 !important;
        overflow: hidden !important;
    }

    .messages {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 15px !important;
    }

    /* 4. LE BLOC DE SAISIE : Toujours visible, scotché au bas de l'écran */
    .composer {
        margin-top: auto !important;
        background: var(--panel-strong) !important;
        padding: 10px 15px calc(10px + var(--safe-bottom)) !important;
        border-top: 1px solid var(--border) !important;
    }

    /* 5. On réduit un peu la zone de texte pour laisser de la place aux boutons */
    .composer textarea {
        min-height: 45px !important;
        max-height: 80px !important;
        margin-bottom: 8px !important;
    }

    .composer-actions-main {
        display: flex !important;
        gap: 8px !important;
    }

    .composer-actions-main .btn {
        flex: 1 !important;
        min-height: 44px !important;
    }
}