.wpsb {
	--wpsb-accent: #3988d3;
	--wpsb-on-accent: #ffffff;
	--wpsb-accent-text: #2f74b5;
	--wpsb-btn-radius: 4px;
	--wpsb-bottom: 20px;
	--wpsb-bg: #ffffff;
	--wpsb-text: #364151;
	--wpsb-muted: #f1f5fa;
	--wpsb-line: #dfe6ef;
	position: fixed;
	right: 20px;
	bottom: var(--wpsb-bottom);
	z-index: 99990;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--wpsb-text);
}

.wpsb *,
.wpsb *::before,
.wpsb *::after {
	box-sizing: border-box;
}

/* Startknopf */
.wpsb-launcher {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	padding: 12px 18px 12px 14px;
	border: 0;
	border-radius: var(--wpsb-btn-radius, 4px);
	background: var(--wpsb-accent);
	color: var(--wpsb-on-accent, #fff);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
	transition: transform .15s ease;
}

.wpsb-launcher:hover { transform: translateY(-2px); }
.wpsb-launcher:focus-visible { outline: 3px solid var(--wpsb-text); outline-offset: 3px; }
/* Icon: Schild oder Website-Icon / eigenes Bild */
.wpsb-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.wpsb-icon svg { width: 22px; height: 22px; fill: currentColor; }
.wpsb-icon.wpsb-has-img { width: 30px; height: 30px; border-radius: 50%; background: #fff; overflow: hidden; }
.wpsb-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wpsb-launcher .wpsb-icon.wpsb-has-img { margin: -4px 0 -4px -4px; }
.wpsb-head-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wpsb-head-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpsb-head-icon.wpsb-has-img { width: 32px; height: 32px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--wpsb-on-accent, #fff) 50%, transparent); }
.wpsb-open .wpsb-launcher { display: none; }
.wpsb-no-launcher .wpsb-launcher { display: none; }

/* Fenster */
.wpsb-panel {
	display: flex;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - var(--wpsb-bottom) - 40px);
	background: var(--wpsb-bg);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
}

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

.wpsb-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--wpsb-accent);
	color: var(--wpsb-on-accent, #fff);
}

.wpsb-close {
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

.wpsb-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	-webkit-overflow-scrolling: touch;
}

/* Hinweis */
.wpsb-alert {
	border-left: 4px solid var(--wpsb-accent);
	background: var(--wpsb-muted);
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 14px;
}

.wpsb-alert p { margin: 4px 0 6px; }
.wpsb-alert a { color: var(--wpsb-accent-text, var(--wpsb-accent)); font-weight: 600; }

/* Nachrichten */
.wpsb-msg {
	max-width: 90%;
	padding: 10px 13px;
	border-radius: 14px;
}

.wpsb-msg p { margin: 0 0 6px; }
.wpsb-msg p:last-child { margin-bottom: 0; }
.wpsb-msg ul { margin: 4px 0 8px; padding-left: 18px; }
.wpsb-msg li { margin: 2px 0; }

.wpsb-msg-bot {
	align-self: flex-start;
	background: var(--wpsb-muted);
	border-bottom-left-radius: 4px;
}

.wpsb-msg-user {
	align-self: flex-end;
	background: var(--wpsb-accent);
	color: var(--wpsb-on-accent, #fff);
	border-bottom-right-radius: 4px;
}

/* Antwortknöpfe */
.wpsb-options {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: flex-end;
}

.wpsb-opt {
	border: 1.5px solid var(--wpsb-accent);
	background: #fff;
	color: var(--wpsb-accent-text, var(--wpsb-accent));
	border-radius: var(--wpsb-btn-radius, 4px);
	padding: 8px 14px;
	font: inherit;
	font-size: 14px;
	text-align: right;
	cursor: pointer;
}

.wpsb-opt:hover,
.wpsb-opt:focus-visible {
	background: var(--wpsb-accent);
	color: var(--wpsb-on-accent, #fff);
	outline: none;
}

.wpsb-opt-ghost {
	border-color: var(--wpsb-line);
	color: #666;
}

.wpsb-opt-ghost:hover,
.wpsb-opt-ghost:focus-visible {
	background: var(--wpsb-muted);
	color: var(--wpsb-text);
}

/* Formular */
.wpsb-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px;
	border: 1px solid var(--wpsb-line);
	border-radius: 12px;
}

.wpsb-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }

.wpsb-field input,
.wpsb-field select,
.wpsb-field textarea {
	width: 100%;
	padding: 9px 10px;
	border: 1px solid var(--wpsb-line);
	border-radius: 8px;
	font: inherit;
	font-size: 16px; /* verhindert Zoom auf iOS */
	font-weight: 400;
	background: #fff;
	color: var(--wpsb-text);
}

.wpsb-field input:focus,
.wpsb-field select:focus,
.wpsb-field textarea:focus {
	border-color: var(--wpsb-accent);
	outline: 2px solid color-mix(in srgb, var(--wpsb-accent) 25%, transparent);
}

.wpsb-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; }
.wpsb-consent input { margin-top: 3px; flex: none; }
.wpsb-consent a { color: var(--wpsb-accent-text, var(--wpsb-accent)); }

.wpsb-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

.wpsb-submit {
	border: 0;
	border-radius: var(--wpsb-btn-radius, 4px);
	padding: 12px;
	background: var(--wpsb-accent);
	color: var(--wpsb-on-accent, #fff);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.wpsb-form .wpsb-opt { text-align: center; }

.wpsb-submit[disabled] { opacity: .6; cursor: wait; }

.wpsb-status { margin: 0; font-size: 13px; min-height: 0; }
.wpsb-status:empty { display: none; }
.wpsb-error { color: #c62828; font-weight: 600; }

/* Shortcode-Knopf */
.wpsb-open-btn {
	display: inline-block;
	padding: 12px 22px;
	border: 0;
	border-radius: var(--wpsb-btn-radius, 4px);
	background: var(--wpsb-accent, #3988d3);
	color: var(--wpsb-on-accent, #fff);
	font-weight: 700;
	cursor: pointer;
}

/* Mobil: Fenster über ganze Breite */
@media (max-width: 480px) {
	.wpsb { right: 12px; left: 12px; }
	.wpsb-launcher { margin-left: auto; }
	.wpsb-panel {
		width: 100%;
		max-width: none;
		height: calc(100vh - var(--wpsb-bottom) - 24px);
		height: calc(100dvh - var(--wpsb-bottom) - 24px);
	}
	.wpsb:not(.wpsb-open) { left: auto; }
}

@media (prefers-reduced-motion: reduce) {
	.wpsb-launcher { transition: none; }
}
