/**
 * Website AI chat widget — loaded inside the component's shadow root, so nothing here reaches
 * the site's own styles and the site's styles do not reach the panel.
 *
 * Layouts (the host's layout attribute): floating — a launcher and a panel in its corner;
 * centered — a dialog over a blurred backdrop, with the question list and a detached message box;
 * panel — a full-height side panel (the script pushes the page across by a margin on <html>).
 */

:host
{
	--aichat-color: #2d6cdf;
	--aichat-color-text: #ffffff;
	--aichat-surface: #ffffff;
	--aichat-text: #1f2933;
	--aichat-text-muted: #6b7280;
	--aichat-border: #e5e7eb;
	--aichat-user-bubble: color-mix(in srgb, var(--aichat-color) 14%, #ffffff);
	--aichat-bot-bubble: #f3f4f6;
	--aichat-radius: 16px;
	--aichat-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
	--aichat-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--aichat-z: 2147483000;
	--aichat-offset: 20px;
	--aichat-panel-width: 380px;
	--aichat-dialog-width: 880px;

	display: contents;
	font-family: var(--aichat-font);
	font-size: 15px;
	line-height: 1.45;
	color: var(--aichat-text);
}

:host([hidden])
{
	display: none;
}

/* Class display rules below would otherwise beat the hidden attribute's user-agent style */
[hidden]
{
	display: none !important;
}

*,
*::before,
*::after
{
	box-sizing: border-box;
}

button
{
	font: inherit;
	cursor: pointer;
}

/* An uploaded mascot: drawn inside its own shadow root, sized by the place it sits in */
.mascot
{
	display: block;
	width: 100%;
	height: 100%;
	flex: 0 0 auto;
}

/* ─── Launcher ─────────────────────────────────────────────────────────── */

/* The launcher and its label bubble share one corner. Whatever places or hides the launcher (side,
   open state, layout, phones) is written against .dock, so the bubble always goes with it.
   data-label on it is where the label shows, as the script resolved launcher-label-display. */
.dock
{
	position: fixed;
	bottom: var(--aichat-offset);
	right: var(--aichat-offset);
	z-index: var(--aichat-z);
	display: flex;
	flex-direction: row-reverse;
	align-items: center;
	gap: 12px;
	max-width: calc(100vw - 2 * var(--aichat-offset));

	/* Only the launcher and a visible bubble take clicks: the box around them, which a hover
	   bubble widens while it cannot be seen, must not cover the page */
	pointer-events: none;

	& > *
	{
		pointer-events: auto;
	}
}

/* Pressed before the chat had been fetched (chatwidget-launcher.js): it opens as soon as it arrives */
:host([data-loading]) .launcher
{
	cursor: progress;
}

.launcher
{
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 56px;
	padding: 0 18px 0 14px;
	border: 0;
	border-radius: 999px;
	background: var(--aichat-color);
	color: var(--aichat-color-text);
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
	font-weight: 600;
	transition: transform 0.15s ease, box-shadow 0.15s ease;

	&:hover
	{
		transform: translateY(-1px);
		box-shadow: 0 12px 28px rgba(15, 23, 42, 0.3);
	}

	&:focus-visible
	{
		outline: 3px solid color-mix(in srgb, var(--aichat-color) 45%, #ffffff);
		outline-offset: 2px;
	}

	&.launcher--icon-only
	{
		width: 56px;
		padding: 0;
		justify-content: center;
	}

	/* Keep the graphic out of the text line box so inherited font metrics cannot offset it. */
	& .launcher__visual
	{
		display: flex;
	}

	& .launcher__icon :is(svg, img)
	{
		display: block;
		width: 28px;
		height: 28px;
		object-fit: contain;
	}

	/* A mascot is a character, not a glyph: it gets most of the button */
	& .launcher__icon .mascot
	{
		width: 40px;
		height: 40px;
	}

	&:has(.mascot):not(.launcher--icon-only)
	{
		padding-left: 8px;
	}

	& .launcher__label:empty
	{
		display: none;
	}
}

/* The launcher's label in a bubble beside it: the text opens the chat, the cross sends the
   bubble away. Not .bubble, which is a chat message's bubble. */
.label-bubble
{
	position: relative;
	flex: 0 1 auto;
	min-width: 0;
	max-width: 280px;
	animation: aichat-label-bubble-in 0.35s ease-out 0.8s both;

	& .label-bubble__text
	{
		display: block;
		width: 100%;
		padding: 12px 18px;
		border: 0;
		border-radius: var(--aichat-radius);
		background: var(--aichat-surface);
		color: var(--aichat-text);
		box-shadow: 0 6px 22px rgba(15, 23, 42, 0.16);
		font-size: 15px;
		font-weight: 500;
		line-height: 1.35;
		text-align: left;
		overflow-wrap: anywhere;

		&:focus-visible
		{
			outline: 3px solid color-mix(in srgb, var(--aichat-color) 45%, #ffffff);
			outline-offset: 2px;
		}
	}

	/* On the corner away from the launcher; shown on hover or focus, always where there is no hover */
	& .label-bubble__close
	{
		position: absolute;
		top: -9px;
		left: -9px;
		display: grid;
		place-items: center;
		width: 24px;
		height: 24px;
		padding: 0;
		border: 1px solid var(--aichat-border);
		border-radius: 50%;
		background: var(--aichat-surface);
		color: var(--aichat-text-muted);
		opacity: 0;
		transition: opacity 0.15s ease;

		& svg
		{
			width: 12px;
			height: 12px;
		}

		&:focus-visible
		{
			opacity: 1;
			outline: 2px solid var(--aichat-color);
			outline-offset: 1px;
		}
	}

	&:hover .label-bubble__close
	{
		opacity: 1;
	}
}

@media (hover: none)
{
	.label-bubble .label-bubble__close
	{
		opacity: 1;
	}
}

@keyframes aichat-label-bubble-in
{
	from
	{
		opacity: 0;
		transform: translateY(6px);
	}
}

/* Hover: the same bubble, there only while the launcher is hovered or focused. It is a name
   tag, not a control: nothing in it can be clicked. */
.dock[data-label="hover"] .label-bubble
{
	animation: none;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease;

	& .label-bubble__close
	{
		display: none;
	}
}

.dock[data-label="hover"] .launcher:is(:hover, :focus-visible) + .label-bubble
{
	opacity: 1;
}

:host([position="left"]) .dock,
:host([position="left"]) .panel
{
	right: auto;
	left: var(--aichat-offset);
}

:host([position="left"]) .dock
{
	flex-direction: row;
}

/* Bubble Above: the bubble sits over the launcher, flush with its side. :host keeps this level
   with the left-side rule above, which would otherwise put the two back in a row. */
:host .dock[data-label="bubble-above"]
{
	flex-direction: column-reverse;
	align-items: flex-end;
}

:host([position="left"]) .dock[data-label="bubble-above"]
{
	align-items: flex-start;
}

:host([position="left"]) .label-bubble .label-bubble__close
{
	left: auto;
	right: -9px;
}

:host([open]) .dock
{
	display: none;
}

/* ─── Backdrop (centered layout) ───────────────────────────────────────── */

.backdrop
{
	position: fixed;
	inset: 0;
	z-index: calc(var(--aichat-z) - 1);
	background: rgba(15, 23, 42, 0.3);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
}

/* ─── Panel ────────────────────────────────────────────────────────────── */

.panel
{
	position: fixed;
	bottom: var(--aichat-offset);
	right: var(--aichat-offset);
	z-index: var(--aichat-z);
	display: none;
	flex-direction: column;
	width: min(400px, calc(100vw - var(--aichat-offset) * 2));
	height: min(640px, calc(100vh - var(--aichat-offset) * 2));
	height: min(640px, calc(100dvh - var(--aichat-offset) * 2));
	overflow: hidden;
	border-radius: var(--aichat-panel-radius, var(--aichat-radius));
	/* Match the header colour under the rounded top edge. */
	background: linear-gradient(var(--aichat-color) var(--aichat-radius), var(--aichat-surface) var(--aichat-radius));
	box-shadow: var(--aichat-shadow);
}

:host([open]) .panel
{
	display: flex;
}

:host([mode="inline"]) .panel
{
	position: relative;
	inset: auto;
	display: flex;
	width: 100%;
	height: 100%;
	min-height: var(--aichat-inline-min-height, 480px);
}

:host([mode="inline"]) .dock
{
	display: none;
}

/* The card groups header, conversation and footer; it is only a box of its own in the centered
   layout, where the message box sits apart from it */
.panel__card
{
	display: contents;
}

.panel__header
{
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--aichat-color);
	color: var(--aichat-color-text);

	& .panel__avatar
	{
		width: 38px;
		height: 38px;
		border-radius: 50%;
		object-fit: cover;
		background: rgba(255, 255, 255, 0.2);
		flex: 0 0 auto;
	}

	& .panel__avatar--icon
	{
		display: grid;
		place-items: center;

		& :is(svg, img)
		{
			width: 22px;
			height: 22px;
			object-fit: contain;
		}

		/* The mascot stands in for the tinted disc rather than sitting on it */
		&:has(.mascot)
		{
			background: none;
			border-radius: 0;
		}
	}

	& .panel__titles
	{
		flex: 1 1 auto;
		min-width: 0;
	}

	& .panel__name
	{
		display: block;
		font-weight: 700;
		font-size: 16px;
		line-height: 1.2;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	& .panel__org
	{
		display: block;
		font-size: 12.5px;
		opacity: 0.85;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
}

.panel__button
{
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.9;

	&:hover
	{
		background: rgba(255, 255, 255, 0.18);
		opacity: 1;
	}

	&:focus-visible
	{
		outline: 2px solid currentColor;
		outline-offset: -4px;
	}

	& svg
	{
		width: 20px;
		height: 20px;
	}
}

/* ─── Messages ─────────────────────────────────────────────────────────── */

.messages
{
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}

.message
{
	display: flex;
	flex-direction: column;
	max-width: 88%;

	&.message--user
	{
		align-self: flex-end;
		align-items: flex-end;
	}

	&.message--assistant
	{
		align-self: flex-start;
		align-items: flex-start;
	}
}

.bubble
{
	padding: 10px 14px;
	border-radius: var(--aichat-radius);
	background: var(--aichat-bot-bubble);
	color: var(--aichat-text);
	word-wrap: break-word;
	overflow-wrap: anywhere;

	.message--user &
	{
		background: var(--aichat-user-bubble);
		border-bottom-right-radius: 6px;
		white-space: pre-wrap;
	}

	.message--assistant &
	{
		border-bottom-left-radius: 6px;
	}

	.message--error &
	{
		background: #fdecec;
		color: #8a1f1f;
	}

	& p
	{
		margin: 0 0 0.6em;
	}

	& p:last-child,
	& ul:last-child,
	& ol:last-child
	{
		margin-bottom: 0;
	}

	& ul,
	& ol
	{
		margin: 0.3em 0 0.6em;
		padding-left: 1.3em;
	}

	& li
	{
		margin: 0.15em 0;
	}

	& a
	{
		color: var(--aichat-color);
		text-decoration: underline;
		text-underline-offset: 2px;
	}

	& strong
	{
		font-weight: 600;
	}

	& code
	{
		font-size: 0.9em;
		background: rgba(0, 0, 0, 0.06);
		padding: 0.1em 0.35em;
		border-radius: 4px;
	}

	& pre
	{
		white-space: pre-wrap;
		margin: 0.4em 0;
	}

	& h1,
	& h2,
	& h3,
	& h4
	{
		font-size: 1em;
		font-weight: 600;
		margin: 0.4em 0 0.2em;
	}

	& img
	{
		max-width: 100%;
		border-radius: 8px;
	}

	& table
	{
		border-collapse: collapse;
		font-size: 0.92em;
	}

	& td,
	& th
	{
		border: 1px solid var(--aichat-border);
		padding: 3px 8px;
	}
}

.message__feedback
{
	display: flex;
	gap: 2px;
	margin-top: 4px;
	opacity: 0;
	transition: opacity 0.15s ease;

	.message:hover &,
	.message:focus-within &,
	&.message__feedback--rated
	{
		opacity: 1;
	}

	& button
	{
		width: 26px;
		height: 26px;
		border: 0;
		border-radius: 50%;
		background: transparent;
		color: var(--aichat-text-muted);
		display: grid;
		place-items: center;

		&:hover,
		&.is-active
		{
			background: var(--aichat-bot-bubble);
			color: var(--aichat-color);
		}

		& svg
		{
			width: 15px;
			height: 15px;
		}
	}
}

:host([reply-draft="1"]) .message__feedback
{
	opacity: 1;

	& button
	{
		width: auto;
		padding-inline: 8px;
		border-radius: 6px;
		font: inherit;
		font-size: 0.8em;
		cursor: pointer;
	}
}

.status
{
	display: none;
	align-items: center;
	gap: 8px;
	align-self: flex-start;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--aichat-bot-bubble);
	color: var(--aichat-text-muted);
	font-size: 13px;

	&.is-visible
	{
		display: inline-flex;
	}

	& .status__text
	{
		flex: 1;
	}

	/* Where the mascot is seen working */
	&:has(.mascot)
	{
		padding: 4px 12px 4px 6px;
	}

	& .mascot
	{
		width: 30px;
		height: 30px;
	}
}

.dots
{
	display: inline-flex;
	gap: 3px;

	& span
	{
		width: 6px;
		height: 6px;
		border-radius: 50%;
		background: currentColor;
		opacity: 0.4;
		animation: aichat-bounce 1.2s infinite ease-in-out;

		&:nth-child(2)
		{
			animation-delay: 0.15s;
		}

		&:nth-child(3)
		{
			animation-delay: 0.3s;
		}
	}
}

@keyframes aichat-bounce
{
	0%, 80%, 100%
	{
		transform: translateY(0);
		opacity: 0.4;
	}

	40%
	{
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* ─── Intro, suggestions and hint ──────────────────────────────────────── */

.intro
{
	padding: 6px 24px 4px;
	font-size: 15px;

	& p
	{
		margin: 0 0 0.5em;
	}

	& p:last-child
	{
		margin-bottom: 0;
	}
}

.suggestions
{
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 16px 10px;

	&:empty
	{
		display: none;
	}

	& button
	{
		padding: 7px 12px;
		border: 1px solid color-mix(in srgb, var(--aichat-color) 45%, #ffffff);
		border-radius: 999px;
		background: #ffffff;
		color: var(--aichat-color);
		font-size: 13.5px;
		text-align: left;

		&:hover
		{
			background: var(--aichat-user-bubble);
		}
	}
}

/* The centered dialog lists each question with its icon */
.suggestions--list
{
	flex: 0 1 auto;
	flex-direction: column;
	flex-wrap: nowrap;
	gap: 0;
	min-height: 0;
	overflow-y: auto;
	padding: 6px 24px 0;

	& .suggestion
	{
		display: flex;
		align-items: center;
		gap: 14px;
		width: 100%;
		padding: 12px 0;
		border: 0;
		border-bottom: 1px solid var(--aichat-border);
		border-radius: 0;
		background: transparent;
		color: var(--aichat-text);
		font-size: 15.5px;
		font-weight: 500;
		text-align: left;

		&:hover
		{
			background: transparent;
		}

		&:hover .suggestion__text,
		&:hover .suggestion__icon
		{
			color: var(--aichat-color);
		}

		&:focus-visible
		{
			outline: 2px solid var(--aichat-color);
			outline-offset: 2px;
			border-radius: 6px;
		}
	}

	& .suggestion__icon
	{
		width: 20px;
		height: 20px;
		flex: 0 0 auto;
		color: var(--aichat-text-muted);

		& svg
		{
			width: 100%;
			height: 100%;
		}
	}

	& .suggestion__text
	{
		flex: 1 1 auto;
		min-width: 0;
	}
}

.hint
{
	margin: 0;
	padding: 12px 24px 16px;
	font-size: 13.5px;
	color: var(--aichat-text-muted);
}

/* ─── Composer ─────────────────────────────────────────────────────────── */

.composer
{
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--aichat-border);
	background: var(--aichat-surface);

	& .composer__spark
	{
		display: none;
		width: 22px;
		height: 22px;
		flex: 0 0 auto;
		color: var(--aichat-text-muted);

		& :is(svg, img)
		{
			width: 100%;
			height: 100%;
			object-fit: contain;
		}

		&:has(.mascot)
		{
			width: 30px;
			height: 30px;
		}
	}

	& textarea
	{
		flex: 1 1 auto;
		min-height: 42px;
		max-height: 140px;
		padding: 10px 12px;
		border: 1px solid var(--aichat-border);
		border-radius: 12px;
		background: #ffffff;
		color: var(--aichat-text);
		font: inherit;
		resize: none;
		outline: none;

		&:focus
		{
			border-color: var(--aichat-color);
			box-shadow: 0 0 0 3px color-mix(in srgb, var(--aichat-color) 20%, transparent);
		}

		&:disabled
		{
			opacity: 0.6;
		}
	}

	& .composer__send
	{
		display: grid;
		place-items: center;
		width: 42px;
		height: 42px;
		flex: 0 0 auto;
		border: 0;
		border-radius: 12px;
		background: var(--aichat-color);
		color: var(--aichat-color-text);

		&:disabled
		{
			opacity: 0.45;
			cursor: default;
		}

		& svg
		{
			width: 20px;
			height: 20px;
		}
	}

	& .composer__sendIcon
	{
		display: grid;
		place-items: center;
	}

	& .composer__sendIcon--up
	{
		display: none;
	}
}

.footer
{
	order: 10;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px 12px;
	padding: 0 12px 10px;
	text-align: center;
	font-size: 11.5px;
	color: var(--aichat-text-muted);

	& a
	{
		color: inherit;
		text-decoration: underline;
		text-underline-offset: 2px;
	}

	& .footer__brand
	{
		white-space: nowrap;
		text-decoration: none;
		opacity: 0.75;

		&:hover,
		&:focus-visible
		{
			text-decoration: underline;
			opacity: 1;
		}
	}
}

/* ─── Centered dialog ──────────────────────────────────────────────────── */

/* The dialog has no launcher: its message box stays on the page, anchored to the bottom, and the
   card opens above it when the visitor focuses or types there */
:host([mode="floating"][layout="centered"]) .dock
{
	display: none;
}

:host([mode="floating"][layout="centered"]) .panel
{
	display: flex;
	top: auto;
	left: 50%;
	right: auto;
	bottom: var(--aichat-offset);
	transform: translateX(-50%);
	width: min(var(--aichat-dialog-width), calc(100vw - 32px));
	height: auto;
	max-height: calc(100vh - var(--aichat-offset) * 2);
	max-height: calc(100dvh - var(--aichat-offset) * 2);
	overflow: visible;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
}

:host([mode="inline"][layout="centered"]) .panel
{
	overflow: visible;
	background: transparent;
	box-shadow: none;
}

:host([layout="centered"]) .panel
{
	gap: 14px;
}

:host([layout="centered"]) .panel__card
{
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	border-radius: var(--aichat-radius);
	background: var(--aichat-surface);
	box-shadow: var(--aichat-shadow);
}

:host([layout="centered"]) .panel__header
{
	padding: 16px 12px 2px 24px;
	background: transparent;
	color: var(--aichat-text-muted);

	& .panel__avatar
	{
		display: none;
	}

	& .panel__name
	{
		font-size: 15px;
		font-weight: 500;
	}

	& .panel__button:hover
	{
		background: rgba(15, 23, 42, 0.06);
	}
}

:host([layout="centered"]) .messages
{
	padding: 8px 24px 12px;

	&.messages--empty
	{
		display: none;
	}
}

:host([layout="centered"]) .composer
{
	flex: 0 0 auto;
	align-items: center;
	gap: 12px;
	padding: 6px 6px 6px 20px;
	border: 0;
	border-radius: var(--aichat-radius);
	box-shadow: var(--aichat-shadow);

	& .composer__spark
	{
		display: block;
	}

	& textarea
	{
		padding: 12px 0;
		border: 0;
		border-radius: 0;
		background: transparent;
		font-size: 16px;

		&:focus
		{
			box-shadow: none;
		}
	}

	& .composer__send
	{
		width: 46px;
		height: 46px;
		border-radius: 12px;
		background: rgba(15, 23, 42, 0.06);
		color: var(--aichat-text);

		&:hover:not(:disabled)
		{
			background: var(--aichat-color);
			color: var(--aichat-color-text);
		}
	}

	& .composer__sendIcon--send
	{
		display: none;
	}

	& .composer__sendIcon--up
	{
		display: grid;
	}
}

:host([layout="centered"]) .footer
{
	justify-content: space-between;
	gap: 4px 16px;
	padding: 12px 24px;
	border-top: 1px solid var(--aichat-border);
	background: rgba(15, 23, 42, 0.025);
	text-align: left;
	font-size: 12.5px;
}

/* ─── Side panel ───────────────────────────────────────────────────────── */

.panel__resize
{
	display: none;
}

:host([mode="floating"][layout="panel"]) .panel
{
	top: 0;
	right: 0;
	bottom: 0;
	left: auto;
	width: min(var(--aichat-panel-width), 100vw);
	height: auto;
	border-radius: 0;
	border-left: 1px solid var(--aichat-border);
	box-shadow: -12px 0 32px rgba(15, 23, 42, 0.12);
}

:host([mode="floating"][layout="panel"][position="left"]) .panel
{
	right: auto;
	left: 0;
	border-left: 0;
	border-right: 1px solid var(--aichat-border);
	box-shadow: 12px 0 32px rgba(15, 23, 42, 0.12);
}

:host([mode="floating"][layout="panel"]) .panel__resize
{
	display: block;
	position: absolute;
	inset: 0 auto 0 0;
	width: 10px;
	z-index: 1;
	cursor: ew-resize;
	touch-action: none;
	user-select: none;

	&:is(:hover, :focus-visible, :active)::after
	{
		content: '';
		position: absolute;
		inset: 0 4px;
		background: var(--aichat-color);
	}
}

:host([mode="floating"][layout="panel"][position="left"]) .panel__resize
{
	inset: 0 0 0 auto;
}

@media (prefers-reduced-motion: no-preference)
{
	:host([mode="floating"][layout="panel"]) .panel:where(.panel--animate)
	{
		animation: aichat-slide-from-right 0.25s ease;
	}

	:host([mode="floating"][layout="panel"][position="left"]) .panel:where(.panel--animate)
	{
		animation-name: aichat-slide-from-left;
	}
}

@keyframes aichat-slide-from-right
{
	from
	{
		transform: translateX(32px);
		opacity: 0;
	}

	to
	{
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes aichat-slide-from-left
{
	from
	{
		transform: translateX(-32px);
		opacity: 0;
	}

	to
	{
		transform: translateX(0);
		opacity: 1;
	}
}

/* ─── Captcha (a spam verdict on a first message) ─────────────────────── */

.message--captcha
{
	max-width: 100%;

	& .bubble
	{
		width: 100%;
	}

	& p
	{
		margin: 0 0 10px;
	}

	& .captcha__row
	{
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 10px;
	}

	& .captcha__image
	{
		display: block;
		height: 42px;
		border-radius: 6px;
	}

	& .captcha__code
	{
		width: 8em;
		padding: 8px 10px;
		border: 1px solid var(--aichat-border);
		border-radius: 8px;
		font: inherit;
		text-transform: lowercase;

		&:focus
		{
			outline: none;
			border-color: var(--aichat-color);
			box-shadow: 0 0 0 3px color-mix(in srgb, var(--aichat-color) 20%, transparent);
		}
	}

	& .captcha__actions
	{
		display: flex;
		flex-wrap: wrap;
		gap: 8px;
		margin-top: 10px;
	}

	& .captcha__verify
	{
		padding: 8px 14px;
		border: 0;
		border-radius: 999px;
		background: var(--aichat-color);
		color: var(--aichat-color-text);
		font-weight: 600;

		&:disabled
		{
			opacity: 0.6;
			cursor: default;
		}
	}

	& .captcha__refresh
	{
		padding: 8px 10px;
		border: 0;
		border-radius: 999px;
		background: transparent;
		color: var(--aichat-color);
		text-decoration: underline;
		text-underline-offset: 2px;
	}

	& .captcha__error
	{
		margin: 8px 0 0;
		color: #8a1f1f;
		font-size: 13px;
	}
}

/* ─── Small screens ────────────────────────────────────────────────────── */

@media (max-width: 640px)
{
	:host([mode="floating"][layout="panel"]) .panel__resize
	{
		display: none;
	}

	:host([mode="floating"]) .panel,
	:host([mode="floating"][layout="panel"]) .panel,
	:host([mode="floating"][layout="panel"][position="left"]) .panel,
	:host([mode="floating"][layout="centered"][open]) .panel
	{
		inset: var(--aichat-viewport-top, 0px) auto auto var(--aichat-viewport-left, 0px);
		transform: none;
		width: var(--aichat-viewport-width, 100%);
		height: var(--aichat-viewport-height, 100%);
		max-height: none;
		border: 0;
		border-radius: 0;
		animation: none;
		overscroll-behavior: contain;
	}

	/* Closed, the dialog is only its message box along the bottom edge */
	:host([mode="floating"][layout="centered"]) .panel
	{
		inset: auto 12px 12px;
		transform: none;
		width: auto;
	}

	:host([mode="floating"][layout="centered"][open]) .panel
	{
		gap: 0;
		background: var(--aichat-surface);
	}

	:host([mode="floating"][layout="centered"][open]) .panel__card
	{
		border-radius: 0;
		box-shadow: none;
	}

	:host([mode="floating"][layout="centered"][open]) .composer
	{
		border-top: 1px solid var(--aichat-border);
		border-radius: 0;
		box-shadow: none;
	}

	:host([mode="floating"][open]) .backdrop
	{
		display: none;
	}

	:host([mode="floating"][open]) :is(.panel__header, .composer)
	{
		flex-shrink: 0;
	}

	:host([mode="floating"]) .composer textarea
	{
		min-width: 0;
	}

	:host([mode="floating"]) :is(.composer textarea, .captcha__code)
	{
		font-size: 16px;
	}

	:host([show-on-mobile="0"]) .dock,
	:host([show-on-mobile="0"]) .panel
	{
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce)
{
	.launcher,
	.label-bubble .label-bubble__close
	{
		transition: none;
	}

	.panel,
	.label-bubble
	{
		animation: none;
	}

	.dots span
	{
		animation: none;
	}
}
