/**
 * WeblabsUI – Chat widget.
 *
 * Theming: everything is a custom property on `.wui-chat`. A theme sets
 * its own values in its stylesheet, e.g.
 *
 *     .wui-chat {
 *         --wui-chat-accent: #c8102e;
 *         --wui-chat-radius: 12px;
 *         --wui-chat-font: "Inter", sans-serif;
 *     }
 *
 * The accent falls back to the block theme's primary colour, so a site
 * that defines nothing still gets its own colour.
 *
 * Light and dark: chatbot.js sets data-scheme="light|dark" on `.wui-chat`
 * (following the website, the device or a fixed mode). The inline style
 * from Chatbot\Theme carries the dark palette under
 * `.wui-chat[data-scheme="dark"]`; a theme can do the same by hand.
 */

.wui-chat {
	--wui-chat-accent: var(--wp--preset--color--primary, #111827);
	--wui-chat-accent-contrast: #fff;
	--wui-chat-bg: #fff;
	--wui-chat-surface: color-mix(in srgb, var(--wui-chat-bg) 94%, var(--wui-chat-text));
	--wui-chat-accent-ink: var(--wui-chat-accent);
	--wui-chat-border: rgba(15, 23, 42, .09);
	--wui-chat-text: #111827;
	--wui-chat-muted: #6b7280;
	--wui-chat-danger: #b42318;
	--wui-chat-font: inherit;
	--wui-chat-font-size: 14.5px;
	--wui-chat-radius: 20px;
	--wui-chat-bubble-radius: 18px;
	--wui-chat-shadow: 0 30px 70px -20px rgba(15, 23, 42, .45), 0 0 0 1px rgba(15, 23, 42, .06);
	--wui-chat-width: 400px;
	--wui-chat-height: min(660px, calc(100dvh - var(--wui-chat-oy, 20px) - var(--wui-chat-lift, 0px) - var(--wui-chat-lsize) - 40px));
	--wui-chat-offset: 20px;
	--wui-chat-lsize: 52px;
	--wui-chat-z: 99990;
	--wui-chat-ease: cubic-bezier(.2, .8, .2, 1);

	position: fixed;
	bottom: calc(var(--wui-chat-oy, 20px) + var(--wui-chat-lift, 0px) + env(safe-area-inset-bottom, 0px));
	z-index: var(--wui-chat-z);
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	min-height: var(--wui-chat-lsize);
	transition: bottom .25s var(--wui-chat-ease);
	font-family: var(--wui-chat-font);
	font-size: var(--wui-chat-font-size);
	line-height: 1.5;
	color: var(--wui-chat-text);
	-webkit-font-smoothing: antialiased;
}

.wui-chat--right { right: calc(var(--wui-chat-ox, 20px) + env(safe-area-inset-right, 0px)); align-items: flex-end; }
.wui-chat--left  { left: calc(var(--wui-chat-ox, 20px) + env(safe-area-inset-left, 0px)); align-items: flex-start; }

.wui-chat[data-scheme="dark"] { color-scheme: dark; }

.wui-chat--sz-s { --wui-chat-lsize: 44px; }
.wui-chat--sz-m { --wui-chat-lsize: 52px; }
.wui-chat--sz-l { --wui-chat-lsize: 60px; }

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

/* :where() keeps this reset at zero specificity — otherwise its
   "color: inherit" beats component colours like the send button's. */
:where(.wui-chat) button,
:where(.wui-chat) input,
:where(.wui-chat) textarea {
	font: inherit;
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
}

.wui-chat__icon {
	width: 20px;
	height: 20px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

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

.wui-chat__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	height: var(--wui-chat-lh, var(--wui-chat-lsize));
	min-width: var(--wui-chat-lh, var(--wui-chat-lsize));
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: var(--wui-chat-accent);
	color: var(--wui-chat-accent-contrast);
	box-shadow: 0 6px 18px -6px rgba(15, 23, 42, .38), 0 0 0 1px rgba(15, 23, 42, .06);
	cursor: pointer;
	transition: transform .3s var(--wui-chat-ease), box-shadow .3s var(--wui-chat-ease), opacity .35s, visibility 0s, background .2s, color .2s;
}

.wui-chat__launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(15, 23, 42, .42), 0 0 0 1px rgba(15, 23, 42, .06); }
.wui-chat__launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--wui-chat-accent-ink) 55%, transparent); outline-offset: 3px; }

.wui-chat__launcher-icon { position: relative; width: calc(var(--wui-chat-lsize) * .42); height: calc(var(--wui-chat-lsize) * .42); flex: none; }
.wui-chat__launcher-icon .wui-chat__icon {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transition: transform .3s var(--wui-chat-ease), opacity .2s;
}
.wui-chat__launcher-icon .wui-chat__icon + .wui-chat__icon { opacity: 0; transform: rotate(-90deg) scale(.6); }
.wui-chat__launcher-label { display: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.wui-chat__launcher-photo { display: none; }

/* Online dot: calm, small, ringed in the button's own colour. */
.wui-chat__dot {
	position: absolute;
	top: 1px;
	right: 1px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 2px var(--wui-chat-dot-ring, var(--wui-chat-accent));
}

/* bubble (default): round, icon only */

/* pill: icon + label */
.wui-chat--l-pill .wui-chat__launcher { padding: 0 18px 0 15px; }
.wui-chat--l-pill .wui-chat__launcher-label { display: inline; }
.wui-chat--l-pill .wui-chat__dot { display: none; }

/* avatar: round with the photo */
.wui-chat--l-avatar .wui-chat__launcher { padding: 0; overflow: visible; }
.wui-chat--l-avatar .wui-chat__launcher-icon { display: none; }
.wui-chat--l-avatar .wui-chat__launcher-photo {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	overflow: hidden;
	font-weight: 650;
	font-size: calc(var(--wui-chat-lsize) * .38);
}
.wui-chat--l-avatar .wui-chat__launcher-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* minimal: small outline, low visual weight */
.wui-chat--l-minimal { --wui-chat-dot-ring: var(--wui-chat-bg); }
.wui-chat--l-minimal .wui-chat__launcher {
	--wui-chat-lh: calc(var(--wui-chat-lsize) - 8px);
	background: var(--wui-chat-bg);
	color: var(--wui-chat-accent-ink);
	border: 1.5px solid color-mix(in srgb, var(--wui-chat-accent-ink) 60%, transparent);
	box-shadow: 0 2px 8px -3px rgba(15, 23, 42, .25);
}
.wui-chat--l-minimal .wui-chat__dot { width: 9px; height: 9px; top: -2px; right: -2px; }

/* tab: slim tab on the screen edge */
.wui-chat--l-tab.wui-chat--right { right: env(safe-area-inset-right, 0px); }
.wui-chat--l-tab.wui-chat--left  { left: env(safe-area-inset-left, 0px); }
.wui-chat--l-tab { min-height: 0; }
.wui-chat--l-tab .wui-chat__launcher {
	--wui-chat-lh: auto;
	min-width: 0;
	width: calc(var(--wui-chat-lsize) * .62);
	padding: 16px 0;
	border-radius: 12px 0 0 12px;
	writing-mode: vertical-rl;
	box-shadow: -3px 4px 14px -6px rgba(15, 23, 42, .35);
}
.wui-chat--l-tab.wui-chat--left .wui-chat__launcher { border-radius: 0 12px 12px 0; box-shadow: 3px 4px 14px -6px rgba(15, 23, 42, .35); }
.wui-chat--l-tab .wui-chat__launcher:hover { transform: none; }
.wui-chat--l-tab .wui-chat__launcher-icon,
.wui-chat--l-tab .wui-chat__dot { display: none; }
.wui-chat--l-tab .wui-chat__launcher-label { display: inline; font-size: 13.5px; letter-spacing: .02em; }
.wui-chat--l-tab .wui-chat__panel { bottom: 0; }
.wui-chat--l-tab.wui-chat--right .wui-chat__panel { right: calc(var(--wui-chat-ox, 20px) + 4px); }
.wui-chat--l-tab.wui-chat--left .wui-chat__panel { left: calc(var(--wui-chat-ox, 20px) + 4px); }

/* Open: the launcher shrinks to a small close button (tab: it goes away). */
.wui-chat[data-open="true"] .wui-chat__launcher {
	--wui-chat-lh: 40px;
	width: 40px;
	padding: 0;
	gap: 0;
	background: var(--wui-chat-bg);
	color: var(--wui-chat-text);
	border: 0;
	box-shadow: 0 4px 14px -6px rgba(15, 23, 42, .4), 0 0 0 1px var(--wui-chat-border);
}
.wui-chat[data-open="true"] .wui-chat__launcher-label,
.wui-chat[data-open="true"] .wui-chat__dot,
.wui-chat[data-open="true"] .wui-chat__launcher-photo { display: none; }
.wui-chat[data-open="true"] .wui-chat__launcher-icon { display: block; width: 18px; height: 18px; }
.wui-chat[data-open="true"] .wui-chat__launcher-icon .wui-chat__icon:first-child { opacity: 0; transform: rotate(90deg) scale(.6); }
.wui-chat[data-open="true"] .wui-chat__launcher-icon .wui-chat__icon + .wui-chat__icon { opacity: 1; transform: none; }
.wui-chat--l-tab[data-open="true"] .wui-chat__launcher { display: none; }

/* Appear late, slide away while scrolling down. */
.wui-chat.is-pending .wui-chat__launcher,
.wui-chat.is-away .wui-chat__launcher,
.wui-chat.is-pending .wui-chat__teaser,
.wui-chat.is-away .wui-chat__teaser,
.wui-chat.is-behind-modal:not([data-open="true"]) .wui-chat__launcher,
.wui-chat.is-behind-modal:not([data-open="true"]) .wui-chat__teaser {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: transform .35s var(--wui-chat-ease), opacity .3s, visibility 0s .35s;
}
.wui-chat.is-pending .wui-chat__launcher { transform: translateY(12px) scale(.92); }
.wui-chat.is-away .wui-chat__launcher { transform: translateY(calc(100% + 24px)); }
.wui-chat--l-tab.is-away.wui-chat--right .wui-chat__launcher { transform: translateX(110%); }
.wui-chat--l-tab.is-away.wui-chat--left .wui-chat__launcher { transform: translateX(-110%); }

/* Teaser bubble */
.wui-chat__teaser {
	position: absolute;
	bottom: calc(var(--wui-chat-lsize) + 12px);
	display: flex;
	align-items: flex-start;
	width: max-content;
	max-width: min(260px, calc(100vw - 2 * var(--wui-chat-ox, 20px) - 8px));
	padding: 10px 6px 10px 14px;
	border-radius: 14px;
	background: var(--wui-chat-bg);
	color: var(--wui-chat-text);
	box-shadow: 0 10px 28px -10px rgba(15, 23, 42, .4), 0 0 0 1px var(--wui-chat-border);
	font-size: 13.5px;
	line-height: 1.4;
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .3s, transform .3s var(--wui-chat-ease), visibility 0s .3s;
}
.wui-chat--right .wui-chat__teaser { right: 0; }
.wui-chat--left .wui-chat__teaser { left: 0; }
.wui-chat--l-tab .wui-chat__teaser { bottom: 8px; }
.wui-chat--l-tab.wui-chat--right .wui-chat__teaser { right: calc(var(--wui-chat-lsize) * .62 + 10px); }
.wui-chat--l-tab.wui-chat--left .wui-chat__teaser { left: calc(var(--wui-chat-lsize) * .62 + 10px); }
.wui-chat.is-teaser:not(.is-pending):not(.is-away) .wui-chat__teaser { opacity: 1; visibility: visible; transform: none; transition: opacity .3s, transform .3s var(--wui-chat-ease), visibility 0s; }
.wui-chat[data-open="true"] .wui-chat__teaser { display: none; }
.wui-chat__teaser-text { padding: 0 8px 0 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.wui-chat__teaser-x {
	flex: none;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wui-chat-muted);
	cursor: pointer;
}
.wui-chat__teaser-x:hover { background: var(--wui-chat-surface); color: var(--wui-chat-text); }
.wui-chat__teaser-x .wui-chat__icon { width: 14px; height: 14px; }

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

.wui-chat__panel {
	position: absolute;
	bottom: calc(100% + 14px);
	width: var(--wui-chat-width);
	max-width: calc(100vw - 2 * var(--wui-chat-ox, 20px));
	height: var(--wui-chat-height);
	display: flex;
	flex-direction: column;
	background: var(--wui-chat-bg);
	border-radius: var(--wui-chat-radius);
	box-shadow: var(--wui-chat-shadow);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(.97);
	transform-origin: bottom right;
	transition: opacity .22s var(--wui-chat-ease), transform .28s var(--wui-chat-ease), visibility 0s .28s;
}

.wui-chat--right .wui-chat__panel { right: 0; }
.wui-chat--left .wui-chat__panel { left: 0; transform-origin: bottom left; }

.wui-chat[data-open="true"] .wui-chat__panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .22s var(--wui-chat-ease), transform .28s var(--wui-chat-ease), visibility 0s;
}

/* Header */

.wui-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--wui-chat-header-bg, var(--wui-chat-accent));
	color: var(--wui-chat-header-text, var(--wui-chat-accent-contrast));
}

.wui-chat__who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.wui-chat__names { display: flex; flex-direction: column; min-width: 0; }
.wui-chat__name { font-size: 15.5px; font-weight: 650; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wui-chat .wui-chat__name { color: inherit; }
.wui-chat .wui-chat__status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--wui-chat-header-text, var(--wui-chat-accent-contrast)); opacity: .9; }
.wui-chat__status i { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }

.wui-chat__logo { max-height: 34px; max-width: 150px; width: auto; display: none; object-fit: contain; }
/* Logo, or the name when there is none (or none for the dark scheme). */
.wui-chat--logo .wui-chat__logo--light { display: block; }
.wui-chat--logo .wui-chat__name { display: none; }
.wui-chat--logo.wui-chat--logo-dark[data-scheme="dark"] .wui-chat__logo--light { display: none; }
.wui-chat--logo.wui-chat--logo-dark[data-scheme="dark"] .wui-chat__logo--dark { display: block; }
.wui-chat--logo:not(.wui-chat--logo-dark)[data-scheme="dark"] .wui-chat__logo--light { display: none; }
.wui-chat--logo:not(.wui-chat--logo-dark)[data-scheme="dark"] .wui-chat__name { display: block; }

.wui-chat__header .wui-chat__avatar--bot { width: 40px; height: 40px; background: color-mix(in srgb, currentColor 16%, transparent); color: inherit; font-size: 16px; }

.wui-chat__header-actions { display: flex; gap: 2px; }

.wui-chat__icon-btn {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	cursor: pointer;
	opacity: .85;
	transition: background .15s, opacity .15s;
}
.wui-chat__icon-btn:hover { opacity: 1; background: rgba(127, 127, 127, .16); }
.wui-chat__icon-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* Body */

.wui-chat__body {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 8px;
	scroll-behavior: smooth;
	background:
		radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--wui-chat-accent) 6%, transparent), transparent 70%),
		var(--wui-chat-bg);
}

.wui-chat__list { display: flex; flex-direction: column; gap: 14px; }

/* Messages */

.wui-chat__msg { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; }
.wui-chat__msg--user { flex-direction: row-reverse; }

.wui-chat__msg.is-new { animation: wui-chat-in .32s var(--wui-chat-ease) both; }

@keyframes wui-chat-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

.wui-chat__avatar {
	flex: none;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	overflow: hidden;
	font-size: 13px;
	font-weight: 650;
	background: var(--wui-chat-accent);
	color: var(--wui-chat-accent-contrast);
}
.wui-chat__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wui-chat__avatar--user { background: var(--wui-chat-surface); color: var(--wui-chat-muted); }
.wui-chat__msg--user .wui-chat__avatar { display: none; }

.wui-chat__stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: calc(100% - 38px); }
.wui-chat__msg--user .wui-chat__stack { align-items: flex-end; max-width: 85%; }

.wui-chat__bubble {
	padding: 10px 14px;
	border-radius: var(--wui-chat-bubble-radius);
	border-bottom-left-radius: 6px;
	background: var(--wui-chat-bot-bubble, var(--wui-chat-surface));
	color: var(--wui-chat-bot-text, var(--wui-chat-text));
	overflow-wrap: anywhere;
}

.wui-chat__msg--user .wui-chat__bubble {
	background: var(--wui-chat-user-bubble, var(--wui-chat-accent));
	color: var(--wui-chat-user-text, var(--wui-chat-accent-contrast));
	border-bottom-left-radius: var(--wui-chat-bubble-radius);
	border-bottom-right-radius: 6px;
	white-space: pre-wrap;
}

.wui-chat__bubble p { margin: 0 0 .55em; }
.wui-chat__bubble p:last-child { margin-bottom: 0; }
.wui-chat__bubble ul,
.wui-chat__bubble ol { margin: .2em 0 .6em; padding-left: 1.25em; }
.wui-chat__bubble li { margin: .15em 0; }
.wui-chat__bubble li::marker { color: var(--wui-chat-muted); }
.wui-chat__bubble strong { font-weight: 650; }
.wui-chat__bubble code { font-size: .9em; padding: .1em .35em; border-radius: 5px; background: rgba(127, 127, 127, .14); }
.wui-chat__heading { font-weight: 650; }

.wui-chat__link {
	/* Text colour, accent only in the underline: a theme's primary colour
	   can be anything, including nearly the bubble's own background. */
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
	text-decoration-color: var(--wui-chat-accent);
	word-break: break-word;
}
.wui-chat__link:hover { text-decoration-color: currentColor; }
.wui-chat__link .wui-chat__icon { width: 13px; height: 13px; margin-left: 2px; vertical-align: -1px; }

.wui-chat__bubble.is-error { background: color-mix(in srgb, var(--wui-chat-danger) 9%, var(--wui-chat-bg)); color: var(--wui-chat-danger); }

.wui-chat__thumb { display: block; max-width: 220px; max-height: 220px; border-radius: 12px; margin: -2px -6px 6px; }

/* Typing, caret, tool status */

.wui-chat__typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.wui-chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--wui-chat-muted); animation: wui-chat-dot 1.2s infinite ease-in-out both; }
.wui-chat__typing i:nth-child(2) { animation-delay: .15s; }
.wui-chat__typing i:nth-child(3) { animation-delay: .3s; }

@keyframes wui-chat-dot {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40%           { opacity: 1;  transform: translateY(-4px); }
}

.wui-chat__caret {
	display: inline-block;
	width: 7px;
	height: 1.05em;
	margin-left: 2px;
	vertical-align: -.15em;
	border-radius: 2px;
	background: var(--wui-chat-accent);
	animation: wui-chat-blink 1s steps(2, start) infinite;
}

@keyframes wui-chat-blink { to { visibility: hidden; } }

.wui-chat__tool {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start;
	padding: 5px 11px;
	border-radius: 999px;
	font-size: 12.5px;
	color: var(--wui-chat-muted);
	background: linear-gradient(90deg, var(--wui-chat-surface) 0%, color-mix(in srgb, var(--wui-chat-accent) 10%, var(--wui-chat-surface)) 50%, var(--wui-chat-surface) 100%);
	background-size: 200% 100%;
	animation: wui-chat-shimmer 1.6s linear infinite;
}
.wui-chat__tool .wui-chat__icon { width: 14px; height: 14px; }

@keyframes wui-chat-shimmer { to { background-position: -200% 0; } }

/* Tool steps: what the assistant is looking up, live, then folded. */

.wui-chat__steps {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.wui-chat__step {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12.5px;
	color: var(--wui-chat-muted);
	animation: wui-chat-in .25s var(--wui-chat-ease) both;
}
.wui-chat__step em { font-style: normal; color: var(--wui-chat-text); font-weight: 550; }
.wui-chat__step-sum { opacity: .85; }

.wui-chat__step-icon {
	flex: none;
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--wui-chat-surface);
}
.wui-chat__step-icon .wui-chat__icon { width: 12px; height: 12px; stroke-width: 2.6; }
.wui-chat__step.is-done .wui-chat__step-icon { background: #dcfce7; color: #15803d; }
.wui-chat__step.is-failed .wui-chat__step-icon { background: #fee2e2; color: #b91c1c; }
.wui-chat__step.is-running .wui-chat__step-icon i {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: 2px solid color-mix(in srgb, var(--wui-chat-accent) 30%, transparent);
	border-top-color: var(--wui-chat-accent);
	animation: wui-chat-spin .7s linear infinite;
}

@keyframes wui-chat-spin { to { transform: rotate(360deg); } }

.wui-chat__steps-done { font-size: 12.5px; color: var(--wui-chat-muted); }
.wui-chat__steps-done summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	list-style: none;
	padding: 2px 0;
}
.wui-chat__steps-done summary::-webkit-details-marker { display: none; }
.wui-chat__steps-done summary .wui-chat__icon { width: 14px; height: 14px; }
.wui-chat__steps-done[open] summary { margin-bottom: 6px; }

.wui-chat__thinking { margin-left: 8px; font-size: 12.5px; color: var(--wui-chat-muted); }

/* Sources under an answer. */

.wui-chat__sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.wui-chat__sources-label { color: var(--wui-chat-muted); }
.wui-chat__source {
	padding: 2px 9px;
	border: 1px solid var(--wui-chat-border);
	border-radius: 999px;
	color: var(--wui-chat-text);
	text-decoration: none;
	background: var(--wui-chat-bg);
	max-width: 220px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.wui-chat__source:hover { border-color: var(--wui-chat-accent); }

.wui-chat__reasoning { font-size: 12.5px; color: var(--wui-chat-muted); }
.wui-chat__reasoning summary { cursor: pointer; }
.wui-chat__reasoning div { margin-top: 4px; padding: 8px 10px; border-left: 2px solid var(--wui-chat-border); white-space: pre-wrap; max-height: 180px; overflow: auto; }

/* Per-message tools */

.wui-chat__msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.wui-chat__msg:hover .wui-chat__msg-tools,
.wui-chat__msg:focus-within .wui-chat__msg-tools { opacity: 1; }
.wui-chat__msg-tools .wui-chat__icon-btn { width: 28px; height: 28px; color: var(--wui-chat-muted); }
.wui-chat__msg-tools .wui-chat__icon { width: 16px; height: 16px; }

.wui-chat__retry {
	display: block;
	margin-top: 8px;
	padding: 4px 10px;
	border: 1px solid currentColor;
	border-radius: 8px;
	background: transparent;
	cursor: pointer;
	font-size: 13px;
}

/* Suggestions */

.wui-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 38px; }
.wui-chat__chips--next { padding-left: 0; margin-top: 2px; }
.wui-chat__chips--next .wui-chat__chip { padding: 6px 12px; font-size: 12.5px; text-align: left; max-width: 100%; }
.wui-chat__chip {
	padding: 7px 13px;
	border: 1px solid color-mix(in srgb, var(--wui-chat-accent) 30%, var(--wui-chat-border));
	border-radius: 999px;
	background: var(--wui-chat-bg);
	color: var(--wui-chat-accent-ink);
	font-size: 13px;
	font-weight: 550;
	cursor: pointer;
	transition: background .15s, transform .15s;
}
.wui-chat__chip:hover { background: color-mix(in srgb, var(--wui-chat-accent) 8%, var(--wui-chat-bg)); transform: translateY(-1px); }

/* Cards */

.wui-chat__cards {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	padding: 2px 2px 8px;
	margin: 0 -2px;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
	max-width: 100%;
	overscroll-behavior-x: contain;
}
.wui-chat__cards--list,
.wui-chat__cards--grid { display: grid; overflow: visible; scroll-snap-type: none; margin: 0; padding: 2px 0; width: 340px; max-width: 100%; }
.wui-chat__cards--list { gap: 6px; }
.wui-chat__cards--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.wui-chat__card {
	flex: 0 0 196px;
	display: flex;
	flex-direction: column;
	border: 1px solid var(--wui-chat-border);
	border-radius: 16px;
	background: var(--wui-chat-bg);
	color: inherit;
	text-decoration: none;
	overflow: hidden;
	scroll-snap-align: start;
	transition: transform .2s var(--wui-chat-ease), box-shadow .2s var(--wui-chat-ease), border-color .2s;
	animation: wui-chat-in .35s var(--wui-chat-ease) both;
}
.wui-chat__card:nth-child(2) { animation-delay: .05s; }
.wui-chat__card:nth-child(3) { animation-delay: .1s; }
.wui-chat__card:nth-child(4) { animation-delay: .15s; }
.wui-chat__card:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -14px rgba(15, 23, 42, .4); border-color: color-mix(in srgb, var(--wui-chat-accent) 30%, var(--wui-chat-border)); }

.wui-chat__card--link { flex-basis: 220px; }

.wui-chat__card-media { position: relative; display: block; aspect-ratio: 1 / 1; background: #f5f6f8; overflow: hidden; }
.wui-chat__card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.wui-chat[data-scheme="dark"] .wui-chat__card-media { background: #eceef2; } /* product photos are shot on white */
.wui-chat__card-media.is-empty { display: grid; place-items: center; color: color-mix(in srgb, var(--wui-chat-muted) 60%, transparent); }
.wui-chat__card-media.is-empty .wui-chat__icon { width: 34%; height: 34%; stroke-width: 1.5; }
.wui-chat__card-badge {
	position: absolute;
	left: 8px;
	top: 8px;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	background: #dcfce7;
	color: #166534;
}
.wui-chat__card-badge.is-out { background: #fee2e2; color: #991b1b; }

.wui-chat__card-info { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; flex: 1; }
.wui-chat__card-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wui-chat__card-meta { font-size: 12px; color: var(--wui-chat-muted); }
.wui-chat__card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.wui-chat__card-price { font-weight: 700; }
.wui-chat__card-go { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--wui-chat-accent-ink); margin-left: auto; }
.wui-chat__card-go .wui-chat__icon { width: 14px; height: 14px; }

/* Composer */

.wui-chat__composer { padding: 10px 12px 12px; border-top: 1px solid var(--wui-chat-border); background: var(--wui-chat-bg); }

.wui-chat__row {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 6px 6px 6px 8px;
	border: 1px solid var(--wui-chat-border);
	border-radius: 16px;
	background: var(--wui-chat-surface);
	transition: border-color .15s, box-shadow .15s;
}
/* The row shows the focus ring; themes with a global
   "textarea:focus-visible { outline … !important }" would draw a second one. */
.wui-chat .wui-chat__row .wui-chat__input:focus,
.wui-chat .wui-chat__row .wui-chat__input:focus-visible { outline: none !important; }
.wui-chat__row:focus-within { border-color: color-mix(in srgb, var(--wui-chat-accent) 45%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wui-chat-accent) 14%, transparent); }

.wui-chat__input {
	flex: 1;
	min-height: 36px;
	max-height: 140px;
	padding: 7px 4px;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	outline: none !important;
	resize: none;
	line-height: 1.45;
}

.wui-chat__attach { color: var(--wui-chat-muted); }

.wui-chat__send {
	display: grid;
	place-items: center;
	flex: none;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--wui-chat-accent);
	color: var(--wui-chat-accent-contrast);
	cursor: pointer;
	transition: transform .15s, opacity .15s;
}
.wui-chat__send:hover { transform: scale(1.05); }
.wui-chat__send .wui-chat__icon { width: 18px; height: 18px; stroke-width: 2.2; }
.wui-chat.is-busy .wui-chat__send .wui-chat__icon { fill: currentColor; stroke: none; width: 14px; height: 14px; }

.wui-chat__preview { position: relative; display: inline-block; margin: 0 0 8px; }
.wui-chat__preview[hidden] { display: none; }
.wui-chat__preview img { display: block; height: 64px; max-width: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--wui-chat-border); }
.wui-chat__preview .wui-chat__icon-btn { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: var(--wui-chat-text); color: var(--wui-chat-bg); opacity: 1; }
.wui-chat__preview .wui-chat__icon { width: 12px; height: 12px; stroke-width: 2.6; }

.wui-chat__drop {
	position: absolute;
	inset: 8px;
	display: grid;
	place-items: center;
	border: 2px dashed var(--wui-chat-accent);
	border-radius: calc(var(--wui-chat-radius) - 6px);
	background: color-mix(in srgb, var(--wui-chat-bg) 88%, transparent);
	color: var(--wui-chat-accent);
	font-weight: 600;
	opacity: 0;
	pointer-events: none;
	transition: opacity .15s;
}
.wui-chat.is-dropping .wui-chat__drop { opacity: 1; }

/* Support: a separate secondary action above the input, never part of the legal text. */
.wui-chat__actionrow { display: flex; justify-content: center; padding: 6px 12px 0; background: var(--wui-chat-bg); }
.wui-chat__escalate {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 32px;
	padding: 5px 13px;
	border: 1px solid color-mix(in srgb, var(--wui-chat-accent) 28%, var(--wui-chat-border));
	border-radius: 999px;
	background: color-mix(in srgb, var(--wui-chat-accent) 6%, var(--wui-chat-bg));
	color: var(--wui-chat-accent-ink);
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s, border-color .15s;
}
.wui-chat__escalate:hover { background: color-mix(in srgb, var(--wui-chat-accent) 12%, var(--wui-chat-bg)); }
.wui-chat__escalate:disabled { opacity: .5; cursor: default; }
.wui-chat__escalate .wui-chat__icon { width: 15px; height: 15px; }

/* Under the input: one quiet legal line, optional EU pill above it. */
.wui-chat__legal { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 14px 9px; background: var(--wui-chat-bg); text-align: center; }
.wui-chat__legal-text { margin: 0; font-size: 11px; line-height: 1.35; color: var(--wui-chat-muted); text-wrap: balance; }
.wui-chat__legal-text a { color: inherit; text-decoration: underline; }

/* "AI hosted in the EU": small pill with twelve stars */
.wui-chat__eu {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: 100%;
	padding: 2px 9px 2px 6px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 550;
	line-height: 1.4;
	white-space: nowrap;
	cursor: help;
}
.wui-chat__eu > span { overflow: hidden; text-overflow: ellipsis; }
.wui-chat__eu-flag { flex: none; width: 12px; height: 12px; fill: currentColor; }
.wui-chat__eu--footer { background: var(--wui-chat-surface); color: var(--wui-chat-muted); border: 1px solid var(--wui-chat-border); }
.wui-chat__eu--header { margin-top: 3px; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; align-self: flex-start; }

.wui-chat__notice { align-self: center; padding: 6px 12px; border-radius: 999px; background: var(--wui-chat-text); color: var(--wui-chat-bg); font-size: 12.5px; animation: wui-chat-in .25s var(--wui-chat-ease) both; }

/* Ticket form */

.wui-chat__ticket {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	border: 1px solid var(--wui-chat-border);
	border-radius: 16px;
	background: var(--wui-chat-bg);
	animation: wui-chat-in .3s var(--wui-chat-ease) both;
}
.wui-chat__ticket p { margin: 0; color: var(--wui-chat-muted); font-size: 13px; }
.wui-chat__ticket label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
.wui-chat__ticket input { padding: 9px 11px; border: 1px solid var(--wui-chat-border); border-radius: 10px; background: var(--wui-chat-surface); font-weight: 400; }
.wui-chat__ticket.is-sending { opacity: .6; pointer-events: none; }
.wui-chat__ticket-actions { display: flex; justify-content: flex-end; gap: 8px; }

.wui-chat__btn { padding: 8px 14px; border: 0; border-radius: 10px; background: var(--wui-chat-accent); color: var(--wui-chat-accent-contrast); font-weight: 600; cursor: pointer; }
.wui-chat__btn--ghost { background: transparent; color: var(--wui-chat-muted); }

.wui-chat__trust {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 0;
	padding: 6px 14px 2px;
	font-size: 11px;
	line-height: 1.35;
	color: var(--wui-chat-muted);
	background: var(--wui-chat-bg);
}
.wui-chat__trust .wui-chat__icon { width: 13px; height: 13px; color: var(--wui-chat-accent-ink); }
.wui-chat__trust a { color: inherit; text-decoration: underline; }
.wui-chat__trust--header { padding: 7px 14px; border-bottom: 1px solid var(--wui-chat-border); justify-content: flex-start; }

.wui-chat__consent {
	display: flex;
	gap: 10px;
	padding: 12px 14px;
	border: 1px solid var(--wui-chat-border);
	border-radius: 14px;
	background: var(--wui-chat-bg);
	font-size: 12.5px;
	animation: wui-chat-in .3s var(--wui-chat-ease) both;
}
.wui-chat__consent > .wui-chat__icon { color: var(--wui-chat-accent-ink); margin-top: 1px; }
.wui-chat__consent-body { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.wui-chat__consent-body p { margin: 0; }
.wui-chat__consent-body small { color: var(--wui-chat-muted); font-size: 11.5px; }
.wui-chat__consent-body a { color: inherit; text-decoration: underline; }
.wui-chat.is-gated .wui-chat__composer { opacity: .55; }

.wui-chat__team {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px;
	border-bottom: 1px solid var(--wui-chat-border);
	background: var(--wui-chat-bg);
	font-size: 12px;
	color: var(--wui-chat-muted);
}
.wui-chat__faces { display: inline-flex; flex: none; }
.wui-chat__face {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	margin-left: -8px;
	border-radius: 50%;
	border: 2px solid var(--wui-chat-bg);
	background: color-mix(in srgb, var(--wui-chat-accent-ink) 18%, var(--wui-chat-bg));
	color: var(--wui-chat-text);
	font-size: 11px;
	font-weight: 650;
	overflow: hidden;
}
.wui-chat__face:first-child { margin-left: 0; }
.wui-chat__face img { width: 100%; height: 100%; object-fit: cover; display: block; }

.wui-chat__who-pick { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wui-chat__who-pick legend { padding: 0; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; }
.wui-chat .wui-chat__ticket label.wui-chat__pick {
	flex-direction: row;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border: 1px solid var(--wui-chat-border);
	border-radius: 12px;
	font-weight: 400;
	cursor: pointer;
}
.wui-chat__pick:has(input:checked) { border-color: var(--wui-chat-accent); background: color-mix(in srgb, var(--wui-chat-accent) 7%, var(--wui-chat-bg)); }
.wui-chat .wui-chat__ticket .wui-chat__pick input { padding: 0; accent-color: var(--wui-chat-accent); }
.wui-chat__pick-body { display: flex; flex-direction: column; min-width: 0; }
.wui-chat__pick-body small { color: var(--wui-chat-muted); font-size: 11.5px; }
.wui-chat__ticket-note { color: var(--wui-chat-muted); font-size: 11.5px; }
.wui-chat__ticket .wui-chat__ticket-check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.wui-chat .wui-chat__ticket .wui-chat__ticket-check input { width: 16px; height: 16px; margin: 0; padding: 0; flex: none; font-size: inherit; accent-color: var(--wui-chat-accent); }
.wui-chat .wui-chat__ticket-error { color: var(--wui-chat-danger); font-size: 12.5px; }
.wui-chat__ticket-error[hidden] { display: none; }

/* ── Inside wp-admin: clear the admin bar ──────────────── */

.wp-admin .wui-chat { --wui-chat-z: 100100; }

/* ── Phones: smaller launcher, full-height sheet ─────────── */

@media (max-width: 600px) {
	.wui-chat--sz-s { --wui-chat-lsize: 40px; }
	.wui-chat--sz-m { --wui-chat-lsize: 46px; }
	.wui-chat--sz-l { --wui-chat-lsize: 54px; }

	/* The label makes way: a pill is a round button on a phone. */
	.wui-chat--l-pill .wui-chat__launcher { padding: 0; }
	.wui-chat--l-pill .wui-chat__launcher-label { display: none; }
	.wui-chat--l-pill .wui-chat__dot { display: block; }
}

/* Phones and landscape phones: the panel is a sheet over the whole screen.
   --wui-chat-vvh / --wui-chat-vvt come from visualViewport (chatbot.js), so
   the iOS keyboard shrinks the sheet instead of covering the input. */
@media (max-width: 600px), (max-height: 480px) and (orientation: landscape) {
	.wui-chat__panel {
		position: fixed;
		top: var(--wui-chat-vvt, 0px);
		right: 0;
		bottom: auto;
		left: 0;
		width: 100%;
		max-width: none;
		height: 100vh;
		height: 100dvh;
		height: var(--wui-chat-vvh, 100dvh);
		border-radius: 0;
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		padding-left: env(safe-area-inset-left, 0px);
		padding-right: env(safe-area-inset-right, 0px);
		transform: translateY(24px);
		overscroll-behavior: contain;
	}
	.wui-chat--l-tab .wui-chat__panel { inset: auto 0 auto 0; }

	.wui-chat[data-open="true"] .wui-chat__launcher { display: none; }
	html.wui-chat-open,
	html.wui-chat-open body { overflow: hidden; }

	/* ≥16px: iOS zooms into smaller inputs on focus */
	.wui-chat__input,
	.wui-chat__ticket input,
	.wui-chat__ticket textarea,
	.wui-chat__ticket select { font-size: 16px; }

	/* compact header, cards and rows never wider than the screen */
	.wui-chat__header { padding: 10px 8px 10px 14px; }
	.wui-chat__header .wui-chat__avatar--bot { width: 34px; height: 34px; }
	.wui-chat__body { overscroll-behavior: contain; }
	.wui-chat__cards--list,
	.wui-chat__cards--grid { width: 100%; }
	.wui-chat__card { flex-basis: min(196px, 62vw); }
	.wui-chat__card--link { flex-basis: min(220px, 70vw); }
	.wui-chat__legal { padding-bottom: 6px; }
}

/* Narrow phones: a wide logo must leave room for the EU pill. */
@media (max-width: 420px) {
	.wui-chat__logo { max-width: 112px; }
}

@media (max-height: 480px) and (orientation: landscape) {
	.wui-chat__header { padding-top: 6px; padding-bottom: 6px; }
	.wui-chat__header .wui-chat__avatar--bot,
	.wui-chat__status { display: none; }
	.wui-chat__legal-text { display: none; }
	.wui-chat__eu--header { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.wui-chat *,
	.wui-chat *::before,
	.wui-chat *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Product display: list = compact rows, grid = two columns */
.wui-chat__cards--list .wui-chat__card { flex: none; flex-direction: row; align-items: center; gap: 10px; min-height: 68px; padding: 6px 8px 6px 6px; border-radius: 12px; animation-duration: .25s; }
.wui-chat__cards--list .wui-chat__card:hover { transform: none; }
.wui-chat__cards--list .wui-chat__card-media { flex: none; width: 56px; height: 56px; aspect-ratio: auto; border-radius: 8px; }
.wui-chat__cards--list .wui-chat__card-info { padding: 0; gap: 1px; min-width: 0; }
.wui-chat__cards--list .wui-chat__card-title { font-size: 13px; line-height: 1.3; }
.wui-chat__cards--list .wui-chat__card-meta { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wui-chat__cards--list .wui-chat__card-meta.is-out { color: #991b1b; }
.wui-chat__cards--list .wui-chat__card-foot { padding-top: 1px; }
.wui-chat__cards--list .wui-chat__card-price { font-size: 13px; }
.wui-chat__cards--list .wui-chat__card-go { flex: none; margin: 0; color: var(--wui-chat-muted); }
.wui-chat__cards--list .wui-chat__card-go .wui-chat__icon { width: 18px; height: 18px; }
.wui-chat__cards-all { justify-self: end; padding: 4px 6px; font-size: 12.5px; font-weight: 600; color: var(--wui-chat-accent-ink); text-decoration: none; }
.wui-chat__cards-all:hover { text-decoration: underline; }

.wui-chat__cards--grid .wui-chat__card { flex: none; border-radius: 12px; }
.wui-chat__cards--grid .wui-chat__card:hover { transform: none; }
.wui-chat__cards--grid .wui-chat__card-info { padding: 8px 9px 9px; }
.wui-chat__cards--grid .wui-chat__card-title { font-size: 12.5px; }
.wui-chat__cards--grid .wui-chat__card-meta { font-size: 11px; }
.wui-chat__cards--grid .wui-chat__card-go { display: none; }
.wui-chat__cards--grid .wui-chat__card-badge { font-size: 10px; padding: 1px 6px; }

.wui-chat__escalate-icon { color: inherit; }
