.bggpt-chat {
  --bggpt-accent: #2b8a47;
  --bggpt-bg: #ffffff;
  --bggpt-fg: #1c2321;
  --bggpt-muted: #66706d;
  --bggpt-line: #dfe4e2;
  --bggpt-bot: #f1f4f3;
  --bggpt-error: #b3261e;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--bggpt-fg);
  box-sizing: border-box;
}
.bggpt-chat *, .bggpt-chat *::before, .bggpt-chat *::after { box-sizing: border-box; }

.bggpt-panel {
  display: flex;
  flex-direction: column;
  background: var(--bggpt-bg);
  border: 1px solid var(--bggpt-line);
  border-radius: 14px;
  overflow: hidden;
  height: 520px;
  max-width: 720px;
  margin: 0 auto;
}
.bggpt-panel[hidden] { display: none !important; }

.bggpt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bggpt-line);
  background: var(--bggpt-bg);
}
.bggpt-avatar { width: 42px; height: 38px; flex: none; }
.bggpt-titlebox { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.bggpt-status { font-size: 12px; color: var(--bggpt-muted); }
.bggpt-status::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #43b864; margin-right: 5px; vertical-align: 1px;
}

/* ред с роботче до отговора */
.bggpt-row { display: flex; gap: 8px; align-items: flex-end; align-self: flex-start; max-width: 92%; }
.bggpt-row .bggpt-msg { max-width: none; }
.bggpt-mini { width: 30px; height: 26px; flex: none; }

/* ---- Роботчето ---- */
.nea-bot { width: 100%; height: 100%; display: block; overflow: visible; }
.nea-float { animation: nea-float 3.6s ease-in-out infinite; }
.nea-head { transform-box: view-box; transform-origin: 60px 86px; transition: transform .45s cubic-bezier(.3,1.6,.5,1); }
.nea-eye { transform-box: fill-box; transform-origin: center; animation: nea-blink 4.8s infinite; }
.nea-pupil { transition: transform .18s ease-out; }
.nea-mouth-o { transform-box: fill-box; transform-origin: center; opacity: 0; }
.nea-arm-r { transform-box: view-box; transform-origin: 90px 96px; transform: rotate(168deg); }
.nea-arm-l { transform-box: view-box; transform-origin: 30px 97px; transform: rotate(4deg); }
.nea-shadow { transform-box: fill-box; transform-origin: center; animation: nea-shadow 3.6s ease-in-out infinite; }

.is-waving .nea-arm-r { animation: nea-wave 1.8s ease-in-out; }
.is-waving .nea-head { transform: rotate(6deg); }
.is-winking .nea-eye-r { animation: nea-wink .75s ease-in-out; }
.is-winking .nea-head { transform: rotate(-7deg); }
.is-winking .nea-mouth { d: path("M53 62 q7 7 14 0"); }
.is-thinking .nea-mouth { opacity: 0; }
.is-thinking .nea-mouth-o { opacity: 1; animation: nea-talk .45s ease-in-out infinite; }
.is-thinking .nea-pupil { transform: translate(2px, -3px) !important; }
.is-thinking .nea-head { animation: nea-ponder 1.6s ease-in-out infinite; }

/* малките роботчета в разговора стоят по-спокойно */
.bggpt-mini .nea-float, .bggpt-mini .nea-eye { animation: none; }

@keyframes nea-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes nea-shadow { 0%, 100% { transform: scaleX(1); opacity: .16; } 50% { transform: scaleX(.86); opacity: .1; } }
@keyframes nea-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes nea-wink { 0%, 100% { transform: scaleY(1); } 25%, 70% { transform: scaleY(.08); } }
@keyframes nea-talk { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
@keyframes nea-ponder { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes nea-wave {
  0%   { transform: rotate(168deg); }
  22%  { transform: rotate(25deg); }
  36%  { transform: rotate(50deg); }
  50%  { transform: rotate(18deg); }
  64%  { transform: rotate(50deg); }
  78%  { transform: rotate(25deg); }
  100% { transform: rotate(168deg); }
}

.bggpt-title { font-weight: 700; }
.bggpt-chat button { font: inherit; cursor: pointer; }
.bggpt-clear, .bggpt-close {
  background: none; border: 0; color: var(--bggpt-muted);
  padding: 4px 6px; border-radius: 6px; font-size: 13px;
}
.bggpt-close { font-size: 22px; line-height: 1; }
.bggpt-clear:hover, .bggpt-close:hover { color: var(--bggpt-fg); background: var(--bggpt-bot); }

.bggpt-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bggpt-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.bggpt-msg p { margin: 0; }
.bggpt-msg p + p { margin-top: .4em; }
.bggpt-msg ul { margin: .3em 0; padding-left: 1.2em; white-space: normal; }
.bggpt-msg code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; font-size: .92em; }
.bggpt-assistant { align-self: flex-start; background: var(--bggpt-bot); border-bottom-left-radius: 4px; white-space: normal; }
.bggpt-user { align-self: flex-end; background: var(--bggpt-accent); color: #fff; border-bottom-right-radius: 4px; }
.bggpt-error { background: color-mix(in srgb, var(--bggpt-error) 10%, var(--bggpt-bg)); color: var(--bggpt-error); }

.bggpt-typing { display: flex; gap: 4px; padding: 13px 14px; }
.bggpt-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bggpt-muted); opacity: .4;
  animation: bggpt-blink 1.2s infinite;
}
.bggpt-typing span:nth-child(2) { animation-delay: .2s; }
.bggpt-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bggpt-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.bggpt-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--bggpt-line);
  align-items: flex-end;
}
.bggpt-input {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--bggpt-line);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  color: var(--bggpt-fg);
  background: var(--bggpt-bg);
  max-height: 140px;
}
.bggpt-input:focus { outline: 2px solid var(--bggpt-accent); outline-offset: -1px; border-color: transparent; }
.bggpt-send {
  background: var(--bggpt-accent); color: #fff; border: 0;
  border-radius: 10px; padding: 9px 16px; font-weight: 600;
}
.bggpt-send:disabled { opacity: .5; cursor: default; }
.bggpt-chat button:focus-visible { outline: 2px solid var(--bggpt-accent); outline-offset: 2px; }

/* Плаващ режим */
.bggpt-chat[data-mode="floating"] {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 99999;
}
.bggpt-chat[data-mode="floating"] .bggpt-panel {
  position: absolute;
  right: 0;
  bottom: 122px;
  width: 370px;
  height: min(560px, calc(100vh - 120px));
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.bggpt-launcher {
  display: block;
  width: 96px; height: 112px;
  padding: 0; border: 0; background: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.18));
  transition: transform .2s;
}
.bggpt-launcher:hover { transform: translateY(-3px) scale(1.04); }
.bggpt-launcher:focus-visible { outline: 2px solid var(--bggpt-accent); outline-offset: 4px; border-radius: 16px; }

/* балонче „Здравейте!“ */
.bggpt-hello {
  position: absolute; right: 92px; bottom: 70px;
  display: flex; align-items: flex-start; gap: 2px;
  background: var(--bggpt-bg); color: var(--bggpt-fg);
  border: 1px solid var(--bggpt-line); border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  width: max-content; max-width: 250px;
  animation: nea-pop .45s cubic-bezier(.3,1.6,.5,1);
}
.bggpt-hello[hidden] { display: none !important; }
.bggpt-hello-text {
  background: none; border: 0; text-align: left; color: inherit;
  padding: 10px 4px 10px 14px; font-size: 14px; line-height: 1.4;
}
.bggpt-hello-x {
  background: none; border: 0; color: var(--bggpt-muted);
  font-size: 18px; line-height: 1; padding: 6px 8px;
}
@keyframes nea-pop { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }

@media (max-width: 480px) {
  .bggpt-chat[data-mode="floating"] { right: 12px; bottom: 12px; }
  .bggpt-chat[data-mode="floating"] .bggpt-panel { width: calc(100vw - 24px); height: calc(100vh - 150px); }
  .bggpt-launcher { width: 78px; height: 92px; }
  .bggpt-hello { right: 74px; bottom: 56px; }
  .bggpt-chat[data-mode="floating"] .bggpt-panel { bottom: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  .bggpt-typing span { animation: none; opacity: .6; }
  .bggpt-chat .nea-float, .bggpt-chat .nea-eye, .bggpt-chat .nea-shadow, .bggpt-chat .nea-head,
  .bggpt-hello, .bggpt-launcher { animation: none !important; transition: none !important; }
}
.bggpt-hello-text strong { white-space: nowrap; }

.bggpt-note {
  padding: 0 12px 9px; font-size: 11px; line-height: 1.4;
  color: var(--bggpt-muted); text-align: center;
}
.bggpt-note a { color: inherit; text-decoration: underline; }
.bggpt-form { border-top: 1px solid var(--bggpt-line); }
