/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
 * Aiwend chat widget. Every rule is scoped under .aiwend-chat / .aiwend-floating, and the widget
 * resets the properties themes commonly change (fonts, sizes, line height, button and textarea
 * styles), so the theme cannot distort it. Nothing here styles the rest of the site, except the
 * scroll lock class applied to <html> while the mobile chat sheet is open.
 *
 * --aiwend-accent comes from the assistant's appearance (fixed palette, each >= 4.5:1 with white
 * text). Links and focus rings use --aiwend-link, lightened in dark mode for contrast.
 */
.aiwend-chat {
	--aiwend-accent: #4f46e5;
	--aiwend-link: var(--awl-link, var(--aiwend-accent));
	--aw-bg: var(--awl-panel-bg, #ffffff);
	--aw-surface: #f5f6fa;
	--aw-surface-2: #eceef5;
	--aw-fg: #151b2c;
	--aw-muted: #566074;
	--aw-border: #e3e6ee;
	--aw-control: #c9cedb;
	--aw-user-bg: var(--awl-user-bg, color-mix(in srgb, var(--aiwend-accent) 11%, #ffffff));
	--aw-user-fg: var(--awl-user-fg, #151b2c);
	--aw-head-bg: var(--awl-header-bg, var(--aw-bg));
	--aw-head-fg: var(--awl-header-fg, var(--aw-fg));
	--aw-head-muted: var(--awl-header-fg, var(--aw-muted));
	--aw-bot-bg: var(--awl-bot-bg, var(--aw-surface));
	--aw-bot-fg: var(--awl-bot-fg, var(--aw-fg));
	--aw-comp-bg: var(--awl-composer-bg, var(--aw-bg));
	--aw-comp-fg: var(--awl-composer-fg, var(--aw-fg));
	--aw-btn-bg: var(--awl-button-bg, var(--aiwend-accent));
	--aw-btn-fg: var(--awl-button-fg, #ffffff);
	--aw-warn: #9a3412;
	--aw-error: #b42318;
	--aw-error-bg: #fef3f2;
	--aw-shadow: 0 12px 40px rgba(20, 24, 45, .16), 0 2px 6px rgba(20, 24, 45, .06);
	--aw-radius: 20px;
	--aw-radius-sm: 12px;
	--aw-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	--aw-dur: 160ms;
	box-sizing: border-box;
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 1px solid var(--aw-border);
	border-radius: var(--aw-radius);
	background: var(--aw-bg);
	color: var(--aw-fg);
	font: 400 15px/1.5 var(--aw-font);
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}
/* Dark: charcoal surfaces (not an inversion). "auto" follows the visitor's system setting. */
@media (prefers-color-scheme: dark) {
	.aiwend-chat:not([data-aiwend-theme="light"]) {
		--aiwend-link: var(--awd-link, color-mix(in srgb, var(--aiwend-accent) 45%, #ffffff));
		--aw-bg: var(--awd-panel-bg, #16191f);
		--aw-surface: #1f232b;
		--aw-surface-2: #282d37;
		--aw-fg: #eceff4;
		--aw-muted: #a8b0bf;
		--aw-border: #2c313c;
		--aw-control: #4a5160;
		--aw-user-bg: var(--awd-user-bg, color-mix(in srgb, var(--aiwend-accent) 72%, #16191f));
		--aw-user-fg: var(--awd-user-fg, #ffffff); --aw-head-bg: var(--awd-header-bg, var(--aw-bg)); --aw-head-fg: var(--awd-header-fg, var(--aw-fg)); --aw-head-muted: var(--awd-header-fg, var(--aw-muted)); --aw-bot-bg: var(--awd-bot-bg, var(--aw-surface)); --aw-bot-fg: var(--awd-bot-fg, var(--aw-fg)); --aw-comp-bg: var(--awd-composer-bg, var(--aw-bg)); --aw-comp-fg: var(--awd-composer-fg, var(--aw-fg)); --aw-btn-bg: var(--awd-button-bg, var(--aiwend-accent)); --aw-btn-fg: var(--awd-button-fg, #ffffff);
		--aw-warn: #fdba8c;
		--aw-error: #ffb4ab;
		--aw-error-bg: #3a1d1b;
		--aw-shadow: 0 16px 48px rgba(0, 0, 0, .5);
		color-scheme: dark;
	}
}
.aiwend-chat[data-aiwend-theme="dark"] {
	--aiwend-link: var(--awd-link, color-mix(in srgb, var(--aiwend-accent) 45%, #ffffff));
	--aw-bg: var(--awd-panel-bg, #16191f);
	--aw-surface: #1f232b;
	--aw-surface-2: #282d37;
	--aw-fg: #eceff4;
	--aw-muted: #a8b0bf;
	--aw-border: #2c313c;
	--aw-control: #4a5160;
	--aw-user-bg: var(--awd-user-bg, color-mix(in srgb, var(--aiwend-accent) 72%, #16191f));
	--aw-user-fg: var(--awd-user-fg, #ffffff); --aw-head-bg: var(--awd-header-bg, var(--aw-bg)); --aw-head-fg: var(--awd-header-fg, var(--aw-fg)); --aw-head-muted: var(--awd-header-fg, var(--aw-muted)); --aw-bot-bg: var(--awd-bot-bg, var(--aw-surface)); --aw-bot-fg: var(--awd-bot-fg, var(--aw-fg)); --aw-comp-bg: var(--awd-composer-bg, var(--aw-bg)); --aw-comp-fg: var(--awd-composer-fg, var(--aw-fg)); --aw-btn-bg: var(--awd-button-bg, var(--aiwend-accent)); --aw-btn-fg: var(--awd-button-fg, #ffffff);
	--aw-warn: #fdba8c;
	--aw-error: #ffb4ab;
	--aw-error-bg: #3a1d1b;
	--aw-shadow: 0 16px 48px rgba(0, 0, 0, .5);
	color-scheme: dark;
}
.aiwend-chat[data-aiwend-theme="light"] { color-scheme: light; }

/* Scoped reset against theme styles. */
.aiwend-chat *, .aiwend-chat *::before, .aiwend-chat *::after { box-sizing: border-box; }
.aiwend-chat :where(h2, h3, p, ol, ul, li, div, span, form, label, header) {
	margin: 0; padding: 0; font: inherit; color: inherit; letter-spacing: normal; text-transform: none; background: none; border: 0; box-shadow: none;
}
.aiwend-chat :where(ol, ul) { list-style: none; }
.aiwend-chat button, .aiwend-chat textarea {
	-webkit-appearance: none; appearance: none; margin: 0; font: inherit; letter-spacing: normal; text-transform: none; text-shadow: none; box-shadow: none; min-width: 0; min-height: 0; width: auto; height: auto; line-height: inherit;
}
.aiwend-chat button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: none; border-radius: 0; }
.aiwend-chat button:disabled { cursor: default; }
.aiwend-chat a { color: var(--aiwend-link); text-decoration: underline; text-underline-offset: 2px; }
.aiwend-chat :focus { outline: none; }
.aiwend-chat :focus-visible { outline: 2px solid var(--aiwend-link); outline-offset: 2px; }
.aiwend-chat[hidden], .aiwend-chat [hidden][hidden][hidden], .aiwend-floating [hidden][hidden][hidden] { display: none !important; }
.aiwend-chat .aiwend-icon { width: 20px; height: 20px; flex: none; display: block; }
.aiwend-chat .aiwend-chat__sr {
	position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
	overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}

/* Header */
.aiwend-chat .aiwend-chat__head {
	display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 16px; flex: none;
	border-bottom: 1px solid var(--aw-border); background: var(--aw-head-bg); color: var(--aw-head-fg);
}
.aiwend-chat .aiwend-chat__titles { min-width: 0; flex: 1 1 auto; }
.aiwend-chat .aiwend-chat__title { display: block; font-size: 15px; font-weight: 650; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aiwend-chat .aiwend-chat__subline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.aiwend-chat .aiwend-chat__subtitle { font-size: 12.5px; color: var(--aw-muted); line-height: 1.4; }
.aiwend-chat .aiwend-chat__pill {
	display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; line-height: 1.6; font-weight: 550;
	background: var(--aw-surface-2); color: var(--aw-muted); white-space: nowrap;
}
.aiwend-chat .aiwend-chat__pill--demo { background: color-mix(in srgb, var(--aiwend-accent) 12%, var(--aw-bg)); color: var(--aw-fg); }
.aiwend-chat .aiwend-chat__head-tools { display: flex; align-items: center; gap: 2px; flex: none; }

/* Avatars */
.aiwend-chat .aiwend-chat__avatar { flex: none; display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; background: var(--aw-surface); color: #fff; font-weight: 700; line-height: 1; }
.aiwend-chat .aiwend-chat__avatar .aiwend-mark { width: 74%; height: 74%; object-fit: contain; display: block; }
/* The logo files carry their own opaque black background (verified: pixel (0,0) of all three sizes is opaque black), so the frame behind the mark is the same black.
 * A white frame made the file look like a dark square inside a light circle. The file itself is used unaltered. */
.aiwend-chat .aiwend-chat__avatar.is-mark { background: #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.aiwend-chat .aiwend-chat__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aiwend-chat .aiwend-chat__avatar.is-initial { background: var(--aiwend-accent); }
.aiwend-chat .aiwend-chat__avatar--sm { width: 36px; height: 36px; font-size: 15px; }
.aiwend-chat .aiwend-chat__avatar--xs { width: 28px; height: 28px; font-size: 12px; margin-top: 2px; }
.aiwend-chat .aiwend-chat__avatar--lg { width: 64px; height: 64px; font-size: 26px; }
.aiwend-chat .aiwend-chat__avatar--lg.is-mark .aiwend-mark { width: 76%; height: 76%; }

/* Icon buttons with tooltips (shown on hover and keyboard focus; the accessible name is separate). */
.aiwend-chat .aiwend-chat__icon-btn {
	position: relative; display: inline-grid !important; place-items: center; width: 40px; height: 40px; border-radius: 10px !important;
	color: var(--aw-muted) !important; transition: background-color var(--aw-dur), color var(--aw-dur);
}
.aiwend-chat .aiwend-chat__icon-btn:hover { background: var(--aw-surface-2) !important; color: var(--aw-fg) !important; }
.aiwend-chat .aiwend-chat__icon-btn[aria-pressed="true"] { color: var(--aiwend-link) !important; background: color-mix(in srgb, var(--aiwend-accent) 14%, var(--aw-bg)) !important; }
.aiwend-chat .aiwend-chat__icon-btn.is-done { color: #15803d !important; }
.aiwend-chat [data-tip]::after {
	content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
	padding: 4px 8px; border-radius: 6px; background: #151b2c; color: #fff; font-size: 12px; line-height: 1.3; font-weight: 500;
	white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--aw-dur); z-index: 3;
}
.aiwend-chat [data-tip]:hover::after, .aiwend-chat [data-tip]:focus-visible::after { opacity: 1; }
.aiwend-chat .aiwend-chat__head [data-tip]::after { bottom: auto; top: calc(100% + 6px); }
.aiwend-chat .aiwend-chat__head-tools > :last-child[data-tip]::after, .aiwend-chat .aiwend-chat__action[data-tip]::after { left: auto; right: 0; transform: none; }

/* Menu */
.aiwend-chat .aiwend-chat__menu {
	position: absolute; top: 56px; right: 10px; z-index: 5; min-width: 240px; max-width: calc(100% - 20px); padding: 6px;
	background: var(--aw-bg); border: 1px solid var(--aw-border); border-radius: 14px; box-shadow: var(--aw-shadow);
}
.aiwend-chat .aiwend-chat__menu-item {
	display: flex !important; align-items: flex-start; gap: 10px; width: 100% !important; padding: 10px !important; border-radius: 10px !important; text-align: left;
	color: var(--aw-fg) !important; font-size: 14px !important;
}
.aiwend-chat .aiwend-chat__menu-item .aiwend-icon { margin-top: 1px; color: var(--aw-muted); }
.aiwend-chat .aiwend-chat__menu-item:hover:not(:disabled), .aiwend-chat .aiwend-chat__menu-item:focus-visible { background: var(--aw-surface) !important; }
.aiwend-chat .aiwend-chat__menu-item:disabled { opacity: .5; }
.aiwend-chat .aiwend-chat__menu-item.is-danger, .aiwend-chat .aiwend-chat__menu-item.is-danger .aiwend-icon { color: var(--aw-error) !important; }
.aiwend-chat .aiwend-chat__menu-text { display: flex; flex-direction: column; min-width: 0; }
.aiwend-chat .aiwend-chat__menu-label { font-weight: 550; line-height: 1.35; }
.aiwend-chat .aiwend-chat__menu-hint { font-size: 12.5px; color: var(--aw-muted); line-height: 1.4; }

/* Body: welcome + transcript */
.aiwend-chat .aiwend-chat__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px 8px; }
.aiwend-chat .aiwend-chat__body:focus-visible { outline-offset: -3px; }
.aiwend-chat .aiwend-chat__welcome { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 4px 8px; }
.aiwend-chat .aiwend-chat__welcome .aiwend-chat__avatar--lg { margin-bottom: 14px; }
.aiwend-chat .aiwend-chat__welcome-title { font-size: 21px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
.aiwend-chat .aiwend-chat__welcome-text { margin-top: 6px !important; color: var(--aw-muted); font-size: 14.5px; max-width: 34ch; overflow-wrap: anywhere; white-space: pre-line; }
.aiwend-chat .aiwend-chat__suggestions { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 22px !important; }
.aiwend-chat .aiwend-chat__suggestion {
	display: flex !important; align-items: center; gap: 12px; width: 100% !important; min-height: 48px; padding: 10px 12px 10px 14px !important; text-align: left;
	border: 1px solid var(--aw-border) !important; border-radius: 14px !important; background: var(--aw-bg) !important; color: var(--aw-fg) !important;
	font-size: 14.5px !important; line-height: 1.4 !important; transition: border-color var(--aw-dur), background-color var(--aw-dur);
}
.aiwend-chat .aiwend-chat__suggestion:hover:not(:disabled) { border-color: color-mix(in srgb, var(--aiwend-accent) 45%, var(--aw-border)) !important; background: var(--aw-surface) !important; }
.aiwend-chat .aiwend-chat__suggestion:active:not(:disabled) { background: var(--aw-surface-2) !important; }
.aiwend-chat .aiwend-chat__suggestion:disabled { opacity: .6; }
.aiwend-chat .aiwend-chat__suggestion-icon { color: var(--aiwend-link); }
.aiwend-chat .aiwend-chat__suggestion-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; text-align: start; }
.aiwend-chat .aiwend-chat__source-title { text-align: start; }
.aiwend-chat .aiwend-chat__suggestion > .aiwend-icon:last-child { color: var(--aw-muted); width: 18px; height: 18px; }

.aiwend-chat .aiwend-chat__list { display: flex; flex-direction: column; gap: 14px; }
.aiwend-chat .aiwend-chat__row { display: flex; gap: 8px; align-items: flex-start; animation: aiwend-in var(--aw-dur) ease-out; }
.aiwend-chat .aiwend-chat__row--user { flex-direction: column; align-items: flex-end; gap: 4px; }
.aiwend-chat .aiwend-chat__col { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; max-width: calc(100% - 36px); }
.aiwend-chat .aiwend-chat__bubble { padding: 10px 14px; border-radius: 18px; max-width: 100%; overflow-wrap: anywhere; word-break: normal; }
.aiwend-chat .aiwend-chat__row--user .aiwend-chat__bubble { max-width: 85%; background: var(--aw-user-bg); color: var(--aw-user-fg); border-bottom-right-radius: 6px; }
.aiwend-chat .aiwend-chat__row--assistant .aiwend-chat__bubble { background: var(--aw-bot-bg); color: var(--aw-bot-fg); border-bottom-left-radius: 6px; }
.aiwend-chat .aiwend-chat__row.is-incomplete .aiwend-chat__bubble { border: 1px dashed var(--aw-control); background: transparent; }
/* Each message resolves its own direction (dir="auto" in the script) and aligns to its own start, whatever the page direction is. */
.aiwend-chat .aiwend-chat__text { display: block; white-space: pre-wrap; text-align: start; }

/* Sources */
.aiwend-chat .aiwend-chat__sources { width: 100%; }
.aiwend-chat .aiwend-chat__sources-toggle {
	display: inline-flex !important; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px !important; border-radius: 999px !important;
	border: 1px solid var(--aw-border) !important; color: var(--aw-muted) !important; font-size: 13px !important;
}
.aiwend-chat .aiwend-chat__sources-toggle .aiwend-icon { width: 16px; height: 16px; transition: transform var(--aw-dur); }
.aiwend-chat .aiwend-chat__sources-toggle:hover { color: var(--aw-fg) !important; background: var(--aw-surface) !important; }
.aiwend-chat .aiwend-chat__sources-toggle[aria-expanded="true"] .aiwend-icon:last-child { transform: rotate(180deg); }
.aiwend-chat .aiwend-chat__sources-list { margin-top: 6px !important; padding: 8px 12px 8px 28px !important; border-radius: var(--aw-radius-sm); background: var(--aw-surface); font-size: 13.5px; }
.aiwend-chat .aiwend-chat__sources-list { list-style: decimal !important; }
.aiwend-chat .aiwend-chat__sources-list li { padding: 2px 0 !important; overflow-wrap: anywhere; }
.aiwend-chat .aiwend-chat__source-ref { margin-left: 6px; color: var(--aw-muted); font-size: 12.5px; }

/* Response actions, notes */
.aiwend-chat .aiwend-chat__actions { display: flex; gap: 2px; margin-left: -6px; }
.aiwend-chat .aiwend-chat__actions .aiwend-chat__icon-btn { width: 36px; height: 36px; }
.aiwend-chat .aiwend-chat__actions .aiwend-icon { width: 18px; height: 18px; }
.aiwend-chat .aiwend-chat__note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--aw-muted); }
.aiwend-chat .aiwend-chat__note .aiwend-icon { width: 16px; height: 16px; }
.aiwend-chat .aiwend-chat__note--warn { color: var(--aw-warn); }
.aiwend-chat .aiwend-chat__row--user .aiwend-chat__note { justify-content: flex-end; }
.aiwend-chat .aiwend-chat__link-btn {
	display: inline-flex !important; align-items: center; gap: 4px; min-height: 32px; padding: 4px 10px !important; border-radius: 999px !important;
	border: 1px solid color-mix(in srgb, var(--aiwend-accent) 40%, var(--aw-border)) !important; color: var(--aiwend-link) !important; font-size: 13px !important; font-weight: 550 !important;
}
.aiwend-chat .aiwend-chat__link-btn .aiwend-icon { width: 15px; height: 15px; }
.aiwend-chat .aiwend-chat__link-btn:hover { background: color-mix(in srgb, var(--aiwend-accent) 10%, var(--aw-bg)) !important; }

/* Typing indicator */
.aiwend-chat .aiwend-chat__dots { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.aiwend-chat .aiwend-chat__wait { align-self: center; margin-inline-start: 8px; font-size: 12px; color: var(--aw-muted); }
.aiwend-chat .aiwend-chat__dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--aw-muted); opacity: .4; animation: aiwend-dot 1.2s infinite; }
.aiwend-chat .aiwend-chat__dots span:nth-child(2) { animation-delay: .2s; }
.aiwend-chat .aiwend-chat__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aiwend-dot { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes aiwend-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Alerts */
.aiwend-chat .aiwend-chat__alert {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 14px 0 4px; padding: 10px 12px;
	border-radius: var(--aw-radius-sm); background: var(--aw-error-bg); color: var(--aw-error); font-size: 13.5px;
}
.aiwend-chat .aiwend-chat__alert-line { display: flex; gap: 8px; align-items: flex-start; min-width: 0; flex: 1 1 200px; }
.aiwend-chat .aiwend-chat__alert-line .aiwend-icon { width: 18px; height: 18px; margin-top: 1px; }
.aiwend-chat .aiwend-chat__alert-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.aiwend-chat .aiwend-chat__ref { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; opacity: .85; }
.aiwend-chat .aiwend-chat__hint-line { color: var(--aw-fg); }

/* Buttons used in alerts and dialogs */
.aiwend-chat .aiwend-chat__btn {
	display: inline-flex !important; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px !important;
	border-radius: 10px !important; border: 1px solid var(--aw-control) !important; background: var(--aw-bg) !important; color: var(--aw-fg) !important; font-size: 14px !important; font-weight: 600 !important;
}
.aiwend-chat .aiwend-chat__btn .aiwend-icon { width: 16px; height: 16px; }
.aiwend-chat .aiwend-chat__btn.is-quiet { border-color: currentColor !important; background: transparent !important; color: inherit !important; }
.aiwend-chat .aiwend-chat__btn.is-primary { background: var(--aw-btn-bg) !important; border-color: var(--aw-btn-bg) !important; color: var(--aw-btn-fg) !important; }
.aiwend-chat .aiwend-chat__btn.is-danger { background: #b42318 !important; border-color: #b42318 !important; color: #fff !important; }

/* Jump to latest */
.aiwend-chat .aiwend-chat__jump {
	position: absolute; left: 50%; transform: translateX(-50%); bottom: 104px; z-index: 2;
	display: inline-flex !important; align-items: center; gap: 6px; padding: 6px 12px !important; min-height: 34px; border-radius: 999px !important;
	background: var(--aw-fg) !important; color: var(--aw-bg) !important; font-size: 13px !important; font-weight: 600 !important; box-shadow: var(--aw-shadow);
}
.aiwend-chat .aiwend-chat__jump .aiwend-icon { width: 16px; height: 16px; }

/* Integrated composer */
.aiwend-chat .aiwend-chat__foot { flex: none; padding: 8px 12px 10px; background: var(--aw-bg); }
.aiwend-chat .aiwend-chat__composer {
	position: relative; display: flex; align-items: flex-end; gap: 4px; padding: 5px 5px 5px 16px;
	border: 1px solid var(--aw-control); border-radius: 24px; background: var(--aw-comp-bg); transition: border-color var(--aw-dur), box-shadow var(--aw-dur);
}
.aiwend-chat .aiwend-chat__composer:focus-within { border-color: var(--aiwend-link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--aiwend-accent) 18%, transparent); }
.aiwend-chat .aiwend-chat__input {
	flex: 1 1 auto; min-width: 0; display: block; width: 100%; max-height: 132px; min-height: 40px; padding: 9px 0 !important; resize: none;
	border: 0 !important; outline: none !important; background: transparent !important; color: var(--aw-comp-fg) !important;
	font: 400 15px/1.45 var(--aw-font) !important; overflow-y: auto; box-shadow: none !important; text-align: start;
}
.aiwend-chat .aiwend-chat__input::placeholder { color: var(--aw-muted); opacity: 1; }
.aiwend-chat .aiwend-chat__clear { width: 36px !important; height: 40px !important; }
.aiwend-chat .aiwend-chat__clear .aiwend-icon { width: 16px; height: 16px; }
.aiwend-chat .aiwend-chat__action {
	position: relative; flex: none; display: inline-grid !important; place-items: center; width: 40px; height: 40px; border-radius: 50% !important;
	background: var(--aw-btn-bg) !important; color: var(--aw-btn-fg) !important; transition: opacity var(--aw-dur);
}
.aiwend-chat .aiwend-chat__action:disabled { opacity: .38; }
.aiwend-chat .aiwend-chat__action:not(:disabled):hover { filter: brightness(1.08); }
.aiwend-chat .aiwend-chat__action:focus-visible { outline-offset: 3px; }
.aiwend-chat .aiwend-chat__action.is-stop { background: var(--aw-fg) !important; color: var(--aw-bg) !important; }
.aiwend-chat .aiwend-chat__action.is-stop:disabled { opacity: .55; }
.aiwend-chat .aiwend-chat__meta { display: flex; justify-content: space-between; gap: 8px; min-height: 18px; padding: 4px 8px 0; font-size: 12px; line-height: 1.5; color: var(--aw-muted); }
.aiwend-chat .aiwend-chat__hint { opacity: 0; transition: opacity var(--aw-dur); }
.aiwend-chat .aiwend-chat__foot:focus-within .aiwend-chat__hint { opacity: 1; }
.aiwend-chat .aiwend-chat__count { margin-left: auto; }
.aiwend-chat .aiwend-chat__disclosure { padding: 2px 8px 0 !important; font-size: 12px; line-height: 1.45; color: var(--aw-muted); }

/* Confirmation dialog (inside the widget) */
.aiwend-chat .aiwend-chat__dialog-host { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(15, 18, 30, .45); }
.aiwend-chat .aiwend-chat__dialog { width: 100%; max-width: 340px; padding: 18px; border-radius: 16px; background: var(--aw-bg); color: var(--aw-fg); box-shadow: var(--aw-shadow); }
.aiwend-chat .aiwend-chat__dialog-title { font-size: 16px; font-weight: 700; line-height: 1.35; }
.aiwend-chat .aiwend-chat__dialog-text { margin-top: 6px !important; font-size: 14px; color: var(--aw-muted); }
.aiwend-chat .aiwend-chat__dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px !important; flex-wrap: wrap; }

/* Inline placement */
.aiwend-chat.aiwend-chat--inline { width: 100%; max-width: 44rem; margin: 1.5rem 0; box-shadow: 0 1px 2px rgba(20, 24, 45, .05), 0 8px 24px rgba(20, 24, 45, .06); }
.aiwend-chat--inline .aiwend-chat__body { max-height: min(560px, 70vh); min-height: 220px; }

/* Floating placement */
.aiwend-floating {
	position: fixed; z-index: 99990; bottom: max(var(--aiwend-desktop-offset), env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
	font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.aiwend-floating--right { right: max(var(--aiwend-desktop-offset), env(safe-area-inset-right)); }
.aiwend-floating--left { left: max(var(--aiwend-desktop-offset), env(safe-area-inset-left)); align-items: flex-start; }
.aiwend-floating > .aiwend-chat {
	width: 392px; max-width: calc(100vw - 2 * var(--aiwend-desktop-offset));
	height: min(640px, calc(100dvh - 2 * var(--aiwend-desktop-offset))); box-shadow: var(--aw-shadow);
	animation: aiwend-pop var(--aw-dur) ease-out;
}
@keyframes aiwend-pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.aiwend-floating.is-open .aiwend-floating__launcher { display: none; }
.aiwend-floating .aiwend-floating__launcher {
	-webkit-appearance: none; appearance: none; position: relative; display: grid; place-items: center; width: 58px; height: 58px; padding: 0; margin: 0;
	border: 0; border-radius: 50%; cursor: pointer; color: #fff;
	background: var(--aw-launch-bg);
	box-shadow: 0 10px 28px rgba(49, 46, 129, .35), 0 2px 6px rgba(20, 24, 45, .18); transition: transform var(--aw-dur), box-shadow var(--aw-dur);
}
/* Launcher colours: optional owner overrides per scheme (--awl-* light, --awd-* dark). */
.aiwend-floating { --aw-launch-bg: var(--awl-launcher-bg, linear-gradient(140deg, #2563eb 0%, var(--aiwend-accent, #4f46e5) 55%, #7c3aed 100%)); --aw-launch-fg: var(--awl-launcher-fg, #ffffff); }
@media (prefers-color-scheme: dark) { .aiwend-floating:not([data-aiwend-theme="light"]) { --aw-launch-bg: var(--awd-launcher-bg, linear-gradient(140deg, #2563eb 0%, var(--aiwend-accent, #4f46e5) 55%, #7c3aed 100%)); --aw-launch-fg: var(--awd-launcher-fg, #ffffff); } }
.aiwend-floating[data-aiwend-theme="dark"] { --aw-launch-bg: var(--awd-launcher-bg, linear-gradient(140deg, #2563eb 0%, var(--aiwend-accent, #4f46e5) 55%, #7c3aed 100%)); --aw-launch-fg: var(--awd-launcher-fg, #ffffff); }
.aiwend-floating .aiwend-floating__logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #000; overflow: hidden; }
.aiwend-floating .aiwend-floating__launcher .aiwend-mark { width: 30px; height: 30px; object-fit: contain; display: block; }
.aiwend-mark--icon { display: flex; align-items: center; justify-content: center; }
.aiwend-mark--icon svg { width: 100%; height: 100%; }
.aiwend-floating .aiwend-floating__launcher:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(49, 46, 129, .42), 0 2px 6px rgba(20, 24, 45, .2); }
.aiwend-floating .aiwend-floating__launcher:focus { outline: none; }
.aiwend-floating .aiwend-floating__launcher:focus-visible { outline: 3px solid #4f46e5; outline-offset: 3px; }
.aiwend-floating .aiwend-floating__launcher[data-tip]::after {
	content: attr(data-tip); position: absolute; bottom: 50%; transform: translateY(50%); right: calc(100% + 10px); padding: 5px 10px; border-radius: 8px;
	background: #151b2c; color: #fff; font-size: 13px; line-height: 1.3; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--aw-dur);
}
.aiwend-floating--left .aiwend-floating__launcher[data-tip]::after { right: auto; left: calc(100% + 10px); }
.aiwend-floating .aiwend-floating__launcher:hover::after, .aiwend-floating .aiwend-floating__launcher:focus-visible::after { opacity: 1; }
@media (min-width: 601px) { .aiwend-floating--mobile { display: none; } }
@media (max-width: 600px) {
	.aiwend-floating--desktop { display: none; }
	.aiwend-floating { bottom: max(var(--aiwend-mobile-offset), env(safe-area-inset-bottom)); }
	.aiwend-floating--right { right: max(var(--aiwend-mobile-offset), env(safe-area-inset-right)); }
	.aiwend-floating--left { left: max(var(--aiwend-mobile-offset), env(safe-area-inset-left)); }
	.aiwend-floating > .aiwend-chat { max-width: calc(100vw - 2 * var(--aiwend-mobile-offset)); height: min(640px, calc(100dvh - 2 * var(--aiwend-mobile-offset))); }
}
/* Very narrow screens: an intentional near-fullscreen sheet that follows the visual viewport. */
@media (max-width: 480px) {
	.aiwend-floating > .aiwend-chat {
		position: fixed; left: 0; right: 0; top: var(--aiwend-vvt, 0px); width: 100%; max-width: none;
		height: var(--aiwend-vvh, 100dvh); border-radius: 0; border: 0;
		padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
	}
	/* Signed-in visitors: the fixed WordPress toolbar sits above the sheet, so start below it. */
	body.admin-bar .aiwend-floating > .aiwend-chat {
		top: calc(var(--aiwend-vvt, 0px) + var(--wp-admin--admin-bar--height, 46px));
		height: calc(var(--aiwend-vvh, 100dvh) - var(--wp-admin--admin-bar--height, 46px));
	}
	.aiwend-chat .aiwend-chat__input { font-size: 16px !important; } /* avoids iOS zoom on focus */
	.aiwend-chat--inline .aiwend-chat__body { padding: 12px; }
	.aiwend-chat .aiwend-chat__row--user .aiwend-chat__bubble { max-width: 92%; }
}
html.aiwend-scroll-lock, html.aiwend-scroll-lock body { overflow: hidden !important; }

@media (pointer: coarse) {
	.aiwend-chat .aiwend-chat__hint { opacity: 1; }
	.aiwend-chat [data-tip]::after, .aiwend-floating .aiwend-floating__launcher[data-tip]::after { display: none; }
	.aiwend-chat .aiwend-chat__action, .aiwend-chat .aiwend-chat__icon-btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
	.aiwend-chat, .aiwend-chat *, .aiwend-floating, .aiwend-floating * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Header text and controls follow the header colour when the owner sets one. */
.aiwend-chat .aiwend-chat__head .aiwend-chat__subtitle { color: var(--aw-head-muted); }
.aiwend-chat .aiwend-chat__head .aiwend-chat__icon-btn:not([aria-pressed="true"]) { color: var(--aw-head-muted) !important; }
.aiwend-chat .aiwend-chat__head .aiwend-chat__icon-btn:not([aria-pressed="true"]):hover { color: var(--aw-head-fg) !important; }

/* Windows high-contrast / forced-colors: the composer border and focus ring must stay visible when box-shadows are dropped. */
@media (forced-colors: active) {
	.aiwend-chat :focus-visible, .aiwend-floating .aiwend-floating__launcher:focus-visible { outline: 2px solid Highlight; }
	.aiwend-chat .aiwend-chat__composer { border: 1px solid CanvasText; }
	.aiwend-chat .aiwend-chat__composer:focus-within { border-color: Highlight; }
}
