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

.ai-chatbot {
	--ai-chatbot-color: #2563eb;
	--ai-chatbot-dark: #111827;
	--ai-chatbot-muted: #6b7280;
	--ai-chatbot-border: #d1d5db;
	--ai-chatbot-bg: #f9fafb;
	position: fixed;
	bottom: 24px;
	z-index: 99999;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

.ai-chatbot--right {
	right: 24px;
}

.ai-chatbot--left {
	left: 24px;
}

.ai-chatbot__launcher {
	width: 68px;
	height: 68px;
	border: 0;
	border-radius: 999px;
	background: var(--ai-chatbot-color);
	color: #fff;
	box-shadow: 0 16px 40px rgba(17, 24, 39, .24);
	display: grid;
	place-items: center;
	cursor: pointer;
	font-size: 34px;
	line-height: 1;
}

.ai-chatbot.is-open .ai-chatbot__launcher {
	display: none;
}

.ai-chatbot__launcher-symbol {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	transform: translateY(-1px);
}

.ai-chatbot__avatar,
.ai-chatbot__reset,
.ai-chatbot__minimize,
.ai-chatbot__send {
	position: relative;
	display: inline-block;
}

.ai-chatbot__dialog {
	position: absolute;
	bottom: 0;
	width: 380px;
	height: 560px;
	max-height: calc(100vh - 48px);
	background: #fff;
	border: 1px solid rgba(17, 24, 39, .1);
	border-radius: 8px;
	box-shadow: 0 24px 70px rgba(17, 24, 39, .28);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.ai-chatbot--right .ai-chatbot__dialog {
	right: 0;
}

.ai-chatbot--left .ai-chatbot__dialog {
	left: 0;
}

.ai-chatbot__header {
	min-height: 60px;
	padding: 12px 14px;
	background: var(--ai-chatbot-dark);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.ai-chatbot__identity {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.ai-chatbot__avatar {
	width: 32px;
	height: 32px;
	border-radius: 999px;
	background: var(--ai-chatbot-color);
	flex: 0 0 auto;
	object-fit: cover;
	overflow: hidden;
}

.ai-chatbot__avatar--header {
	background: transparent;
}

.ai-chatbot__msg-avatar {
	width: 36px;
	height: 36px;
	border-radius: 999px;
	object-fit: cover;
	flex: 0 0 auto;
	margin-right: 8px;
	align-self: flex-end;
	border: 1px solid rgba(0,0,0,0.06);
}

.ai-chatbot__message--assistant {
	display: flex;
	align-items: flex-end;
}

.ai-chatbot__message--sources {
	margin-top: -4px;
}

.ai-chatbot__sources {
	margin-left: 44px;
	max-width: 80%;
	font-size: 12px;
	line-height: 1.4;
}

.ai-chatbot__sources-label {
	color: #6b7280;
	margin-bottom: 4px;
	font-size: 11px;
	letter-spacing: 0.04em;
}

.ai-chatbot__sources-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ai-chatbot__sources-list li {
	margin: 0;
	padding: 0;
}

.ai-chatbot__sources-list a {
	color: var(--ai-chatbot-color);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 999px;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s;
}

.ai-chatbot__sources-list a::before {
	content: "→";
	font-size: 11px;
	opacity: 0.7;
	flex: 0 0 auto;
}

.ai-chatbot__sources-list a:hover {
	background: #f9fafb;
	border-color: var(--ai-chatbot-color);
	text-decoration: none;
}

.ai-chatbot__avatar::before,
.ai-chatbot__avatar::after {
	content: "";
	position: absolute;
	background: #fff;
	border-radius: 999px;
}

.ai-chatbot__avatar::before {
	width: 12px;
	height: 6px;
	left: 10px;
	top: 10px;
}

.ai-chatbot__avatar::after {
	width: 16px;
	height: 3px;
	left: 8px;
	top: 20px;
}

.ai-chatbot__header h2 {
	margin: 0;
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ai-chatbot__actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.ai-chatbot__reset,
.ai-chatbot__minimize {
	width: 32px;
	height: 32px;
	border: 1px solid rgba(255, 255, 255, .24);
	border-radius: 6px;
	background: rgba(255, 255, 255, .08);
	color: #fff;
	cursor: pointer;
}

.ai-chatbot__reset::before {
	content: "";
	position: absolute;
	inset: 8px;
	border: 2px solid currentColor;
	border-left-color: transparent;
	border-radius: 999px;
}

.ai-chatbot__reset::after {
	content: "";
	position: absolute;
	right: 8px;
	top: 7px;
	border: 4px solid transparent;
	border-left-color: currentColor;
	transform: rotate(-30deg);
}

.ai-chatbot__minimize::before {
	content: "";
	position: absolute;
	left: 8px;
	right: 8px;
	top: 15px;
	height: 2px;
	background: currentColor;
}

.ai-chatbot__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--ai-chatbot-bg);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ai-chatbot__message {
	display: flex;
	max-width: 86%;
}

.ai-chatbot__message--user {
	align-self: flex-end;
}

.ai-chatbot__message--assistant {
	align-self: flex-start;
}

.ai-chatbot__bubble {
	padding: 10px 12px;
	border-radius: 8px;
	background: #fff;
	color: var(--ai-chatbot-dark);
	border: 1px solid rgba(17, 24, 39, .08);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.ai-chatbot__message--user .ai-chatbot__bubble {
	background: var(--ai-chatbot-color);
	border-color: var(--ai-chatbot-color);
	color: #fff;
}

.ai-chatbot__message--typing .ai-chatbot__bubble {
	display: flex;
	gap: 5px;
	padding: 13px 14px;
}

.ai-chatbot__message--typing span {
	width: 7px;
	height: 7px;
	border-radius: 999px;
	background: var(--ai-chatbot-muted);
	animation: ai-chatbot-breathe 1.2s infinite ease-in-out;
}

.ai-chatbot__message--typing span:nth-child(2) {
	animation-delay: .14s;
}

.ai-chatbot__message--typing span:nth-child(3) {
	animation-delay: .28s;
}

@keyframes ai-chatbot-breathe {
	0%, 80%, 100% {
		opacity: .35;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-4px);
	}
}

.ai-chatbot__form {
	border-top: 1px solid var(--ai-chatbot-border);
	background: #fff;
	padding: 10px;
}

.ai-chatbot__input {
	width: 100%;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 11px;
	border: 1px solid var(--ai-chatbot-border);
	border-radius: 8px;
	resize: none;
	color: var(--ai-chatbot-dark);
	background: #fff;
	font: inherit;
}

.ai-chatbot__input:focus {
	outline: 2px solid transparent;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
	border-color: var(--ai-chatbot-color);
}

.ai-chatbot__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 8px;
}

.ai-chatbot__counter {
	color: var(--ai-chatbot-muted);
	font-size: 12px;
}

.ai-chatbot__send {
	width: 40px;
	height: 36px;
	border: 0;
	border-radius: 6px;
	background: var(--ai-chatbot-color);
	color: #fff;
	cursor: pointer;
}

.ai-chatbot__send::before {
	content: "";
	position: absolute;
	left: 12px;
	top: 10px;
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
	border-left: 16px solid currentColor;
}

.ai-chatbot__send:disabled,
.ai-chatbot__input:disabled {
	opacity: .6;
	cursor: wait;
}

.ai-chatbot__retry {
	display: block;
	margin-top: 8px;
	padding: 6px 10px;
	border: 1px solid var(--ai-chatbot-color);
	border-radius: 6px;
	background: #fff;
	color: var(--ai-chatbot-color);
	cursor: pointer;
}

@media (max-width: 600px) {
	.ai-chatbot {
		inset: 0;
		bottom: 0;
		right: 0;
		left: 0;
		pointer-events: none;
	}

	.ai-chatbot__launcher {
		position: fixed;
		right: 16px;
		bottom: 16px;
		pointer-events: auto;
	}

	.ai-chatbot--left .ai-chatbot__launcher {
		left: 16px;
		right: auto;
	}

	.ai-chatbot__dialog {
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		border: 0;
		pointer-events: auto;
	}
}
