/* Sizes are in px: Bootstrap 3 sets html { font-size: 10px }, so rem units would render too small. */
.ai-search-launcher {
	position: fixed;
	right: max(20px, env(safe-area-inset-right));
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 1900;
}

#ai-search-open:not([hidden]) {
	display: grid;
	width: 64px;
	height: 64px;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #cd0a37;
	color: #fff;
	box-shadow: 0 5px 18px rgba(0, 0, 0, 0.3);
	transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

#ai-search-open:not([hidden]):hover {
	transform: translateY(-2px);
	background: #a9082d;
	box-shadow: 0 7px 22px rgba(0, 0, 0, 0.35);
}

#ai-search-open:not([hidden]):focus-visible {
	outline: 3px solid #222;
	outline-offset: 3px;
}

.ai-search-launcher__icon {
	width: 30px;
	height: 30px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.8;
}

.ai-search-launcher__icon path + path {
	stroke-width: 2.5;
}

.ai-search-launcher__label {
	position: absolute;
	right: calc(100% + 12px);
	padding: 7px 11px;
	border-radius: 4px;
	background: #222;
	color: #fff;
	font-size: 14px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transform: translateX(4px);
	transition: opacity 160ms ease, transform 160ms ease;
}

#ai-search-open:not([hidden]):hover .ai-search-launcher__label,
#ai-search-open:not([hidden]):focus-visible .ai-search-launcher__label {
	opacity: 1;
	transform: translateX(0);
}

.ai-search-dialog:not([hidden]) {
	position: fixed;
	right: max(20px, env(safe-area-inset-right));
	bottom: calc(max(20px, env(safe-area-inset-bottom)) + 76px);
	z-index: 2000;
	display: block;
	width: min(480px, calc(100vw - 40px));
	animation: ai-search-pop 160ms ease-out;
}

@keyframes ai-search-pop {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ai-search-dialog__panel {
	display: flex;
	flex-direction: column;
	height: min(620px, calc(100vh - 130px));
	overflow: hidden;
	border-radius: 12px;
	background: #fff;
	color: #222;
	font-size: 16px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.ai-search-dialog__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 12px 12px 20px;
	background: #cd0a37;
	color: #fff;
}

.ai-search-dialog__header h2 {
	flex: 1 1 auto;
	margin: 0;
	color: inherit;
	font-size: 20px;
	line-height: 1.2;
}

.ai-search-dialog__clear {
	padding: 4px 10px;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-radius: 5px;
	background: transparent;
	color: inherit;
	font-size: 13px;
}

.ai-search-dialog__clear:hover,
.ai-search-dialog__clear:focus-visible {
	background: rgba(255, 255, 255, 0.15);
}

.ai-search-dialog__close {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 28px;
	line-height: 1;
}

.ai-search-dialog__disclaimer {
	margin: 0;
	padding: 8px 20px;
	border-bottom: 1px solid #eee;
	color: #666;
	font-size: 13px;
	line-height: 1.4;
}

.ai-search-log {
	flex: 1 1 auto;
	margin: 0;
	padding: 16px 20px;
	overflow-y: auto;
	list-style: none;
	background: #f7f7f7;
}

.ai-search-log__item {
	display: flex;
	margin-bottom: 10px;
}

.ai-search-log__item--user {
	justify-content: flex-end;
}

.ai-search-log__bubble {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.45;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

.ai-search-log__item--assistant .ai-search-log__bubble {
	border-bottom-left-radius: 3px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.ai-search-log__item--user .ai-search-log__bubble {
	border-bottom-right-radius: 3px;
	background: #cd0a37;
	color: #fff;
}

.ai-search-log__item--error .ai-search-log__bubble {
	border: 1px solid #cd0a37;
	color: #a9082d;
}

.ai-search-log__bubble a {
	color: #cd0a37;
	font-weight: 600;
	text-decoration: underline;
}

#ai-search-message {
	margin: 0;
	padding: 6px 20px 0;
	color: #666;
	font-size: 13px;
}

#ai-search-message:empty {
	display: none;
}

#ai-search-form {
	display: flex;
	gap: 8px;
	padding: 12px 20px 16px;
	border-top: 1px solid #eee;
}

#ai-search-query {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	padding: 8px 14px;
	border: 1px solid #bbb;
	border-radius: 22px;
	font-size: 15px;
}

#ai-search-submit {
	height: 44px;
	padding: 0 18px;
	border-radius: 22px;
	font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
	#ai-search-open:not([hidden]),
	.ai-search-launcher__label,
	.ai-search-dialog:not([hidden]) {
		transition: none;
		animation: none;
	}
}