.lag-guide {
	--lag-pink: #f4479d;
	--lag-blue: #2a9df4;
	--lag-yellow: #ffd34e;
	--lag-ink: #37234f;
	--lag-panel: #ffffff;
	--lag-bubble-border: rgba(244, 71, 157, 0.22);
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 9999;
	display: flex;
	align-items: center;
	gap: 14px;
	max-width: min(92vw, 380px);
	font-family: inherit;
}

.lag-guide--left {
	right: auto;
	left: 18px;
	flex-direction: row-reverse;
}

.lag-guide--inline {
	position: relative;
	right: auto;
	bottom: auto;
	left: auto;
	z-index: 1;
	display: inline-flex;
	margin: 16px 0;
}

.lag-guide__avatar {
	position: relative;
	width: 92px;
	height: 92px;
	padding: 0;
	border: 4px solid #ffffff;
	border-radius: 50%;
	background: radial-gradient(circle at 50% 40%, #ffffff 0%, #fff3bd 62%, #fedb67 100%);
	box-shadow: 0 10px 28px rgba(55, 35, 79, 0.22);
	cursor: pointer;
	overflow: hidden;
	transition: transform 180ms ease, box-shadow 180ms ease;
}

.lag-guide__avatar:hover,
.lag-guide__avatar:focus-visible {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 14px 32px rgba(55, 35, 79, 0.26);
	outline: 3px solid rgba(42, 157, 244, 0.25);
	outline-offset: 3px;
}

.lag-guide__avatar img {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 132%;
	height: 132%;
	object-fit: contain;
	object-position: center center;
	pointer-events: none;
	transform: translate(-50%, -56%);
}

.lag-guide__bubble {
	position: relative;
	width: min(270px, calc(92vw - 120px));
	padding: 16px;
	border: 3px solid var(--lag-bubble-border);
	border-radius: 28px;
	background: var(--lag-panel);
	box-shadow: 0 14px 34px rgba(55, 35, 79, 0.18);
	color: var(--lag-ink);
	z-index: 0;
}

.lag-guide__bubble::before,
.lag-guide__bubble::after {
	content: "";
	position: absolute;
	display: block;
	pointer-events: none;
	width: 0;
	height: 0;
	background: transparent;
}

.lag-guide__bubble::before {
	right: -22px;
	top: 50%;
	border-top: 17px solid transparent;
	border-bottom: 17px solid transparent;
	border-left: 22px solid var(--lag-bubble-border);
	filter: drop-shadow(5px 6px 8px rgba(55, 35, 79, 0.08));
	transform: translateY(-50%);
	z-index: 1;
}

.lag-guide__bubble::after {
	right: -17px;
	top: 50%;
	border-top: 14px solid transparent;
	border-bottom: 14px solid transparent;
	border-left: 18px solid var(--lag-panel);
	transform: translateY(-50%);
	z-index: 2;
}

.lag-guide--left .lag-guide__bubble::before,
.lag-guide--left .lag-guide__bubble::after {
	right: auto;
	border-left: 0;
}

.lag-guide--left .lag-guide__bubble::before {
	left: -22px;
	border-right: 22px solid var(--lag-bubble-border);
}

.lag-guide--left .lag-guide__bubble::after {
	left: -17px;
	border-right: 18px solid var(--lag-panel);
}

.lag-guide__bubble[hidden] {
	display: none;
}

.lag-guide__message {
	position: relative;
	z-index: 1;
	margin: 0;
	font-size: 16px;
	line-height: 1.35;
	font-weight: 700;
}

.lag-guide__actions {
	position: relative;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.lag-guide__button {
	min-height: 38px;
	padding: 8px 13px;
	border: 0;
	border-radius: 999px;
	background: var(--lag-blue);
	color: #ffffff;
	font: inherit;
	font-size: 14px;
	font-weight: 800;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(42, 157, 244, 0.22);
}

.lag-guide__button--soft {
	background: #ffffff;
	color: var(--lag-ink);
	border: 2px solid rgba(42, 157, 244, 0.2);
	box-shadow: none;
}

.lag-guide__button:hover,
.lag-guide__button:focus-visible {
	filter: brightness(1.04);
	outline: 3px solid rgba(255, 211, 78, 0.55);
	outline-offset: 2px;
}

.lag-guide__minimize {
	position: absolute;
	right: 2px;
	top: -7px;
	width: 28px;
	height: 28px;
	border: 2px solid #ffffff;
	border-radius: 50%;
	background: var(--lag-pink);
	color: #ffffff;
	font-size: 18px;
	font-weight: 800;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 5px 14px rgba(55, 35, 79, 0.2);
}

.lag-guide--left .lag-guide__minimize {
	right: auto;
	left: 2px;
}

.lag-guide--speaking .lag-guide__avatar {
	animation: lag-wave 900ms ease;
}

.lag-guide--minimized .lag-guide__bubble,
.lag-guide--minimized .lag-guide__minimize {
	display: none;
}

.lag-guide--minimized .lag-guide__avatar {
	width: 62px;
	height: 62px;
}

@keyframes lag-wave {
	0%,
	100% {
		transform: rotate(0deg) scale(1);
	}
	30% {
		transform: rotate(-3deg) scale(1.04);
	}
	60% {
		transform: rotate(3deg) scale(1.04);
	}
}

@media (max-width: 520px) {
	.lag-guide {
		right: 10px;
		bottom: 10px;
		gap: 12px;
	}

	.lag-guide--left {
		left: 10px;
		right: auto;
	}

	.lag-guide__avatar {
		width: 76px;
		height: 76px;
	}

	.lag-guide__bubble {
		width: min(230px, calc(100vw - 104px));
		padding: 12px;
		border-radius: 24px;
	}

	.lag-guide__bubble::before,
	.lag-guide__bubble::after {
		transform: translateY(-50%);
	}

	.lag-guide__bubble::before {
		right: -18px;
		top: 50%;
		border-top-width: 14px;
		border-bottom-width: 14px;
		border-left-width: 18px;
	}

	.lag-guide__bubble::after {
		right: -14px;
		top: 50%;
		border-top-width: 11px;
		border-bottom-width: 11px;
		border-left-width: 14px;
	}

	.lag-guide--left .lag-guide__bubble::before {
		left: -18px;
		right: auto;
		border-right-width: 18px;
	}

	.lag-guide--left .lag-guide__bubble::after {
		left: -14px;
		right: auto;
		border-right-width: 14px;
	}

	.lag-guide__message {
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lag-guide *,
	.lag-guide--speaking .lag-guide__avatar {
		animation: none;
		transition: none;
	}
}
