.aichat-widget {
	--aichat-primary: #00453f;
	--aichat-primary-fg: #fdfbf8;
	--aichat-action: #00453f;
	--aichat-action-fg: #fdfbf8;
	--aichat-headline: #00453f;
	--aichat-body: #656767;
	--aichat-bg: #fffdf8;
	--aichat-bg-secondary: #f0f7f0;
	--aichat-bot-bubble: #f9f9f9;
	--aichat-border: #e5e9ed;
	--aichat-fg: #1e1f1f;
	--aichat-muted: #656767;
	--aichat-radius: 16px;
	--aichat-radius-pill: 32px;
	--aichat-radius-bubble: 8px;
	--aichat-shadow: 0 16px 48px rgba(30, 31, 31, 0.14);
	--aichat-font: "Open Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
	--aichat-font-ui: "Poppins", var(--aichat-font);

	font-family: var(--aichat-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--aichat-fg);
	box-sizing: border-box;
}

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

.aichat-widget--floating {
	--aichat-sidebar-width: min(600px, calc(100vw - 16px));
	--aichat-slide-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--aichat-anim-panel: 0.65s;
	--aichat-anim-launcher: 0.55s;
	--aichat-anim-launcher-in: 0.85s;
	--aichat-anim-fade: 0.45s;
	--aichat-anim-fade-in: 0.7s;
	position: fixed;
	inset: 0;
	z-index: 99999;
	pointer-events: none;
}

.aichat-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(30, 31, 31, 0.28);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity var(--aichat-anim-fade) ease,
		visibility var(--aichat-anim-fade) ease;
}

.aichat-widget--floating.is-open {
	pointer-events: auto;
}

.aichat-widget--floating.is-open .aichat-backdrop {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.aichat-launcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 100000;
	height: 48px;
	min-width: 48px;
	border: 1px solid var(--aichat-border);
	border-radius: var(--aichat-radius-pill);
	background: var(--aichat-bg);
	color: var(--aichat-primary-fg);
	padding: 0 16px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	box-shadow: var(--aichat-shadow);
	pointer-events: auto;
	overflow: hidden;
	font-family: var(--aichat-font-ui);
	font-size: 16px;
	font-weight: 500;
	line-height: 18px;
	white-space: nowrap;
	transition:
		background var(--aichat-anim-fade) ease,
		border-color var(--aichat-anim-fade) ease,
		gap var(--aichat-anim-launcher) var(--aichat-slide-ease),
		padding var(--aichat-anim-launcher) var(--aichat-slide-ease),
		height var(--aichat-anim-launcher) var(--aichat-slide-ease),
		min-width var(--aichat-anim-launcher) var(--aichat-slide-ease),
		opacity var(--aichat-anim-fade) ease,
		visibility var(--aichat-anim-fade) ease,
		transform var(--aichat-anim-fade) ease;
}

.aichat-launcher__icon {
	position: relative;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border-radius: 50%;
}

.aichat-launcher__img {
	width: 16px;
	height: 16px;
	object-fit: contain;
	display: block;
}

.aichat-launcher--custom-icon {
	height: 56px;
	min-width: 56px;
	padding: 0 10px;
}

.aichat-launcher--custom-icon .aichat-launcher__icon {
	width: 44px;
	height: 44px;
}

.aichat-launcher--custom-icon .aichat-launcher__img {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	object-fit: cover;
	/* Crop padded uploads so the face fills the circle */
	transform: scale(1.75);
}

.aichat-launcher__img--hover {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity var(--aichat-anim-fade) ease;
}

.aichat-launcher__img--default {
	opacity: 1;
	transition: opacity var(--aichat-anim-fade) ease;
}

.aichat-launcher__label {
	display: inline-block;
	max-width: 0;
	opacity: 0;
	overflow: hidden;
	white-space: nowrap;
	color: var(--aichat-primary-fg);
	transform: translateX(-6px);
	/* Hover-out timing (leaving :hover uses this rule) */
	transition:
		max-width var(--aichat-anim-launcher) var(--aichat-slide-ease),
		opacity var(--aichat-anim-fade) ease,
		transform var(--aichat-anim-launcher) var(--aichat-slide-ease);
}

.aichat-launcher:hover,
.aichat-launcher:focus-visible {
	background: var(--aichat-primary);
	border-color: var(--aichat-primary);
	gap: 8px;
	padding: 0 18px 0 12px;
	outline: none;
	/* Hover-in timing (entering :hover uses this rule) */
	transition:
		background var(--aichat-anim-fade-in) ease,
		border-color var(--aichat-anim-fade-in) ease,
		gap var(--aichat-anim-launcher-in) var(--aichat-slide-ease),
		padding var(--aichat-anim-launcher-in) var(--aichat-slide-ease),
		height var(--aichat-anim-launcher-in) var(--aichat-slide-ease),
		min-width var(--aichat-anim-launcher-in) var(--aichat-slide-ease),
		opacity var(--aichat-anim-fade-in) ease,
		visibility var(--aichat-anim-fade-in) ease,
		transform var(--aichat-anim-fade-in) ease;
}

.aichat-launcher--custom-icon:hover,
.aichat-launcher--custom-icon:focus-visible {
	padding: 0 18px 0 8px;
}

.aichat-launcher:hover .aichat-launcher__img--default,
.aichat-launcher:focus-visible .aichat-launcher__img--default {
	opacity: 0;
	transition: opacity var(--aichat-anim-fade-in) ease;
}

.aichat-launcher:hover .aichat-launcher__img--hover,
.aichat-launcher:focus-visible .aichat-launcher__img--hover {
	opacity: 1;
	transition: opacity var(--aichat-anim-fade-in) ease;
}

.aichat-launcher:hover .aichat-launcher__label,
.aichat-launcher:focus-visible .aichat-launcher__label {
	max-width: 240px;
	opacity: 1;
	transform: translateX(0);
	transition:
		max-width var(--aichat-anim-launcher-in) var(--aichat-slide-ease),
		opacity var(--aichat-anim-fade-in) ease 0.08s,
		transform var(--aichat-anim-launcher-in) var(--aichat-slide-ease);
}

.aichat-launcher__typing {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	gap: 5px;
	pointer-events: none;
}

.aichat-launcher__typing[hidden] {
	display: none !important;
}

.aichat-launcher__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aichat-primary-fg);
	opacity: 0.35;
	animation: aichat-typing-dot 1.2s ease-in-out infinite;
}

.aichat-launcher__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.aichat-launcher__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

.aichat-launcher.is-waiting,
.aichat-launcher.is-waiting:hover,
.aichat-launcher.is-waiting:focus-visible {
	overflow: visible;
	background: var(--aichat-primary);
	border-color: var(--aichat-primary);
	gap: 0;
	padding: 0 16px;
}

.aichat-launcher.is-waiting.aichat-launcher--custom-icon,
.aichat-launcher.is-waiting.aichat-launcher--custom-icon:hover,
.aichat-launcher.is-waiting.aichat-launcher--custom-icon:focus-visible {
	padding: 0 10px;
}

.aichat-launcher.is-waiting .aichat-launcher__icon,
.aichat-launcher.is-waiting .aichat-launcher__label {
	opacity: 0;
}

.aichat-launcher.is-waiting .aichat-launcher__typing {
	display: flex;
}

.aichat-launcher.has-unread {
	overflow: visible;
	border-color: var(--aichat-primary);
	box-shadow:
		0 0 0 2px var(--aichat-primary),
		0 0 12px var(--aichat-primary),
		0 0 24px var(--aichat-primary),
		var(--aichat-shadow);
	animation: aichat-glow-pulse 2s ease-in-out infinite;
}

@keyframes aichat-typing-dot {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

@keyframes aichat-glow-pulse {
	0%,
	100% {
		box-shadow:
			0 0 0 2px var(--aichat-primary),
			0 0 8px var(--aichat-primary),
			0 0 18px var(--aichat-primary),
			var(--aichat-shadow);
	}
	50% {
		box-shadow:
			0 0 0 3px var(--aichat-primary),
			0 0 16px var(--aichat-primary),
			0 0 32px var(--aichat-primary),
			var(--aichat-shadow);
	}
}

.aichat-widget--floating.is-open .aichat-launcher {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: scale(0.92);
}

/* Mobile / touch: keep circular button, but solid primary color (no hover expand) */
@media (hover: none), (max-width: 768px) {
	.aichat-launcher {
		background: var(--aichat-primary);
		border-color: var(--aichat-primary);
		gap: 0;
		padding: 0 16px;
		overflow: visible;
	}

	.aichat-launcher--custom-icon {
		padding: 0 10px;
	}

	.aichat-launcher__img--default {
		opacity: 0;
	}

	.aichat-launcher__img--hover {
		opacity: 1;
	}

	.aichat-launcher__label {
		max-width: 0;
		opacity: 0;
		transform: translateX(-6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.aichat-launcher,
	.aichat-launcher__label,
	.aichat-launcher__img--default,
	.aichat-launcher__img--hover {
		transition: none !important;
	}

	.aichat-launcher__typing span,
	.aichat-launcher.has-unread {
		animation: none !important;
	}
}

.aichat-avatar {
	width: 40px;
	height: 40px;
	border-radius: var(--aichat-radius-pill);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	padding: 0 12px;
}

.aichat-avatar img {
	width: 16px;
	height: 16px;
	display: block;
}

.aichat-avatar--bot {
	background: var(--aichat-bg-secondary);
}

.aichat-avatar--bot.aichat-avatar--custom {
	padding: 0;
	overflow: hidden;
}

.aichat-avatar--bot.aichat-avatar--custom img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	/* Match launcher crop for padded uploads */
	transform: scale(1.75);
}

.aichat-avatar--user {
	background: #fff;
	border: 1px solid var(--aichat-border);
}

.aichat-panel {
	display: flex;
	flex-direction: column;
	background: var(--aichat-bg);
	border: 1px solid var(--aichat-border);
	overflow: hidden;
}

.aichat-widget--floating .aichat-panel {
	position: absolute;
	top: 7px;
	right: 8px;
	bottom: 7px;
	width: var(--aichat-sidebar-width);
	height: auto;
	border-radius: var(--aichat-radius);
	border: 1px solid var(--aichat-border);
	box-shadow: -12px 0 40px rgba(30, 31, 31, 0.18);
	transform: translateX(calc(100% + 8px));
	visibility: hidden;
	pointer-events: none;
	transition:
		transform var(--aichat-anim-panel) var(--aichat-slide-ease),
		visibility var(--aichat-anim-panel) var(--aichat-slide-ease);
	will-change: transform;
}

.aichat-widget--floating.is-open .aichat-panel {
	transform: translateX(0);
	visibility: visible;
	pointer-events: auto;
}

.aichat-widget--inline .aichat-panel {
	width: 100%;
	max-width: 420px;
	height: 640px;
	margin: 1rem 0;
	border-radius: var(--aichat-radius);
	box-shadow: none;
}

.aichat-widget--inline .aichat-panel--hidden,
.aichat-widget--inline .aichat-panel[hidden] {
	display: none !important;
}

@media (max-width: 480px) {
	.aichat-widget--floating {
		--aichat-sidebar-width: calc(100vw - 16px);
	}
}

.aichat-panel__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	background: var(--aichat-bg);
	border-bottom: 1px solid var(--aichat-border);
	flex-shrink: 0;
}

.aichat-panel__heading {
	flex: 1;
	min-width: 0;
}

.aichat-panel__title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.5;
	color: var(--aichat-headline);
	word-break: break-word;
}

.aichat-panel__subtitle {
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--aichat-body);
}

.aichat-panel__close {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: var(--aichat-radius-pill);
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
}

.aichat-panel__close:hover,
.aichat-panel__close:focus-visible {
	background: var(--aichat-bg-secondary);
	outline: none;
}

.aichat-panel__close img {
	width: 16px;
	height: 16px;
	display: block;
}

.aichat-panel__messages {
	flex: 1;
	overflow-x: hidden;
	overflow-y: auto;
	padding: 32px 16px;
	display: flex;
	flex-direction: column;
	gap: 20px;
	background: var(--aichat-bg);
}

.aichat-row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	width: 100%;
}

.aichat-row--user {
	justify-content: flex-end;
}

.aichat-row--bot,
.aichat-row--error,
.aichat-row--status {
	justify-content: flex-start;
}

.aichat-row__body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
	flex: 1;
}

.aichat-row--user .aichat-row__body {
	align-items: flex-end;
	flex: 0 1 auto;
	max-width: calc(100% - 48px);
}

.aichat-row--bot .aichat-row__body {
	padding-right: 48px;
}

.aichat-bubble {
	padding: 12px;
	border-radius: var(--aichat-radius-bubble);
	word-wrap: break-word;
	white-space: pre-wrap;
	font-size: 14px;
	line-height: 1.5;
	max-width: 100%;
	color: var(--aichat-body);
}

.aichat-row--user .aichat-bubble {
	max-width: 250px;
	background: var(--aichat-bot-bubble);
	color: var(--aichat-body);
	border-radius: 8px 2px 8px 8px;
}

.aichat-row--bot .aichat-bubble {
	background: transparent;
	padding: 0;
	border-radius: 0;
	color: var(--aichat-body);
}

.aichat-bubble p {
	margin: 0 0 16px;
}

.aichat-bubble p:last-child {
	margin-bottom: 0;
}

.aichat-bubble strong {
	font-weight: 700;
	color: var(--aichat-headline);
}

.aichat-bubble a {
	color: var(--aichat-action);
	text-decoration: underline;
}

.aichat-row--error .aichat-bubble {
	background: #fde8e8;
	color: #7f1d1d;
	border-radius: 8px;
}

.aichat-row--status {
	justify-content: center;
}

.aichat-row--status .aichat-bubble {
	background: transparent;
	color: var(--aichat-body);
	font-size: 12px;
	padding: 4px;
	text-align: center;
}

.aichat-card {
	background: var(--aichat-bot-bubble);
	border: 0.8px solid var(--aichat-border);
	border-radius: 8px;
	overflow: hidden;
	width: 100%;
	max-width: 295px;
}

.aichat-card__media {
	width: 100%;
	aspect-ratio: 16 / 10;
	background: var(--aichat-bg-secondary);
	overflow: hidden;
}

.aichat-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.aichat-card__inner {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 12px;
}

.aichat-card__title {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.5;
	color: var(--aichat-headline);
}

.aichat-card__desc {
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--aichat-body);
}

.aichat-card__actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.aichat-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	padding: 0 24px;
	border-radius: var(--aichat-radius-pill);
	font-family: var(--aichat-font-ui);
	font-size: 14px;
	font-weight: 500;
	line-height: 18px;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	box-sizing: border-box;
	width: 100%;
}

.aichat-btn--primary {
	background: var(--aichat-action);
	color: var(--aichat-action-fg);
	border-color: var(--aichat-action);
}

.aichat-btn--primary:hover,
.aichat-btn--primary:focus-visible {
	opacity: 0.92;
	outline: none;
}

.aichat-btn--secondary {
	background: var(--aichat-bg);
	color: var(--aichat-action);
	border-color: var(--aichat-action);
}

.aichat-btn--secondary:hover,
.aichat-btn--secondary:focus-visible {
	background: var(--aichat-bg-secondary);
	outline: none;
}

.aichat-chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	padding: 0 16px;
	border: 1px solid var(--aichat-border);
	border-radius: var(--aichat-radius-pill);
	background: var(--aichat-bg);
	color: var(--aichat-muted);
	font-family: var(--aichat-font-ui);
	font-size: 14px;
	font-weight: 400;
	line-height: 18px;
	cursor: pointer;
	text-align: left;
}

.aichat-chip:hover,
.aichat-chip:focus-visible {
	border-color: var(--aichat-action);
	color: var(--aichat-action);
	outline: none;
}

.aichat-panel__footer {
	padding: 24px 16px;
	background: var(--aichat-bg);
	flex-shrink: 0;
}

.aichat-panel__form {
	display: flex;
	align-items: center;
	gap: 9px;
	width: 100%;
	padding: 16px;
	border: 1px solid var(--aichat-border);
	border-radius: var(--aichat-radius-pill);
	background: var(--aichat-bg);
	position: relative;
}

.aichat-panel__input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	color: var(--aichat-fg);
	font-family: inherit;
	font-size: 16px;
	line-height: 28px;
	outline: none;
	padding: 0;
}

.aichat-panel__input::placeholder {
	color: var(--aichat-muted);
	opacity: 0.5;
}

.aichat-panel__send {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: var(--aichat-radius-pill);
	background: var(--aichat-action);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
	opacity: 0.5;
	transition: opacity 0.15s ease;
}

.aichat-panel__send.is-active {
	opacity: 1;
}

.aichat-panel__send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.aichat-panel__send img {
	width: 16px;
	height: 16px;
	display: block;
	filter: brightness(0) invert(1);
}

.aichat-honeypot {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.aichat-widget .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* Prevent page jump when scrollbar is hidden while sidebar is open */
html.aichat-sidebar-open {
	overflow: hidden;
	padding-right: var(--aichat-sb-gap, 0px);
}

html.aichat-sidebar-open body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.aichat-widget--floating .aichat-panel,
	.aichat-backdrop,
	.aichat-launcher {
		transition: none !important;
	}
}
