#aeps-ai-widget-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.aeps-ai-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: #021529;
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 16px 3px rgba(59, 130, 246, 0.55), 0 0 0 0 rgba(59, 130, 246, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, box-shadow 0.2s ease;
	animation: aeps-ai-glow-pulse 2.2s ease-in-out infinite;
}

.aeps-ai-bubble:hover {
	transform: scale(1.06);
}

.aeps-ai-bubble.is-muted {
	animation: none;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.aeps-ai-bubble-fallback-icon {
	width: 26px;
	height: 26px;
}

.aeps-ai-bubble.has-lottie .aeps-ai-bubble-fallback-icon {
	display: none;
}

.aeps-ai-bubble-lottie {
	width: 48px;
	height: 48px;
	pointer-events: none;
}

@keyframes aeps-ai-glow-pulse {
	0%, 100% {
		box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 0 16px 3px rgba(59, 130, 246, 0.5), 0 0 0 0 rgba(59, 130, 246, 0.55);
	}
	50% {
		box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3), 0 0 22px 6px rgba(59, 130, 246, 0.8), 0 0 0 12px rgba(59, 130, 246, 0);
	}
}

.aeps-ai-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 14px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(14px) scale(0.97);
	transform-origin: bottom right;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.aeps-ai-panel.is-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.aeps-ai-panel.aeps-ai-no-transition {
	transition: none;
}

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

.aeps-ai-header {
	background: #021529;
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
	font-size: 15px;
}

.aeps-ai-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	opacity: 0.8;
}

.aeps-ai-close:hover {
	opacity: 1;
}

.aeps-ai-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f5f7fa;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.aeps-ai-msg {
	max-width: 85%;
	padding: 9px 12px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: aeps-ai-msg-in 0.25s ease;
}

.aeps-ai-msg.aeps-ai-no-anim {
	animation: none;
}

@keyframes aeps-ai-msg-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.aeps-ai-msg-user {
	align-self: flex-end;
	background: #021529;
	color: #fff;
	border-bottom-right-radius: 3px;
}

.aeps-ai-msg-bot {
	align-self: flex-start;
	background: #fff;
	color: #1a1a1a;
	border: 1px solid #e2e6ea;
	border-bottom-left-radius: 3px;
}

.aeps-ai-msg-bot.aeps-ai-thinking {
	padding: 11px 14px;
}

.aeps-ai-typing-dots {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.aeps-ai-typing-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #a7afb8;
	animation: aeps-ai-typing-bounce 1.2s infinite ease-in-out;
}

.aeps-ai-typing-dots span:nth-child(2) {
	animation-delay: 0.15s;
}

.aeps-ai-typing-dots span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes aeps-ai-typing-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	30% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

.aeps-ai-msg-bot.aeps-ai-error {
	border-color: #e2b3b3;
	background: #fdf3f3;
	color: #a02323;
}

.aeps-ai-sources {
	margin-top: 8px;
	font-size: 11.5px;
	color: #555;
}

.aeps-ai-sources div {
	font-weight: 600;
	margin-bottom: 3px;
}

.aeps-ai-sources a {
	display: block;
	color: #0a5ab0;
	text-decoration: none;
	margin-bottom: 2px;
}

.aeps-ai-sources a:hover {
	text-decoration: underline;
}

.aeps-ai-rating {
	display: flex;
	gap: 4px;
	margin-top: 6px;
}

.aeps-ai-rate-btn {
	background: transparent;
	border: 1px solid transparent;
	border-radius: 6px;
	padding: 2px 6px;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.45;
	transition: opacity 0.15s ease, background 0.15s ease;
}

.aeps-ai-rate-btn:hover {
	opacity: 0.8;
	background: #f0f2f5;
}

.aeps-ai-rate-btn.is-active {
	opacity: 1;
	background: #eef3ff;
	border-color: #d5e0f5;
}

.aeps-ai-cta {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px dashed #e2e6ea;
}

.aeps-ai-cta-note {
	font-size: 11.5px;
	color: #777;
	margin-bottom: 6px;
}

.aeps-ai-cta-btn {
	display: inline-block;
	background: #f39c12;
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.aeps-ai-cta-btn:hover {
	background: #d98807;
}

.aeps-ai-inputbar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e2e6ea;
	background: #fff;
}

.aeps-ai-inputbar textarea {
	flex: 1;
	resize: none;
	border: 1px solid #dfe3e8;
	border-radius: 10px;
	padding: 9px 11px;
	font-size: 13.5px;
	font-family: inherit;
	max-height: 90px;
	min-height: 38px;
}

.aeps-ai-inputbar textarea:focus {
	outline: none;
	border-color: #021529;
}

.aeps-ai-send {
	background: #021529;
	color: #fff;
	border: none;
	border-radius: 10px;
	padding: 0 14px;
	height: 38px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.aeps-ai-send:disabled {
	opacity: 0.5;
	cursor: default;
}

@media (max-width: 480px) {
	.aeps-ai-panel {
		width: calc(100vw - 24px);
		right: -8px;
	}

	/* На мобильных клавиатура сдвигает видимую область экрана, а маленькое плавающее
	   окно этого не учитывает — низ (поле ввода, кнопка отправки) уезжает под клавиатуру.
	   Разворачиваем чат на весь экран и держим его высоту равной реальной видимой
	   области (см. --aeps-ai-vvh, выставляется в widget.js через visualViewport). */
	.aeps-ai-panel.is-open {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: 100%;
		height: var(--aeps-ai-vvh, 100dvh);
		max-height: none;
		border-radius: 0;
		transform: none;
	}

	.aeps-ai-panel.is-open ~ .aeps-ai-bubble {
		display: none;
	}

	.aeps-ai-inputbar {
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}

	/* Пока чат открыт на весь экран, страница за ним не должна скроллиться —
	   иначе фон "гуляет" одновременно с открытием клавиатуры. */
	body.aeps-ai-panel-open {
		overflow: hidden;
	}
}
