.stb-root {
  --stb-color: #b3122d;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99990;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #1d2327;
}
.stb-root *, .stb-root *::before, .stb-root *::after { box-sizing: border-box; }

.stb-toggle {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--stb-color);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.stb-toggle:focus-visible, .stb-close:focus-visible, .stb-send:focus-visible, .stb-input:focus-visible {
  outline: 3px solid #1d2327;
  outline-offset: 2px;
}

.stb-panel {
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 110px);
  margin-bottom: 12px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stb-panel[hidden] { display: none; }

.stb-head {
  background: var(--stb-color);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.stb-close {
  background: none;
  border: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.stb-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f6f7f7;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stb-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.stb-bot { background: #fff; border: 1px solid #e0e0e0; align-self: flex-start; border-bottom-left-radius: 4px; }
.stb-user { background: var(--stb-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.stb-bot a { color: var(--stb-color); text-decoration: underline; }

.stb-typing { display: flex; gap: 4px; padding: 13px 14px; }
.stb-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #8c8f94;
  animation: stb-blink 1.2s infinite ease-in-out;
}
.stb-typing span:nth-child(2) { animation-delay: .2s; }
.stb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes stb-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stb-typing span { animation: none; } }

.stb-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e0e0e0; background: #fff; }
.stb-input {
  flex: 1;
  resize: none;
  border: 1px solid #c3c4c7;
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  background: #fff;
  min-height: 40px;
  max-height: 110px;
}
.stb-send {
  border: 0;
  border-radius: 10px;
  background: var(--stb-color);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
}
.stb-send:disabled { opacity: .55; cursor: default; }

.stb-hint { font-size: 11.5px; color: #646970; padding: 0 12px 10px; background: #fff; }
.stb-hint a { color: inherit; text-decoration: underline; }

@media (max-width: 480px) {
  .stb-root { right: 12px; bottom: 12px; }
  .stb-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}

/* Knopf mit Text */
.stb-toggle-pill {
  width: auto;
  border-radius: 29px;
  padding: 0 20px 0 16px;
  gap: 9px;
  font: inherit;
  font-weight: 600;
}

/* Eigene Grafik als Knopf */
.stb-toggle-image {
  width: auto;
  height: auto;
  padding: 0;
  background: none;
  border-radius: 8px;
  box-shadow: none;
}
.stb-toggle-image img {
  display: block;
  width: var(--stb-launcher-size, 110px);
  max-width: 45vw;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25));
  transition: transform .15s ease;
}
.stb-toggle-image:hover img { transform: scale(1.04); }
@media (prefers-reduced-motion: reduce) { .stb-toggle-image img { transition: none; } }
@media (max-width: 767px) {
  .stb-toggle-image img { width: var(--stb-launcher-size-mobile, 64px); }
  .stb-toggle:not(.stb-toggle-image):not(.stb-toggle-pill) { width: 50px; height: 50px; }
  .stb-toggle-pill { height: 46px; font-size: 14px; padding: 0 16px 0 12px; }
}
@media (max-width: 480px) {
  .stb-open .stb-toggle-image, .stb-open .stb-toggle-pill { display: none; }
}

/* Sprechblase über dem Knopf */
.stb-bubble {
  position: relative;
  display: flex;
  align-items: flex-start;
  width: fit-content;
  max-width: 240px;
  margin: 0 0 12px auto;
  background: #fff;
  color: #1d2327;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.stb-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: calc(var(--stb-tail, 29px) - 8px);
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: 4px 4px 6px rgba(0, 0, 0, .08);
}
.stb-bubble-text {
  position: relative;
  z-index: 1;
  background: none;
  border: 0;
  padding: 10px 4px 10px 14px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.stb-bubble-close {
  position: relative;
  z-index: 1;
  background: none;
  border: 0;
  padding: 6px 10px 6px 4px;
  font-size: 18px;
  line-height: 1;
  color: #646970;
  cursor: pointer;
}
.stb-bubble-text:focus-visible, .stb-bubble-close:focus-visible { outline: 3px solid #1d2327; outline-offset: 2px; border-radius: 8px; }
@media (max-width: 767px) {
  .stb-bubble { max-width: 200px; font-size: 14px; }
  .stb-bubble::after { right: calc(var(--stb-tail-mobile, 25px) - 8px); }
  .stb-bubble-desktop { display: none; }
}

/* Schutz gegen Button-Stile des Themes (Elementor färbt sonst alle Knöpfe ein) */
.stb-root .stb-toggle,
.stb-root .stb-toggle:hover,
.stb-root .stb-toggle:focus {
  background: var(--stb-color) !important;
  color: #fff !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 0 0 auto !important;
  border-radius: 50% !important;
  min-width: 0 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}
.stb-root .stb-toggle.stb-toggle-pill,
.stb-root .stb-toggle.stb-toggle-pill:hover,
.stb-root .stb-toggle.stb-toggle-pill:focus {
  border-radius: 29px !important;
  padding: 0 20px 0 16px !important;
}
.stb-root .stb-toggle.stb-toggle-image,
.stb-root .stb-toggle.stb-toggle-image:hover,
.stb-root .stb-toggle.stb-toggle-image:focus {
  background: none !important;
  box-shadow: none !important;
  border-radius: 50% !important;
  line-height: 0 !important;
}
.stb-root .stb-toggle-image img {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
.stb-root .stb-close,
.stb-root .stb-close:hover,
.stb-root .stb-close:focus {
  background: none !important;
  color: #fff !important;
  border: 0 !important;
  padding: 0 4px !important;
  margin: 0 !important;
  box-shadow: none !important;
  min-width: 0 !important;
}
.stb-root .stb-send,
.stb-root .stb-send:hover,
.stb-root .stb-send:focus {
  background: var(--stb-color) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 10px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}
.stb-root .stb-bubble-text,
.stb-root .stb-bubble-text:hover,
.stb-root .stb-bubble-text:focus {
  background: none !important;
  color: #1d2327 !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 10px 4px 10px 14px !important;
  margin: 0 !important;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: inherit !important;
  line-height: 1.35 !important;
}
.stb-root .stb-bubble-close,
.stb-root .stb-bubble-close:hover,
.stb-root .stb-bubble-close:focus {
  background: none !important;
  color: #646970 !important;
  border: 0 !important;
  padding: 6px 10px 6px 4px !important;
  margin: 0 !important;
  box-shadow: none !important;
  min-width: 0 !important;
}
.stb-root .stb-input {
  background: #fff !important;
  color: #1d2327 !important;
  border: 1px solid #c3c4c7 !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  margin: 0 !important;
}
@media (max-width: 767px) {
  .stb-root .stb-toggle.stb-toggle-pill { padding: 0 16px 0 12px !important; }
}
