.ubb-chat {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 100000;
	display: flex;
	align-items: center;
	gap: 10px;
	font-family: inherit;
	color: #243024;
}

.ubb-chat .ubb-chat-toggle,
.ubb-chat .ubb-chat-send,
.ubb-chat .ubb-chat-close,
.ubb-chat .ubb-chat-suggestion {
	box-sizing: border-box;
	font-family: inherit;
	font-size: 14px;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
}

.ubb-chat .ubb-chat-toggle {
	display: grid;
	place-items: center;
	width: 56px;
	min-width: 56px;
	height: 56px;
	min-height: 56px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	flex-shrink: 0;
	background: var(--ast-global-color-0, #ffd936);
	color: var(--ast-global-color-2, #536942);
	box-shadow: 0 1px 2px rgba(36, 48, 36, 0.08), 0 6px 16px rgba(36, 48, 36, 0.12);
}

.ubb-chat-toggle svg {
	width: 31px;
	height: 31px;
	fill: currentColor;
}

.ubb-chat-hint {
	margin: 0;
	padding: 6px 10px;
	border-radius: 12px;
	background: #fff;
	color: var(--ast-global-color-2, #536942);
	font-size: 13px;
	line-height: 1.2;
	white-space: nowrap;
	box-shadow: 0 1px 2px rgba(36, 48, 36, 0.08), 0 4px 12px rgba(36, 48, 36, 0.1);
	pointer-events: none;
}

.ubb-chat-hint[hidden] {
	display: none;
}

.ubb-chat-toggle:focus-visible,
.ubb-chat-close:focus-visible,
.ubb-chat-send:focus-visible,
.ubb-chat-suggestion:focus-visible {
	outline: 2px solid var(--ast-global-color-2, #536942);
	outline-offset: 3px;
}

.ubb-chat-panel {
	position: absolute;
	right: 0;
	bottom: 68px;
	display: flex;
	flex-direction: column;
	width: min(400px, calc(100vw - 32px));
	height: min(600px, calc(100dvh - 120px));
	max-height: 600px;
	background: #fff;
	border: 1px solid #e4e6df;
	border-radius: 18px;
	box-shadow: 0 16px 40px rgba(36, 48, 36, 0.18);
	overflow: hidden;
}

.ubb-chat-panel[hidden] {
	display: none;
}

.ubb-chat-head {
	display: flex;
	flex-shrink: 0;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 12px;
	background: var(--ast-global-color-2, #536942);
	color: #fff;
}

.ubb-chat-head strong {
	display: block;
	font-size: 16px;
	line-height: 1.3;
}

.ubb-chat-sub {
	margin: 2px 0 0;
	color: rgba(255, 255, 255, 0.88);
	font-size: 14px;
}

.ubb-chat .ubb-chat-close {
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: #fff;
	min-height: 44px;
	padding: 8px 10px;
	font-weight: 600;
}

.ubb-chat-log {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 14px;
	background: #f7f6f1;
}

.ubb-chat-log .ubb-chat-msg:has(+ .ubb-chat-suggestions) {
	margin-bottom: 6px;
}

.ubb-chat-msg {
	margin: 0 0 10px;
	padding: 10px 12px;
	border-radius: 14px;
	line-height: 1.45;
	white-space: normal;
	overflow-wrap: anywhere;
}

.ubb-chat-msg-bot,
.ubb-chat-msg-error,
.ubb-chat-msg-pending {
	background: #fff;
	border: 1px solid #e4e6df;
}

.ubb-chat-msg-user {
	background: var(--ast-global-color-0, #ffd936);
	margin-left: 28px;
	white-space: pre-wrap;
}

.ubb-chat-msg a {
	color: var(--ast-global-color-2, #536942);
	font-weight: 700;
}

.ubb-chat-suggestions:not([hidden]) {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 6px;
	max-width: 100%;
	margin: 0 0 10px;
}

.ubb-chat-suggestions[hidden] {
	display: none;
}

.ubb-chat .ubb-chat-suggestion {
	flex: 0 1 auto;
	max-width: 100%;
	border: 1px solid rgba(83, 105, 66, 0.35);
	border-radius: 999px;
	background: #fff;
	color: var(--ast-global-color-2, #536942);
	box-shadow: none;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	min-height: 0;
	min-width: 0;
	padding: 6px 10px;
	text-align: left;
	white-space: normal;
}

@media (hover: hover) {
	.ubb-chat .ubb-chat-suggestion:hover {
		background: rgba(83, 105, 66, 0.08);
		border-color: rgba(83, 105, 66, 0.55);
	}
}

.ubb-chat-typing {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 1.15em;
	vertical-align: -0.1em;
}

.ubb-chat-msg .ubb-chat-typing:not(:first-child) {
	margin-left: 6px;
}

.ubb-chat-typing-dot {
	display: block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.75;
}

.ubb-chat-typing-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.ubb-chat-form {
	display: grid;
	flex-shrink: 0;
	grid-template-columns: 1fr auto;
	gap: 8px;
	padding: 12px;
	padding-bottom: calc(12px + env(safe-area-inset-bottom));
	background: #fff;
	border-top: 1px solid #e4e6df;
}

.ubb-chat-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

.ubb-chat .ubb-chat-input {
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	resize: none;
	border: 1px solid #d5d8ce;
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	color: inherit;
	background: #fff;
}

.ubb-chat .ubb-chat-input:focus {
	outline: none;
	border-color: var(--ast-global-color-2, #536942);
	box-shadow: 0 1px 2px rgba(83, 105, 66, 0.16);
}

.ubb-chat .ubb-chat-send {
	border: 0;
	border-radius: 12px;
	background: var(--ast-global-color-2, #536942);
	color: #fff;
	font-weight: 700;
	min-height: 44px;
	padding: 0 14px;
}

.ubb-chat-send:disabled,
.ubb-chat-suggestion:disabled,
.ubb-chat .ubb-chat-input:disabled {
	opacity: 0.6;
	cursor: progress;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.ubb-chat .ubb-chat-toggle {
		transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
	}

	.ubb-chat .ubb-chat-suggestion {
		transition: background-color 120ms ease, border-color 120ms ease;
	}

	.ubb-chat .ubb-chat-toggle:hover {
		background: var(--ast-global-color-1, #dab200);
		transform: translateY(-1px) scale(1.02);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.ubb-chat-hint:not([hidden]) {
		animation: ubb-chat-hint-in 220ms ease;
	}

	.ubb-chat-hint.is-leaving {
		animation: ubb-chat-hint-out 220ms ease forwards;
	}

	.ubb-chat-panel {
		animation: ubb-chat-in 160ms ease;
	}

	.ubb-chat-typing-dot {
		animation: ubb-chat-dot 1.05s infinite ease-in-out;
	}

	.ubb-chat-typing-dot:nth-child(3) {
		animation-delay: 0.15s;
	}

	.ubb-chat-typing-dot:nth-child(4) {
		animation-delay: 0.3s;
	}
}

@keyframes ubb-chat-hint-in {
	from {
		opacity: 0;
		transform: translateX(6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ubb-chat-hint-out {
	from {
		opacity: 1;
		transform: none;
	}

	to {
		opacity: 0;
		transform: translateX(6px);
	}
}

@keyframes ubb-chat-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ubb-chat-dot {
	0%,
	80%,
	100% {
		opacity: 0.3;
	}

	40% {
		opacity: 1;
	}
}

@media (max-width: 640px) {
	.ubb-chat {
		right: 12px;
		bottom: calc(12px + env(safe-area-inset-bottom));
	}

	.ubb-chat-panel {
		width: calc(100vw - 16px);
		height: min(78dvh, calc(100dvh - 96px - env(safe-area-inset-bottom)));
		max-height: none;
	}
}

@media (max-width: 380px) {
	.ubb-chat {
		right: 8px;
	}

	.ubb-chat-panel {
		width: calc(100vw - 8px);
		height: calc(100dvh - 80px - env(safe-area-inset-bottom));
	}
}

/* Astra « remonter » : au-dessus de la bulle, écart 12px. */
body:has(.ubb-chat) #ast-scroll-top.ast-scroll-to-top-right {
	bottom: calc(20px + 56px + 12px);
	z-index: 99999;
}

@media (max-width: 640px) {
	body:has(.ubb-chat) #ast-scroll-top.ast-scroll-to-top-right {
		bottom: calc(12px + 56px + 12px + env(safe-area-inset-bottom));
	}
}

@media (max-width: 380px) {
	body:has(.ubb-chat) #ast-scroll-top.ast-scroll-to-top-right {
		bottom: calc(8px + 56px + 12px + env(safe-area-inset-bottom));
		right: 18px;
	}
}

/* Mobile : le panneau suit la zone visible (clavier inclus), le titre reste à l'écran. */
@media (max-width: 640px) {
	.ubb-chat-panel.is-fitted {
		position: fixed;
		top: calc(var(--ubb-vv-offset, 0px) + 8px);
		left: 8px;
		right: 8px;
		bottom: auto;
		width: auto;
		height: var(--ubb-vv-height, 70dvh);
		max-height: var(--ubb-vv-height, 70dvh);
	}
}
