.bebot,
.bebot * { box-sizing: border-box; }

.bebot {
  --bebot-ink: #17191f;
  --bebot-blue: #43758d;
  --bebot-pale: #e4eff4;
  --bebot-logo-blue: #bdd9e4;
  --bebot-logo-blue-strong: #68777d;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 1200;
  color: var(--bebot-ink);
  font-family: 'Montserrat', 'Avenir Next', 'Segoe UI', sans-serif;
}

.bebot-launcher {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.bebot-close:focus-visible,
.bebot-form input:focus-visible,
.bebot-form button:focus-visible {
  outline: 3px solid #d69e2e;
  outline-offset: 3px;
}

.bebot-launcher:focus-visible {
  outline: 3px solid var(--bebot-logo-blue-strong);
  outline-offset: 3px;
}

.bebot-invite {
  position: relative;
  max-width: 245px;
  margin-bottom: 38px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 22px 22px 6px 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .68), rgba(190, 222, 233, .4));
  color: #15343e;
  box-shadow:
    0 14px 34px rgba(7, 39, 48, .16),
    inset 0 1px 0 rgba(255, 255, 255, .94);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  transform-origin: right bottom;
  transition:
    max-width .34s ease,
    padding-inline .34s ease,
    border-width .24s ease,
    transform .34s ease,
    opacity .24s ease;
}

.bebot-invite::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: 14px;
  width: 14px;
  height: 14px;
  border-right: 1px solid rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(255, 255, 255, .88);
  background: rgba(216, 237, 244, .64);
  box-shadow: 3px 3px 8px rgba(7, 39, 48, .06);
  transform: rotate(-45deg);
  transition: opacity .18s ease;
}

.bebot-launcher:hover .bebot-invite { transform: translateY(-3px); }
.bebot[data-invite='folded'] .bebot-invite {
  max-width: 0;
  padding-inline: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px) scale(.88);
}
.bebot[data-invite='folded'] .bebot-invite::after { opacity: 0; }

.bebot-mascot-wrap {
  --bebot-halo-x: 42px;
  --bebot-halo-y: 40px;
  position: relative;
  isolation: isolate;
  display: grid;
  width: 116px;
  height: 116px;
  place-items: center;
  animation: bebot-float 3.8s ease-in-out infinite;
}

.bebot-mascot-wrap::before,
.bebot-mascot-wrap::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: -1;
  border-radius: 50%;
  transform: translate(var(--bebot-halo-x), var(--bebot-halo-y));
}

.bebot-mascot-wrap::before {
  inset: -24px;
  background:
    radial-gradient(circle at 32% 28%, rgba(228, 239, 244, .92) 0 15%, transparent 46%),
    conic-gradient(from 30deg, rgba(67, 117, 141, .08), rgba(67, 117, 141, .68), rgba(116, 174, 198, .4), rgba(67, 117, 141, .08));
  filter: blur(9px);
  opacity: .7;
  animation: bebot-halo-turn 9s linear infinite;
}

.bebot-mascot-wrap::after {
  inset: -10px;
  background: radial-gradient(circle, rgba(228, 239, 244, .78) 0 34%, rgba(67, 117, 141, .42) 58%, transparent 74%);
  filter: blur(7px);
  opacity: .72;
  animation: bebot-halo-breathe 4.6s ease-in-out infinite;
}

.bebot-mascot {
  position: relative;
  z-index: 1;
  display: block;
  width: 116px;
  height: 116px;
  object-fit: contain;
  filter: drop-shadow(0 9px 7px rgba(23, 25, 31, .22));
  transition: transform .2s ease;
}

.bebot-launcher:hover .bebot-mascot { transform: rotate(2deg) scale(1.04); }
.bebot[data-state='wave'] .bebot-mascot {
  transform-origin: 64% 72%;
  animation: bebot-wave-greeting 1.25s ease-in-out both;
}

.bebot-thinking-dots {
  position: absolute;
  z-index: 2;
  top: 2px;
  right: 0;
  display: none;
  gap: 3px;
  padding: 7px;
  border: 2px solid var(--bebot-ink);
  border-radius: 999px;
  background: #fff;
}

.bebot-thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bebot-blue);
  animation: bebot-dot .8s ease-in-out infinite alternate;
}

.bebot-thinking-dots i:nth-child(2) { animation-delay: .15s; }
.bebot-thinking-dots i:nth-child(3) { animation-delay: .3s; }
.bebot[data-state='thinking'] .bebot-thinking-dots { display: flex; }

.bebot-panel {
  position: absolute;
  right: 0;
  bottom: 128px;
  display: grid;
  grid-template-rows: auto minmax(140px, 1fr) auto auto;
  width: min(390px, calc(100vw - 32px));
  height: min(570px, calc(100vh - 170px));
  min-height: 390px;
  overflow: hidden;
  border: 2px solid var(--bebot-ink);
  border-radius: 22px 22px 7px 22px;
  background: #fff;
  box-shadow: 7px 9px 0 rgba(23, 25, 31, .2), 0 20px 50px rgba(23, 25, 31, .18);
  transform-origin: bottom right;
  animation: bebot-panel-in .2s ease-out;
}

.bebot-panel[hidden] { display: none; }

.bebot-panel-header {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--bebot-ink);
  background: var(--bebot-pale);
}

.bebot-panel-avatar {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.bebot-panel-header div { display: grid; gap: 3px; }
.bebot-panel-header strong { font-size: 16px; }
.bebot-panel-header span { color: #47525e; font-size: 11px; font-weight: 700; }

.bebot-close {
  width: 38px;
  height: 38px;
  margin-left: auto;
  padding: 0;
  border: 2px solid var(--bebot-ink);
  border-radius: 50%;
  background: #fff;
  color: var(--bebot-ink);
  font: 700 25px/32px Arial, sans-serif;
  cursor: pointer;
}

.bebot-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
  background: linear-gradient(155deg, #f8fbfc, #fff 55%);
  scrollbar-color: #9ab9c7 transparent;
}

.bebot-message {
  width: fit-content;
  max-width: 88%;
  margin: 0;
  padding: 10px 12px;
  border: 1.5px solid var(--bebot-ink);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bebot-message-bot {
  align-self: flex-start;
  border-radius: 5px 16px 16px 16px;
  background: var(--bebot-pale);
}

.bebot-message-user {
  align-self: flex-end;
  border-radius: 16px 5px 16px 16px;
  background: #f7e8cf;
}

.bebot-message-error {
  border-color: #a12f1f;
  background: #fff0ed;
  color: #7d2418;
}

.bebot-notice {
  margin: 0;
  padding: 7px 14px;
  border-top: 1px solid #d5e1e6;
  color: #64757d;
  font-size: 10px;
  line-height: 1.35;
}

.bebot-notice a { color: var(--bebot-blue); font-weight: 800; }

.bebot-form {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #d5e1e6;
  background: #fff;
}

.bebot-form input {
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 2px solid var(--bebot-ink);
  border-radius: 12px;
  color: var(--bebot-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}

.bebot-form button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 2px solid var(--bebot-ink);
  border-radius: 12px;
  background: #f2ddb5;
  color: var(--bebot-ink);
  cursor: pointer;
}

.bebot-form button:disabled { cursor: wait; opacity: .55; }
.bebot-form button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bebot-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes bebot-float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-9px) rotate(1deg); } }
@keyframes bebot-halo-turn {
  from { transform: translate(var(--bebot-halo-x), var(--bebot-halo-y)) rotate(0); }
  to { transform: translate(var(--bebot-halo-x), var(--bebot-halo-y)) rotate(1turn); }
}
@keyframes bebot-halo-breathe {
  0%, 100% { transform: translate(var(--bebot-halo-x), var(--bebot-halo-y)) scale(.94); opacity: .58; }
  50% { transform: translate(var(--bebot-halo-x), var(--bebot-halo-y)) scale(1.08); opacity: .82; }
}
@keyframes bebot-dot { to { transform: translateY(-4px); opacity: .45; } }
@keyframes bebot-wave-greeting {
  0%, 100% { transform: translateY(0) rotate(0) scale(1.12); }
  24% { transform: translateY(-4px) rotate(-2.5deg) scale(1.145); }
  50% { transform: translateY(-2px) rotate(1.5deg) scale(1.155); }
  74% { transform: translateY(-4px) rotate(-1.5deg) scale(1.145); }
}
@keyframes bebot-panel-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }

@media (max-width: 620px) {
  .bebot { right: max(9px, env(safe-area-inset-right)); bottom: max(7px, env(safe-area-inset-bottom)); }
  .bebot-mascot-wrap { --bebot-halo-x: 32px; --bebot-halo-y: 30px; }
  .bebot-mascot-wrap, .bebot-mascot { width: 88px; height: 88px; }
  .bebot-mascot-wrap::before { inset: -17px; filter: blur(7px); }
  .bebot-mascot-wrap::after { inset: -7px; filter: blur(5px); }
  .bebot-invite { max-width: 205px; margin-bottom: 27px; padding: 10px 13px; font-size: 12px; }
  .bebot-panel {
    position: fixed;
    right: 8px;
    bottom: calc(94px + env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    height: min(560px, calc(100dvh - 112px));
    min-height: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bebot-mascot-wrap,
  .bebot-mascot-wrap::before,
  .bebot-mascot-wrap::after,
  .bebot-thinking-dots i,
  .bebot[data-state='wave'] .bebot-mascot,
  .bebot-panel { animation: none; }
  .bebot-invite,
  .bebot-invite::after,
  .bebot-mascot { transition: none; }
}


/* ---------- Panneau BEbot aligné sur l'application ---------- */
.bebot-panel{
  width:min(390px,calc(100vw - 28px));height:min(610px,calc(100dvh - 150px));min-height:390px;
  border:2px solid rgba(255,255,255,.78);border-radius:24px;
  background:linear-gradient(145deg,rgba(255,255,255,.52),rgba(224,248,250,.34));color:#15343e;
  box-shadow:0 24px 65px rgba(7,39,48,.28),inset 0 1px 0 rgba(255,255,255,.92);
  backdrop-filter:blur(24px) saturate(145%);-webkit-backdrop-filter:blur(24px) saturate(145%)
}
.bebot-panel-header{border-bottom:1px solid rgba(255,255,255,.72);background:transparent}
.bebot-panel-header strong{color:#15343e}
.bebot-close{
  border:1px solid rgba(255,255,255,.78);border-radius:11px;background:rgba(255,255,255,.48);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.9);color:#173943
}
.bebot-messages{background:transparent}
.bebot-message{border:1px solid rgba(255,255,255,.9);box-shadow:0 5px 13px rgba(15,55,66,.07)}
.bebot-message-bot{background:rgba(255,255,255,.74);color:#15343e}
.bebot-message-user{border-color:rgba(23,57,67,.88);background:#173943;color:#fff}
.bebot-notice{border-top:1px solid rgba(255,255,255,.7);color:#607982}
.bebot-form{border-top:1px solid rgba(255,255,255,.75);background:rgba(255,255,255,.28)}
.bebot-form input{border:1px solid rgba(125,171,182,.55);background:rgba(255,255,255,.76);color:#15343e}
.bebot-form button{
  border:0;background:linear-gradient(135deg,#31c7d7,#315be7);color:#fff;
  box-shadow:0 8px 18px rgba(23,137,189,.22)
}
@media(max-width:620px){.bebot-panel{border-radius:22px;height:min(560px,calc(100dvh - 112px))}}
