.ai-chat {
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}

.ai-chat--right { right: 20px; }
.ai-chat--left  { left: 20px; }

.ai-chat__toggle {
	width: 58px;
	height: 58px;
	border: 0;
	border-radius: 50%;
	background: var(--ai-chat-accent, #2563eb);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
	transition: transform .15s ease, box-shadow .15s ease;
}
.ai-chat__toggle:hover { transform: translateY(-2px); }
.ai-chat__toggle:focus-visible { outline: 3px solid rgba(0,0,0,.25); outline-offset: 2px; }

.ai-chat__icon-close { display: none; }
.ai-chat.is-open .ai-chat__icon-open  { display: none; }
.ai-chat.is-open .ai-chat__icon-close { display: block; }

.ai-chat__panel {
	position: absolute;
	bottom: 74px;
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 130px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	color: #1f2937;
	text-align: left;
}
.ai-chat__panel[hidden] { display: none; }
.ai-chat--right .ai-chat__panel { right: 0; }
.ai-chat--left  .ai-chat__panel { left: 0; }

.ai-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 16px;
	background: var(--ai-chat-accent, #2563eb);
	color: #fff;
	font-weight: 600;
}
.ai-chat__close {
	background: transparent;
	border: 0;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	opacity: .85;
}
.ai-chat__close:hover { opacity: 1; }

.ai-chat__messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f8fafc;
}

.ai-chat__bubble {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.ai-chat__bubble--bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}
.ai-chat__bubble--user {
	align-self: flex-end;
	background: var(--ai-chat-accent, #2563eb);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ai-chat__bubble--error {
	background: #fef2f2;
	border-color: #fecaca;
	color: #991b1b;
}
.ai-chat__bubble.is-typing {
	letter-spacing: 3px;
	animation: ai-chat-pulse 1.1s ease-in-out infinite;
}
@keyframes ai-chat-pulse {
	0%, 100% { opacity: .35; }
	50%      { opacity: 1; }
}

.ai-chat__form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}
.ai-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 15px;
	color: inherit;
	background: #fff;
}
.ai-chat__input:focus {
	outline: none;
	border-color: var(--ai-chat-accent, #2563eb);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.ai-chat__send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 10px;
	background: var(--ai-chat-accent, #2563eb);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.ai-chat__send:disabled { opacity: .55; cursor: default; }

@media (max-width: 480px) {
	.ai-chat { bottom: 14px; }
	.ai-chat--right { right: 14px; }
	.ai-chat--left  { left: 14px; }
	.ai-chat__panel {
		width: calc(100vw - 28px);
		height: calc(100vh - 120px);
		max-height: none;
		bottom: 70px;
	}
	.ai-chat--right .ai-chat__panel { right: 0; }
	.ai-chat--left  .ai-chat__panel { left: 0; }
}