.ai-widget {
	position: fixed;
	z-index: 80;
	right: 30px;
	top: 50%;
	transform: translateY(-50%);
	touch-action: none;
	user-select: none;
}

.ai-widget.is-positioned {
	right: auto;
	bottom: auto;
	transform: none;
}

.ai-widget.is-dragging {
	z-index: 120;
}

.ai-widget-button {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 6px;
	border: 2px solid #6c7ebe;
	border-radius: 999px;
	background: #fff;
	color: #6c7ebe;
	box-shadow: 0 18px 38px rgba(108, 126, 190, 0.24);
	overflow: visible;
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
	isolation: isolate;
	cursor: grab;
}

.ai-widget-button:hover,
.ai-widget-button:focus-visible {
	transform: translateY(-3px);
	background: #fff;
	box-shadow: 0 24px 50px rgba(108, 126, 190, 0.32);
}

.ai-widget-button:focus-visible {
	outline: 3px solid rgba(108, 126, 190, 0.22);
	outline-offset: 4px;
}

.ai-widget.is-dragging .ai-widget-button {
	cursor: grabbing;
	transform: scale(0.98);
	box-shadow: 0 28px 54px rgba(15, 23, 42, 0.38);
}

.ai-widget-button::after {
	content: "";
	position: absolute;
	inset: 1px;
	border-radius: inherit;
	border: 1px solid rgba(108, 126, 190, 0.18);
	pointer-events: none;
}

.ai-widget-orbit {
	position: absolute;
	left: 7px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(108, 126, 190, 0.12);
	animation: aiWidgetPulse 2.4s ease-in-out infinite;
}

.ai-widget-icon {
	position: relative;
	z-index: 1;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #fff;
	color: #6c7ebe;
	border: 1px solid rgba(108, 126, 190, 0.28);
	display: grid;
	place-items: center;
	font-weight: 900;
	font-size: 15px;
	line-height: 1;
	letter-spacing: 0;
}

.ai-widget-text {
	position: absolute;
	top: 50%;
	right: 66px;
	z-index: 1;
	width: max-content;
	max-width: min(280px, calc(100vw - 120px));
	height: 38px;
	padding: 0 14px;
	border-radius: 999px;
	background: rgba(17, 24, 39, 0.94);
	color: #fff;
	display: flex;
	align-items: center;
	opacity: 0;
	transform: translateY(-50%) translateX(6px);
	pointer-events: none;
	font-weight: 800;
	font-size: 15px;
	line-height: 1;
	letter-spacing: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
	transition: opacity 0.16s ease, transform 0.2s ease;
}

.ai-widget.is-left-side .ai-widget-text {
	left: 66px;
	right: auto;
	transform: translateY(-50%) translateX(-6px);
}

.ai-widget-button:hover .ai-widget-text,
.ai-widget-button:focus-visible .ai-widget-text {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

.ai-widget-panel {
	position: fixed;
	z-index: 110;
	inset: 0;
	display: none;
	justify-content: flex-end;
	background: rgba(15, 23, 42, 0.12);
}

.ai-widget-panel.is-open {
	display: flex;
}

.ai-widget-window {
	position: relative;
	width: min(440px, 100vw);
	height: 100%;
	background: #f5f7fb;
	box-shadow: -28px 0 70px rgba(15, 23, 42, 0.22);
	display: flex;
	flex-direction: column;
	animation: aiWidgetPanelIn 0.24s ease both;
}

.ai-widget-header {
	min-height: 76px;
	padding: 16px 18px;
	background: #fff;
	border-bottom: 1px solid #e5e7eb;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

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

.ai-widget-brand strong {
	display: block;
	font-size: 17px;
	line-height: 1.2;
	color: #111827;
	letter-spacing: 0;
}

.ai-widget-brand span:not(.ai-widget-avatar) {
	display: block;
	margin-top: 3px;
	font-size: 12px;
	color: #6b7280;
}

.ai-widget-avatar,
.ai-widget-message-avatar {
	flex: 0 0 auto;
	border-radius: 50%;
	background: #fff;
	color: #6c7ebe;
	border: 1px solid rgba(108, 126, 190, 0.3);
	display: grid;
	place-items: center;
	font-weight: 900;
	letter-spacing: 0;
	box-shadow: 0 6px 16px rgba(108, 126, 190, 0.14);
}

.ai-widget-avatar {
	width: 40px;
	height: 40px;
	font-size: 13px;
}

.ai-widget-message-avatar {
	width: 32px;
	height: 32px;
	font-size: 11px;
}

.ai-widget-close {
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 10px;
	background: #f3f4f6;
	color: #111827;
	font-size: 24px;
	line-height: 1;
	display: grid;
	place-items: center;
	cursor: pointer;
}

.ai-widget-close:hover,
.ai-widget-close:focus-visible {
	background: #6c7ebe;
	color: #fff;
	outline: none;
}

.ai-widget-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.ai-widget-message-list {
	flex: 1;
	min-height: 0;
	padding: 18px 16px 120px;
	overflow-y: auto;
}

.ai-widget-message {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-bottom: 14px;
}

.ai-widget-bubble {
	max-width: calc(100% - 48px);
	padding: 15px 16px;
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	background: #fff;
	color: #111827;
	box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
	font-size: 14px;
	line-height: 1.65;
	word-break: keep-all;
}

.ai-widget-bubble p {
	margin: 0;
}

.ai-widget-bubble p + p {
	margin-top: 10px;
}

.ai-widget-composer {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 16px;
	min-height: 54px;
	padding: 12px 58px 12px 16px;
	border: 1px solid #e5e7eb;
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}

.ai-widget-composer textarea {
	width: 100%;
	min-height: 28px;
	max-height: 120px;
	border: 0;
	background: transparent;
	color: #111827;
	font: inherit;
	font-size: 14px;
	line-height: 1.55;
	resize: none;
	outline: none;
}

.ai-widget-composer textarea::placeholder {
	color: #8b96a8;
}

.ai-widget-send {
	position: absolute;
	right: 10px;
	bottom: 9px;
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 50%;
	background: #6c7ebe;
	color: #fff;
	font-size: 22px;
	font-weight: 900;
	line-height: 1;
	display: grid;
	place-items: center;
	cursor: pointer;
}

.ai-widget-send:disabled {
	background: #c3cadf;
	cursor: not-allowed;
}

.ai-widget-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

@keyframes aiWidgetPanelIn {
	from {
		transform: translateX(36px);
		opacity: 0.5;
	}

	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes aiWidgetPulse {
	0%,
	100% {
		transform: scale(1);
		opacity: 0.7;
	}

	50% {
		transform: scale(1.18);
		opacity: 0.28;
	}
}

@media (max-width: 900px) {
	.ai-widget {
		right: 16px;
		bottom: 18px;
		top: auto;
		transform: none;
	}

	.ai-widget.is-positioned {
		right: auto;
		bottom: auto;
	}

	.ai-widget-button {
		width: 64px;
		height: 64px;
		padding: 9px;
		border-radius: 50%;
	}

	.ai-widget-icon {
		width: 46px;
		height: 46px;
	}

	.ai-widget-text {
		display: none;
	}

	.ai-widget-window {
		width: 100vw;
	}

	.ai-widget-header {
		min-height: 70px;
		padding: 14px 16px;
	}

	.ai-widget-brand strong {
		font-size: 16px;
	}

	.ai-widget-message-list {
		padding: 16px 14px 112px;
	}

	.ai-widget-composer {
		left: 12px;
		right: 12px;
		bottom: 12px;
	}
}

.ai-widget-message.is-user {
	justify-content: flex-end;
}

.ai-widget-message.is-user .ai-widget-bubble {
	max-width: min(82%, 340px);
	border-color: rgba(108, 126, 190, 0.26);
	background: #6c7ebe;
	color: #fff;
	box-shadow: 0 12px 26px rgba(108, 126, 190, 0.22);
}

.ai-widget-message.is-loading .ai-widget-bubble {
	color: #5b6475;
}

.ai-widget-message.is-loading .ai-widget-bubble p::after {
	content: "";
	display: inline-block;
	width: 1.1em;
	margin-left: 2px;
	text-align: left;
	animation: aiWidgetDots 1.2s steps(4, end) infinite;
}

.ai-widget-message.is-error .ai-widget-bubble {
	border-color: rgba(220, 38, 38, 0.24);
	background: #fff7f7;
	color: #991b1b;
}

.ai-widget-sources {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 7px;
	margin-top: 12px;
	padding-top: 11px;
	border-top: 1px solid #edf0f5;
}

.ai-widget-sources > span {
	font-size: 12px;
	font-weight: 900;
	color: #6b7280;
}

.ai-widget-source {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	min-height: 30px;
	padding: 0 10px;
	border: 1px solid rgba(108, 126, 190, 0.28);
	border-radius: 999px;
	background: #fff;
	color: #5164a6;
	font-size: 12px;
	font-weight: 800;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ai-widget-source:hover,
.ai-widget-source:focus-visible {
	background: #6c7ebe;
	color: #fff;
	outline: none;
}

.ai-widget-source:disabled {
	cursor: default;
	background: #f7f8fb;
	color: #697386;
}

@keyframes aiWidgetDots {
	0% { content: ""; }
	25% { content: "."; }
	50% { content: ".."; }
	75%, 100% { content: "..."; }
}
