.awai-root,
.awai-root * {
	box-sizing: border-box;
}

.awai-root {
	--awai-primary: #397dff;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: #18212f;
}

.awai-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--awai-primary);
	box-shadow: 0 12px 30px rgba(26, 47, 87, 0.24);
	color: #fff;
	font: 700 14px/1 inherit;
	cursor: pointer;
	transition: transform 160ms ease, box-shadow 160ms ease;
}

.awai-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 15px 34px rgba(26, 47, 87, 0.3);
}

.awai-launcher:focus-visible,
.awai-close:focus-visible,
.awai-send:focus-visible,
.awai-input:focus-visible,
.awai-privacy:focus-visible {
	outline: 3px solid #ffca48;
	outline-offset: 3px;
}

.awai-launcher-icon {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	font-size: 16px;
}

.awai-panel {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	width: min(410px, calc(100vw - 32px));
	height: min(680px, calc(100vh - 48px));
	overflow: hidden;
	border: 1px solid rgba(17, 35, 62, 0.1);
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 24px 70px rgba(15, 31, 56, 0.25);
}

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

.awai-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 82px;
	padding: 16px 18px;
	background: linear-gradient(135deg, var(--awai-primary), #265cc9);
	color: #fff;
}

.awai-identity {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.awai-mark,
.awai-header-image {
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: #fff;
	object-fit: contain;
}

.awai-mark {
	display: grid;
	place-items: center;
	color: var(--awai-primary);
	font-size: 22px;
	font-weight: 800;
}

.awai-titles {
	display: grid;
	gap: 2px;
	min-width: 0;
}

.awai-title {
	font-size: 17px;
	line-height: 1.2;
}

.awai-subtitle {
	max-width: 270px;
	opacity: 0.88;
	font-size: 11px;
	line-height: 1.3;
}

.awai-close {
	flex: 0 0 38px;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font: 300 28px/36px inherit;
	cursor: pointer;
}

.awai-messages {
	overflow-y: auto;
	padding: 18px;
	background: #f5f7fb;
	overscroll-behavior: contain;
}

.awai-row {
	display: flex;
	margin: 0 0 12px;
}

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

.awai-bubble {
	max-width: 86%;
	padding: 11px 14px;
	border-radius: 16px 16px 16px 5px;
	background: #fff;
	box-shadow: 0 3px 12px rgba(25, 43, 70, 0.07);
	color: #1d2a3c;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.awai-row-user .awai-bubble {
	border-radius: 16px 16px 5px 16px;
	background: var(--awai-primary);
	color: #fff;
}

.awai-row-error .awai-bubble {
	border: 1px solid #f2b8b5;
	background: #fff5f4;
	color: #80231d;
}

.awai-composer {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 12px;
	border-top: 1px solid #e7eaf0;
	background: #fff;
}

.awai-input {
	flex: 1 1 auto;
	min-height: 46px;
	max-height: 120px;
	resize: none;
	padding: 12px 14px;
	border: 1px solid #cfd6e2;
	border-radius: 14px;
	background: #fff;
	color: #172033;
	font: inherit;
	line-height: 1.4;
}

.awai-input:focus {
	border-color: var(--awai-primary);
}

.awai-send {
	flex: 0 0 46px;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: 14px;
	background: var(--awai-primary);
	color: #fff;
	font-size: 20px;
	cursor: pointer;
}

.awai-send:disabled,
.awai-input:disabled {
	opacity: 0.62;
	cursor: wait;
}

.awai-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 14px 10px;
	background: #fff;
	color: #667085;
	font-size: 10px;
}

.awai-test-state {
	width: 100%;
	margin-top: 6px;
	font-size: 10px;
	color: #5f6470;
}

.awai-test-state pre {
	max-height: 150px;
	overflow: auto;
	white-space: pre-wrap;
	background: #f4f6f9;
	padding: 8px;
	border-radius: 8px;
}

.awai-privacy {
	color: #365f9d;
	text-decoration: underline;
}

.awai-disclosure {
	text-align: right;
}

.awai-typing {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-width: 54px;
}

.awai-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #738198;
	animation: awai-pulse 1.1s infinite ease-in-out;
}

.awai-typing span:nth-child(2) { animation-delay: 120ms; }
.awai-typing span:nth-child(3) { animation-delay: 240ms; }

@keyframes awai-pulse {
	0%, 70%, 100% { opacity: 0.35; transform: translateY(0); }
	35% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 520px) {
	.awai-root {
		right: max(10px, env(safe-area-inset-right));
		bottom: max(10px, env(safe-area-inset-bottom));
		left: max(10px, env(safe-area-inset-left));
	}

	.awai-panel {
		width: 100%;
		height: min(760px, calc(100dvh - 20px - env(safe-area-inset-bottom)));
		border-radius: 18px;
	}

	.awai-launcher {
		float: right;
		width: 56px;
		height: 56px;
		padding: 0;
		justify-content: center;
	}

	.awai-launcher-label {
		display: none;
	}

	.awai-footer {
		align-items: flex-start;
		flex-direction: column;
	}

	.awai-disclosure {
		text-align: left;
	}
}

@media (prefers-reduced-motion: reduce) {
	.awai-launcher,
	.awai-typing span {
		transition: none;
		animation: none;
	}
}
