:root { --wwbs-ai-accent: #7c3aed; }
#wwbs-ai-root { position: fixed; right: 18px; bottom: 18px; z-index: 999999; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
#wwbs-ai-launcher { border: 0; border-radius: 999px; padding: 14px 18px; background: var(--wwbs-ai-accent); color: #fff; font-weight: 750; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
#wwbs-ai-panel { width: min(410px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 36px)); background: #fff; color: #171717; border: 1px solid #d8d8dc; border-radius: 18px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; box-shadow: 0 16px 48px rgba(0,0,0,.28); }
#wwbs-ai-panel[hidden] { display: none; }
#wwbs-ai-panel header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; background: var(--wwbs-ai-accent); color: #fff; }
#wwbs-ai-panel header div { display: grid; gap: 2px; }
#wwbs-ai-panel header strong { font-size: 18px; }
#wwbs-ai-panel header span { font-size: 12px; opacity: .92; }
#wwbs-ai-close { border: 0; background: transparent; color: #fff; font-size: 28px; cursor: pointer; }
#wwbs-ai-messages { min-height: 220px; max-height: 330px; overflow-y: auto; padding: 14px; background: #f7f7f8; }
.wwbs-ai-msg { max-width: 88%; margin: 8px 0; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; line-height: 1.42; overflow-wrap: anywhere; }
.wwbs-ai-msg.assistant { background: #fff; border: 1px solid #ddd; }
.wwbs-ai-msg.user { margin-left: auto; color: #fff; background: var(--wwbs-ai-accent); }
#wwbs-ai-status { display: flex; align-items: center; gap: 9px; padding: 8px 14px; color: #5f6368; font-size: 13px; background: #f7f7f8; }
#wwbs-ai-status[hidden] { display: none; }
#wwbs-ai-status span { width: 9px; height: 9px; border-radius: 50%; background: var(--wwbs-ai-accent); animation: wwbsPulse 1s infinite alternate; }
@keyframes wwbsPulse { to { opacity: .25; transform: scale(.7); } }
#wwbs-ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 2px; }
#wwbs-ai-quick button { border: 1px solid #cfcfd5; border-radius: 999px; background: #fff; padding: 7px 9px; cursor: pointer; font: inherit; font-size: 12px; }
#wwbs-ai-quick button:disabled { opacity: .55; cursor: wait; }
#wwbs-ai-consent { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; padding: 9px 12px; font-size: 12px; border-top: 1px solid #eee; }
#wwbs-ai-consent label { display: flex; gap: 6px; }
#wwbs-ai-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; }
#wwbs-ai-input, #wwbs-ai-handoff input, #wwbs-ai-handoff textarea { width: 100%; box-sizing: border-box; border: 1px solid #bbb; border-radius: 10px; padding: 10px; font: inherit; }
#wwbs-ai-send, #wwbs-ai-submit-lead, #wwbs-ai-handoff-cta { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--wwbs-ai-accent); color: #fff; font-weight: 750; cursor: pointer; }
#wwbs-ai-send:disabled, #wwbs-ai-submit-lead:disabled { cursor: wait; opacity: .65; }
#wwbs-ai-handoff-cta { display: block; width: calc(100% - 24px); margin: 4px 12px 10px; }
#wwbs-ai-handoff-cta[hidden] { display: none; }
#wwbs-ai-handoff { padding: 12px; border-top: 1px solid #eee; display: grid; gap: 8px; }
#wwbs-ai-handoff[hidden] { display: none; }
#wwbs-ai-hp { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
#wwbs-ai-panel footer { padding: 8px 12px 12px; color: #666; font-size: 11px; }
@media (max-width: 480px) {
  #wwbs-ai-root { right: 8px; bottom: 8px; }
  #wwbs-ai-panel { position: fixed; inset: 8px; width: auto; max-height: none; height: calc(100dvh - 16px); border-radius: 16px; overflow-y: auto; }
  #wwbs-ai-messages { min-height: 190px; max-height: 38dvh; }
  #wwbs-ai-handoff { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  html.wwbs-ai-open, html.wwbs-ai-open body { overflow: hidden; }
}

#wwbs-ai-handoff-status {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  background: #eef3ff;
  border: 1px solid #b8c7ef;
}
#wwbs-ai-handoff-status[hidden] { display: none; }
#wwbs-ai-handoff-status[data-type="error"] {
  background: #fff1f0;
  border-color: #e5a19c;
  color: #8b1e16;
}
#wwbs-ai-handoff-status[data-type="success"] {
  background: #edf9f0;
  border-color: #8ac69a;
  color: #185c2a;
}
#wwbs-ai-handoff-status[data-type="loading"] {
  background: #f5f1ff;
  border-color: #bda8ed;
  color: #4d2b91;
}
#wwbs-ai-handoff textarea {
  resize: vertical;
  min-height: 92px;
}

/* stabile mobile Bedienung und klare Zustände */
#wwbs-ai-submit-lead:disabled,
#wwbs-ai-send:disabled,
#wwbs-ai-quick button:disabled {
  cursor: wait;
  opacity: .72;
}
#wwbs-ai-handoff-status {
  scroll-margin-top: 90px;
}

/* v2.0 production UI */
.wwbs-ai-header-actions { display: flex; align-items: center; gap: 6px; }
#wwbs-ai-reset, #wwbs-ai-close { border: 0; background: transparent; color: #fff; font-size: 25px; cursor: pointer; line-height: 1; min-width: 40px; min-height: 40px; }
.wwbs-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
#wwbs-ai-notice { margin: 8px 12px 0; border-radius: 10px; padding: 10px 12px; font-size: 13px; background: #eef3ff; border: 1px solid #b8c7ef; }
#wwbs-ai-notice[hidden] { display: none; }
#wwbs-ai-notice[data-type="error"] { background: #fff1f0; border-color: #e5a19c; color: #8b1e16; }
#wwbs-ai-handoff label { font-size: 12px; font-weight: 650; margin-bottom: -4px; }
.wwbs-ai-help { margin: -2px 0 4px; color: #666; font-size: 12px; line-height: 1.4; }
.wwbs-ai-action-link { display: block; margin: 4px 12px 10px; padding: 10px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--wwbs-ai-accent); color: var(--wwbs-ai-accent); text-decoration: none; text-align: center; font-weight: 750; }
.wwbs-ai-action-link[hidden] { display: none; }
#wwbs-ai-panel :focus-visible { outline: 3px solid color-mix(in srgb, var(--wwbs-ai-accent) 55%, white); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #wwbs-ai-status span { animation: none; } * { scroll-behavior: auto !important; } }

#wwbs-ai-new-handoff.wwbs-ai-secondary {
  background: transparent;
  color: var(--wwbs-ai-accent, #7c3aed);
  border: 2px solid currentColor;
  margin-top: 8px;
}
#wwbs-ai-new-handoff.wwbs-ai-secondary:hover,
#wwbs-ai-new-handoff.wwbs-ai-secondary:focus-visible {
  background: rgba(124, 58, 237, .08);
}
