.fap-widget-root {
	--fap-widget-primary: #2563eb;
	position: fixed;
	z-index: 999999;
	bottom: 22px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 15px;
	line-height: 1.45;
	text-align: left;
}

.fap-widget-position-right {
	right: 22px;
}

.fap-widget-position-left {
	left: 22px;
}

.fap-widget-root *,
.fap-widget-root *::before,
.fap-widget-root *::after {
	box-sizing: border-box;
}

.fap-widget-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 58px;
	padding: 8px 18px 8px 8px;
	border: 0;
	border-radius: 999px;
	background: var(--fap-widget-primary);
	box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22), 0 3px 8px rgba(15, 23, 42, 0.15);
	color: #fff;
	cursor: pointer;
	font: inherit;
	font-weight: 700;
	letter-spacing: -0.01em;
	transition: transform 160ms ease, box-shadow 160ms ease;
}

.fap-widget-launcher:hover {
	box-shadow: 0 15px 34px rgba(15, 23, 42, 0.27), 0 4px 10px rgba(15, 23, 42, 0.16);
	transform: translateY(-2px);
}

.fap-widget-launcher-icon-only {
	width: 58px;
	height: 58px;
	padding: 8px;
}

.fap-widget-launcher:focus-visible,
.fap-widget-close:focus-visible,
.fap-widget-send:focus-visible,
.fap-widget-composer input:focus-visible {
	outline: 3px solid rgba(99, 102, 241, 0.28);
	outline-offset: 3px;
}

.fap-widget-launcher-icon,
.fap-widget-header-avatar,
.fap-widget-message-avatar {
	display: grid;
	flex: 0 0 auto;
	overflow: hidden;
	border-radius: 50%;
	place-items: center;
}

.fap-widget-launcher-icon {
	width: 42px;
	height: 42px;
	background: rgba(255, 255, 255, 0.18);
}

.fap-widget-launcher-icon img,
.fap-widget-header-avatar img,
.fap-widget-message-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.fap-widget-launcher-icon svg,
.fap-widget-header-avatar svg,
.fap-widget-message-avatar svg {
	width: 56%;
	height: 56%;
	fill: currentColor;
}

.fap-widget-panel {
	position: absolute;
	bottom: 74px;
	display: flex;
	overflow: hidden;
	width: min(380px, calc(100vw - 32px));
	height: min(590px, calc(100vh - 120px));
	min-height: 430px;
	flex-direction: column;
	border: 1px solid rgba(148, 163, 184, 0.3);
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24), 0 8px 20px rgba(15, 23, 42, 0.12);
	color: #172033;
	transform-origin: bottom right;
	animation: fap-widget-arrive 180ms ease-out;
}

.fap-widget-position-right .fap-widget-panel {
	right: 0;
}

.fap-widget-position-left .fap-widget-panel {
	left: 0;
	transform-origin: bottom left;
}

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

@keyframes fap-widget-arrive {
	from { opacity: 0; transform: translateY(10px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

.fap-widget-header {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 17px 17px 16px;
	background: linear-gradient(135deg, var(--fap-widget-primary), color-mix(in srgb, var(--fap-widget-primary), #111827 22%));
	color: #fff;
}

@supports not (background: color-mix(in srgb, red, blue)) {
	.fap-widget-header { background: var(--fap-widget-primary); }
}

.fap-widget-header-avatar {
	width: 42px;
	height: 42px;
	background: rgba(255, 255, 255, 0.18);
}

.fap-widget-identity {
	display: flex;
	min-width: 0;
	flex: 1;
	flex-direction: column;
}

.fap-widget-identity strong {
	overflow: hidden;
	font-size: 16px;
	font-weight: 750;
	letter-spacing: -0.015em;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fap-widget-agent-status {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 1px;
	opacity: 0.86;
	font-size: 12px;
}

.fap-widget-status-dot {
	width: 7px;
	height: 7px;
	border: 1px solid rgba(255, 255, 255, 0.8);
	border-radius: 50%;
	background: #86efac;
	box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.16);
}

.fap-widget-close {
	display: grid;
	width: 34px;
	height: 34px;
	padding: 0 0 3px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	font: 300 28px/1 sans-serif;
	place-items: center;
}

.fap-widget-close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.fap-widget-messages {
	display: flex;
	overflow-y: auto;
	flex: 1;
	flex-direction: column;
	gap: 14px;
	padding: 20px 17px;
	background: #f7f8fc;
	scrollbar-color: #cbd5e1 transparent;
	scrollbar-width: thin;
}

.fap-widget-message {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 88%;
}

.fap-widget-message-assistant {
	align-self: flex-start;
}

.fap-widget-message-visitor {
	align-self: flex-end;
	justify-content: flex-end;
}

.fap-widget-message-avatar {
	width: 27px;
	height: 27px;
	background: var(--fap-widget-primary);
	color: #fff;
}

.fap-widget-message-bubble {
	padding: 10px 13px;
	border: 1px solid #e2e8f0;
	border-radius: 14px 14px 14px 4px;
	background: #fff;
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
	color: #263246;
	font-size: 14px;
	line-height: 1.48;
	white-space: pre-wrap;
	word-break: break-word;
}

.fap-widget-message-visitor .fap-widget-message-bubble {
	border-color: transparent;
	border-radius: 14px 14px 4px;
	background: var(--fap-widget-primary);
	color: #fff;
}

.fap-widget-preview-note {
	align-self: center;
	padding: 7px 10px;
	border: 1px dashed #cbd5e1;
	border-radius: 8px;
	color: #64748b;
	font-size: 11px;
	text-align: center;
}

.fap-widget-preview-note span {
	margin-right: 3px;
	color: var(--fap-widget-primary);
	font-weight: 700;
	text-transform: uppercase;
}

.fap-widget-source {
	display: block;
	margin-top: 8px;
	padding-top: 7px;
	border-top: 1px solid #edf0f5;
	color: #7c8799;
	font-size: 10px;
	font-weight: 650;
}

.fap-widget-support-link {
	display: flex;
	width: fit-content;
	max-width: 100%;
	margin-top: 9px;
	padding: 7px 10px;
	border-radius: 8px;
	background: var(--fap-widget-primary);
	color: #fff !important;
	font-size: 12px;
	font-weight: 700;
	text-decoration: none !important;
}

.fap-widget-email-handoff {
	display: flex;
	margin-top: 10px;
	padding-top: 9px;
	border-top: 1px solid #edf0f5;
	flex-direction: column;
	gap: 7px;
	white-space: normal;
}

.fap-widget-email-prompt,
.fap-widget-email-status {
	display: block;
	font-size: 12px;
	line-height: 1.4;
}

.fap-widget-email-form {
	display: flex;
	align-items: stretch;
	gap: 6px;
}

.fap-widget-email-form input {
	min-width: 0;
	height: 36px;
	flex: 1;
	padding: 0 9px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	color: #172033;
	font: inherit;
	font-size: 12px;
}

.fap-widget-email-form input:focus {
	border-color: var(--fap-widget-primary);
	outline: 2px solid color-mix(in srgb, var(--fap-widget-primary), transparent 75%);
	outline-offset: 1px;
}

.fap-widget-email-form button {
	padding: 0 10px;
	border: 0;
	border-radius: 8px;
	background: var(--fap-widget-primary);
	color: #fff;
	cursor: pointer;
	font: inherit;
	font-size: 11px;
	font-weight: 700;
}

.fap-widget-email-form button:disabled,
.fap-widget-email-form input:disabled {
	cursor: wait;
	opacity: 0.65;
}

.fap-widget-email-error {
	color: #b42318;
}

.fap-widget-email-success {
	padding: 9px 10px;
	border: 1px solid #bbdfc7;
	border-radius: 8px;
	background: #f0faf3;
	color: #176b35;
	font-weight: 650;
}

.fap-widget-history-prompt,
.fap-widget-history-divider {
	align-self: center;
	color: #64748b;
	font-size: 11px;
	text-align: center;
}

.fap-widget-history-prompt button {
	padding: 7px 11px;
	border: 1px solid #cbd5e1;
	border-radius: 999px;
	background: #fff;
	color: var(--fap-widget-primary);
	cursor: pointer;
	font: inherit;
	font-weight: 700;
}

.fap-widget-history-prompt button:hover {
	border-color: var(--fap-widget-primary);
	background: #f8fafc;
}

.fap-widget-previous-link button {
	padding: 3px 4px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: #7c8799;
	font-size: 10px;
	font-weight: 650;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.fap-widget-conversation-links {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
}

.fap-widget-history-actions {
	display: flex;
	align-self: center;
	gap: 7px;
	flex-wrap: wrap;
	justify-content: center;
}

.fap-widget-history-actions button {
	padding: 7px 10px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	color: var(--fap-widget-primary);
	cursor: pointer;
	font: inherit;
	font-size: 11px;
	font-weight: 700;
}

.fap-widget-history-divider {
	display: flex;
	width: 100%;
	align-items: center;
	gap: 8px;
	text-transform: uppercase;
}

.fap-widget-history-divider::before,
.fap-widget-history-divider::after {
	height: 1px;
	flex: 1;
	background: #dbe1e9;
	content: "";
}

.fap-widget-composer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 13px 14px;
	border-top: 1px solid #e8edf3;
	background: #fff;
}

.fap-widget-composer input {
	min-width: 0;
	height: 43px;
	flex: 1;
	padding: 0 14px;
	border: 1px solid #d8dee8;
	border-radius: 12px;
	background: #f8fafc;
	box-shadow: none;
	color: #172033;
	font: inherit;
	font-size: 14px;
}

.fap-widget-composer input:focus {
	border-color: var(--fap-widget-primary);
	background: #fff;
	outline: none;
}

.fap-widget-send {
	display: grid;
	width: 43px;
	height: 43px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--fap-widget-primary);
	color: #fff;
	cursor: pointer;
	place-items: center;
}

.fap-widget-send:disabled,
.fap-widget-composer input:disabled {
	cursor: wait;
	opacity: 0.64;
}

.fap-widget-send svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
}

.fap-widget-branding {
	padding: 0 14px 10px;
	background: #fff;
	color: #94a3b8;
	font-size: 10px;
	text-align: center;
}

.fap-widget-branding a {
	color: inherit;
	font-weight: 700;
	text-decoration: underline;
	text-decoration-color: color-mix(in srgb, currentColor, transparent 45%);
	text-underline-offset: 2px;
}

.fap-widget-branding a:hover {
	color: var(--fap-widget-primary);
}

.fap-widget-typing .fap-widget-message-bubble {
	display: flex;
	align-items: center;
	gap: 4px;
	min-height: 38px;
}

.fap-widget-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: fap-widget-dot 900ms infinite ease-in-out;
}

.fap-widget-typing i:nth-child(2) { animation-delay: 120ms; }
.fap-widget-typing i:nth-child(3) { animation-delay: 240ms; }

@keyframes fap-widget-dot {
	0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}

.fap-shortcode-warning {
	padding: 10px 12px;
	border-left: 4px solid #d63638;
	background: #fff;
	color: #50575e;
}

@media (max-width: 520px) {
	.fap-widget-root {
		bottom: 14px;
	}

	.fap-widget-position-right { right: 14px; }
	.fap-widget-position-left { left: 14px; }

	.fap-widget-panel {
		position: fixed;
		inset: 12px 12px 84px;
		width: auto;
		height: auto;
		min-height: 0;
		border-radius: 17px;
	}

	.fap-widget-launcher-label {
		display: none;
	}

	.fap-widget-launcher {
		width: 58px;
		height: 58px;
		padding: 8px;
	}

	.fap-widget-launcher-icon {
		width: 42px;
		height: 42px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fap-widget-panel,
	.fap-widget-launcher,
	.fap-widget-typing i {
		animation: none;
		transition: none;
	}
}
