.wia-root,
.wia-root * {
	box-sizing: border-box;
}

.wia-root p {
	margin: 0;
}

.wia-root {
	position: fixed;
	z-index: 99999;
	right: var(--wia-side, calc(20px + env(safe-area-inset-right)));
	bottom: var(--wia-bottom, calc(20px + env(safe-area-inset-bottom)));
	font-family: "Segoe UI", system-ui, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: #111827;
}

.wia-root.is-left {
	right: auto;
	left: var(--wia-side, calc(20px + env(safe-area-inset-left)));
}

.wia-launcher,
.wia-icon-btn,
.wia-compose button,
.wia-restart {
	font: inherit;
	cursor: pointer;
}

.wia-launcher {
	width: 60px;
	height: 60px;
	border: 0;
	border-radius: 50%;
	background: #111827;
	color: #fff;
	box-shadow: 0 10px 24px rgba(17, 24, 39, 0.28);
	display: flex;
	align-items: center;
	justify-content: center;
}

.wia-launcher svg,
.wia-avatar svg {
	width: 30px;
	height: 30px;
	display: block;
}

.wia-launcher:hover,
.wia-launcher:focus-visible {
	background: #1f2937;
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

.wia-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: min(380px, calc(100vw - 32px));
	height: min(560px, calc(100vh - var(--wia-bottom, 20px) - 100px));
	height: min(560px, calc(100dvh - var(--wia-bottom, 20px) - 100px));
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(17, 24, 39, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.wia-root.is-left .wia-panel {
	right: auto;
	left: 0;
}

.wia-panel[hidden] {
	display: none !important;
}

.wia-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 12px 12px 14px;
	background: #111827;
	color: #fff;
}

.wia-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #2563eb;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}

.wia-avatar svg {
	width: 22px;
	height: 22px;
}

.wia-heading {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.wia-heading strong {
	font-size: 15px;
}

.wia-subtitle {
	font-size: 12px;
	color: #d1d5db;
}

.wia-icon-btn {
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	width: 36px;
	height: 36px;
}

.wia-log {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f8fafc;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.wia-msg {
	max-width: 85%;
	padding: 8px 10px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-break: break-word;
}

.wia-msg.is-customer {
	margin-left: auto;
	background: #2563eb;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.wia-msg.is-assistant,
.wia-msg.is-agent {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

.wia-msg.is-system {
	align-self: center;
	max-width: 100%;
	background: transparent;
	color: #6b7280;
	font-size: 12px;
	text-align: center;
	padding: 0;
}

.wia-msg-label,
.wia-msg time {
	display: block;
	font-size: 11px;
	margin-bottom: 2px;
	color: #6b7280;
}

.wia-rich p,
.wia-rich ul {
	margin: 0 0 8px;
}

.wia-rich p:last-child,
.wia-rich ul:last-child {
	margin-bottom: 0;
}

.wia-rich ul {
	padding-left: 1.15em;
}

.wia-rich a {
	color: #1d4ed8;
}

.wia-rich a.wia-catalog {
	display: inline-block;
	margin: 8px 0 4px;
	padding: 10px 14px;
	background: #111827;
	color: #fff;
	border-radius: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-decoration: none;
	text-transform: uppercase;
}

.wia-msg.is-customer time {
	color: rgba(255, 255, 255, 0.8);
	text-align: right;
}

.wia-typing {
	display: flex;
	align-items: center;
	gap: 8px;
	width: fit-content;
}

.wia-typing .wia-msg-label {
	margin: 0;
}

.wia-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid #d1d5db;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: wia-spin 0.7s linear infinite;
}

@keyframes wia-spin {
	to {
		transform: rotate(360deg);
	}
}

.wia-error {
	margin: 0;
	padding: 8px 12px;
	background: #fef2f2;
	color: #991b1b;
	font-size: 13px;
}

.wia-compose {
	border-top: 1px solid #e5e7eb;
	padding: 10px;
	background: #fff;
}

.wia-name {
	display: block;
	margin-bottom: 8px;
}

.wia-name input,
.wia-compose-row input {
	width: 100%;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 10px 12px;
	font: inherit;
	font-size: 16px;
}

.wia-compose-row {
	display: flex;
	gap: 8px;
}

.wia-compose-row input {
	flex: 1;
}

.wia-compose button,
.wia-restart {
	border: 0;
	border-radius: 10px;
	background: #2563eb;
	color: #fff;
	padding: 10px 14px;
}

.wia-compose button:disabled {
	opacity: 0.6;
	cursor: default;
}

.wia-restart {
	margin: 0 10px 10px;
}

.wia-name[hidden],
.wia-restart[hidden],
.wia-error[hidden] {
	display: none !important;
}

.wia-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.wia-panel {
		scroll-behavior: auto;
	}

	.wia-spinner {
		animation: none;
	}
}
