/* PsyAI Assistant: chat widget. Everything is scoped under .psyai-root to avoid theme conflicts.
 *
 * Motion is driven by GSAP from chat.js when it is available (the root then has .psyai-fx);
 * the CSS transitions and keyframes below are the fallback, and prefers-reduced-motion
 * turns all of it off. */

.psyai-root {
	/* --psyai-primary, --psyai-primary-2 (gradient companion), --psyai-primary-rgb and
	   --psyai-on-primary are set from the settings by chat.js. */
	--psyai-primary: #5b6ee1;
	--psyai-primary-2: #7d6ee6;
	--psyai-primary-rgb: 91, 110, 225;
	--psyai-on-primary: #ffffff;
	--psyai-gradient: linear-gradient(135deg, var(--psyai-primary) 0%, var(--psyai-primary-2) 100%);
	--psyai-width: 390px;
	--psyai-bg: #ffffff;
	--psyai-surface: #f6f7fb;
	--psyai-bubble-bot: #f1f3f9;
	--psyai-text: #1d2030;
	--psyai-muted: #62677d;
	--psyai-border: #e3e6ef;
	--psyai-accent-text: var(--psyai-primary);
	--psyai-radius: 22px;
	--psyai-shadow: 0 28px 70px -18px rgba(18, 20, 40, 0.38), 0 10px 28px -10px rgba(18, 20, 40, 0.16);
	--psyai-card-shadow: 0 18px 40px -16px rgba(18, 20, 40, 0.32);
	--psyai-scroll-shade: rgba(18, 20, 40, 0.08);
	--psyai-online: #22c55e;
	--psyai-unread: #f43f5e;
	--psyai-crisis-bg: #fff5f2;
	--psyai-crisis-border: #f5cabf;
	--psyai-crisis-accent: #d9583f;
	--psyai-crisis-text: #74241a;
	--psyai-ok-bg: #effaf3;
	--psyai-ok-border: #bfe6cd;
	--psyai-ok-accent: #1f9d55;
	--psyai-ok-text: #174a2b;
	--psyai-link: var(--psyai-primary);
	--psyai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--psyai-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

	font-family: var(--psyai-font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--psyai-text);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.psyai-root[data-theme="dark"] {
	--psyai-bg: #16171f;
	--psyai-surface: #1e2029;
	--psyai-bubble-bot: #252836;
	--psyai-text: #eceef6;
	--psyai-muted: #a3a7bb;
	--psyai-border: #2f3242;
	--psyai-accent-text: #b4bfff;
	--psyai-shadow: 0 28px 70px -18px rgba(0, 0, 0, 0.7), 0 10px 28px -10px rgba(0, 0, 0, 0.5);
	--psyai-card-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
	--psyai-scroll-shade: rgba(0, 0, 0, 0.35);
	--psyai-crisis-bg: #3a1f1c;
	--psyai-crisis-border: #6e3a31;
	--psyai-crisis-accent: #ff8f78;
	--psyai-crisis-text: #ffd7cf;
	--psyai-ok-bg: #16301f;
	--psyai-ok-border: #2b5a3b;
	--psyai-ok-accent: #3ccf7a;
	--psyai-ok-text: #c9f0d6;
	/* The main colour can be too dark to read on a dark bubble. */
	--psyai-link: currentColor;
}

@media (prefers-color-scheme: dark) {
	.psyai-root[data-theme="auto"] {
		--psyai-bg: #16171f;
		--psyai-surface: #1e2029;
		--psyai-bubble-bot: #252836;
		--psyai-text: #eceef6;
		--psyai-muted: #a3a7bb;
		--psyai-border: #2f3242;
		--psyai-accent-text: #b4bfff;
		--psyai-shadow: 0 28px 70px -18px rgba(0, 0, 0, 0.7), 0 10px 28px -10px rgba(0, 0, 0, 0.5);
		--psyai-card-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
		--psyai-scroll-shade: rgba(0, 0, 0, 0.35);
		--psyai-crisis-bg: #3a1f1c;
		--psyai-crisis-border: #6e3a31;
		--psyai-crisis-accent: #ff8f78;
		--psyai-crisis-text: #ffd7cf;
		--psyai-ok-bg: #16301f;
		--psyai-ok-border: #2b5a3b;
		--psyai-ok-accent: #3ccf7a;
		--psyai-ok-text: #c9f0d6;
		--psyai-link: currentColor;
	}
}

/* In dark mode, accents are a light tint of the main colour (readable on dark surfaces). */
@supports (color: color-mix(in srgb, red 50%, white)) {
	.psyai-root[data-theme="dark"] {
		--psyai-accent-text: color-mix(in srgb, var(--psyai-primary) 45%, #ffffff);
	}

	@media (prefers-color-scheme: dark) {
		.psyai-root[data-theme="auto"] {
			--psyai-accent-text: color-mix(in srgb, var(--psyai-primary) 45%, #ffffff);
		}
	}
}

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

.psyai-root button,
.psyai-root textarea,
.psyai-root input {
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
}

.psyai-root button {
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.psyai-root [hidden] {
	display: none !important;
}

/* While GSAP animates an element, its CSS transitions would fight it. */
.psyai-root .psyai-notrans,
.psyai-root .psyai-notrans * {
	transition: none !important;
}

/* ---------------- Panel ---------------- */

.psyai-panel {
	display: flex;
	flex-direction: column;
	background: var(--psyai-bg);
	color: var(--psyai-text);
	border-radius: var(--psyai-radius);
	overflow: hidden;
	position: relative;
	isolation: isolate;
}

.psyai-inline {
	display: block;
	width: 100%;
	max-width: 100%;
	min-height: 420px;
	margin: 0 auto 1.5em;
}

.psyai-inline .psyai-panel {
	height: 100%;
	border: 1px solid var(--psyai-border);
	box-shadow: 0 24px 60px -28px rgba(18, 20, 40, 0.35);
}

/* Header */
.psyai-header {
	position: relative;
	z-index: 0;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 12px 32px 18px;
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	flex: 0 0 auto;
	overflow: hidden;
}

/* Soft light shapes behind the header content. */
.psyai-aura {
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
}

.psyai-aura i {
	position: absolute;
	display: block;
	border-radius: 50%;
}

.psyai-aura i:nth-child(1) {
	width: 200px;
	height: 200px;
	top: -110px;
	right: -50px;
	background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 70%);
}

.psyai-aura i:nth-child(2) {
	width: 160px;
	height: 160px;
	bottom: -95px;
	left: 28%;
	background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
}

.psyai-aura i:nth-child(3) {
	width: 110px;
	height: 110px;
	top: -30px;
	left: -40px;
	background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 70%);
}

.psyai-avatar-wrap {
	position: relative;
	display: block;
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
}

.psyai-root .psyai-avatar {
	display: block;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255, 255, 255, 0.25);
	border: 2px solid rgba(255, 255, 255, 0.75);
	box-shadow: 0 6px 16px rgba(10, 12, 30, 0.18);
	margin: 0 !important;
}

.psyai-presence {
	position: absolute;
	right: -1px;
	bottom: 1px;
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: var(--psyai-online);
	border: 2px solid #ffffff;
}

.psyai-header-text {
	flex: 1 1 auto;
	min-width: 0;
}

.psyai-name {
	font-weight: 700;
	font-size: 16.5px;
	line-height: 1.25;
	letter-spacing: -0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.psyai-status {
	margin-top: 2px;
	font-size: 12.5px;
	line-height: 1.35;
	opacity: 0.88;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.psyai-header-actions {
	display: flex;
	gap: 2px;
	flex: 0 0 auto;
}

.psyai-root .psyai-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.88;
	box-shadow: none;
	transition: background 0.2s, opacity 0.2s, transform 0.15s;
}

.psyai-root .psyai-icon-btn:focus-visible {
	background: rgba(255, 255, 255, 0.2);
	opacity: 1;
}

.psyai-root .psyai-icon-btn:active {
	transform: scale(0.92);
}

/* Hover effects only where hovering exists: on touch screens they "stick" after a tap. */
@media (hover: hover) {
	.psyai-root .psyai-icon-btn:hover {
		background: rgba(255, 255, 255, 0.2);
		opacity: 1;
	}
}

/* Body: the conversation sits on a card that curves up over the header. */
.psyai-body {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	margin-top: -18px;
	border-radius: 20px 20px 0 0;
	background: var(--psyai-bg);
	overflow: hidden;
}

/* A soft shade under the header once the conversation is scrolled. */
.psyai-body::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 14px;
	z-index: 1;
	background: linear-gradient(var(--psyai-scroll-shade), transparent);
	opacity: 0;
	transition: opacity 0.25s;
	pointer-events: none;
}

.psyai-scrolled .psyai-body::before {
	opacity: 1;
}

.psyai-messages {
	position: relative;
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 22px 16px 10px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
	background: radial-gradient(120% 60% at 100% 0%, rgba(var(--psyai-primary-rgb), 0.07) 0%, rgba(var(--psyai-primary-rgb), 0) 60%), var(--psyai-bg);
}

/* Items keep their height when the conversation overflows (cards clip their corners with
   overflow: hidden, which would otherwise let flexbox squash them). */
.psyai-messages > * {
	flex-shrink: 0;
}

.psyai-messages:focus:not(:focus-visible) {
	outline: none;
}

.psyai-root .psyai-messages:focus-visible {
	outline: none;
	box-shadow: inset 0 0 0 2px var(--psyai-primary);
}

/* Who you are talking to, at the top of the conversation. */
.psyai-intro {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 0 12px 6px;
}

.psyai-intro-avatar {
	display: block;
	width: 70px;
	height: 70px;
	padding: 3px;
	margin-bottom: 9px;
	border-radius: 50%;
	background: var(--psyai-gradient);
	box-shadow: 0 12px 28px -12px rgba(var(--psyai-primary-rgb), 0.75);
}

.psyai-root .psyai-intro-avatar img {
	display: block;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
	border: 3px solid var(--psyai-bg);
	background: var(--psyai-surface);
	margin: 0 !important;
}

.psyai-intro-name {
	font-weight: 700;
	font-size: 15.5px;
	line-height: 1.3;
}

.psyai-intro-status {
	font-size: 13px;
	color: var(--psyai-muted);
}

/* Messages */
.psyai-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
	animation: psyai-in 0.3s var(--psyai-ease) both;
}

.psyai-row-user {
	justify-content: flex-end;
}

.psyai-msg {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.psyai-row-assistant .psyai-msg {
	align-items: flex-start;
	/* Replies can be long: give them the full width beside the avatar. */
	max-width: calc(100% - 38px);
}

.psyai-row-user .psyai-msg {
	align-items: flex-end;
	max-width: 84%;
}

.psyai-root .psyai-msg-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 auto;
	box-shadow: 0 3px 10px rgba(18, 20, 40, 0.14);
	/* Aligned with the bottom of the bubble, above the time line. */
	margin: 0 0 22px !important;
}

.psyai-root .psyai-typing-row .psyai-msg-avatar {
	margin-bottom: 0 !important;
}

.psyai-bubble {
	max-width: 100%;
	padding: 11px 15px;
	border-radius: 20px;
	line-height: 1.55;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.psyai-row-assistant .psyai-bubble {
	background: var(--psyai-bubble-bot);
	color: var(--psyai-text);
	border-bottom-left-radius: 6px;
	box-shadow: 0 1px 2px rgba(18, 20, 40, 0.05);
}

.psyai-row-user .psyai-bubble {
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	border-bottom-right-radius: 6px;
	white-space: pre-wrap;
	box-shadow: 0 10px 22px -12px rgba(var(--psyai-primary-rgb), 0.8);
}

.psyai-bubble p,
.psyai-bubble ul,
.psyai-bubble ol {
	margin: 0 0 0.65em;
	padding: 0;
}

.psyai-bubble ul,
.psyai-bubble ol {
	padding-left: 1.3em;
}

.psyai-bubble li {
	margin: 0.3em 0;
}

.psyai-bubble li::marker {
	color: var(--psyai-accent-text);
	font-weight: 600;
}

.psyai-bubble > :last-child {
	margin-bottom: 0;
}

.psyai-bubble strong {
	font-weight: 650;
}

.psyai-bubble a {
	color: var(--psyai-link);
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 550;
}

.psyai-row-user .psyai-bubble a {
	color: inherit;
}

.psyai-bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9em;
	background: rgba(127, 127, 127, 0.15);
	padding: 1px 5px;
	border-radius: 5px;
}

/* Name / time / read receipt under a bubble. */
.psyai-meta {
	display: flex;
	align-items: center;
	gap: 5px;
	min-height: 18px;
	margin-top: 4px;
	padding: 0 6px;
	font-size: 11.5px;
	line-height: 1.4;
	color: var(--psyai-muted);
	white-space: nowrap;
}

.psyai-receipt {
	display: inline-flex;
	align-items: center;
	gap: 3px;
}

.psyai-receipt::before {
	content: "·";
	margin-right: 2px;
}

.psyai-receipt svg {
	display: block;
	width: 14px;
	height: 14px;
}

.psyai-receipt-seen {
	color: var(--psyai-accent-text);
	font-weight: 550;
}

/* Typing indicator */
.psyai-typing {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 15px 17px;
}

.psyai-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--psyai-muted);
	opacity: 0.4;
	animation: psyai-blink 1.2s infinite ease-in-out;
}

.psyai-typing span:nth-child(2),
.psyai-teaser-dots span:nth-child(2) {
	animation-delay: 0.15s;
}

.psyai-typing span:nth-child(3),
.psyai-teaser-dots span:nth-child(3) {
	animation-delay: 0.3s;
}

.psyai-typing-note {
	display: block;
	margin: 6px 0 0 6px;
	font-size: 12px;
	color: var(--psyai-muted);
}

/* Crisis card: warm and clear, never alarming. */
.psyai-crisis {
	position: relative;
	overflow: hidden;
	background: var(--psyai-crisis-bg);
	border: 1px solid var(--psyai-crisis-border);
	color: var(--psyai-crisis-text);
	border-radius: 16px;
	padding: 14px 16px 14px 19px;
	font-size: 14px;
	box-shadow: 0 14px 30px -20px rgba(217, 88, 63, 0.7);
	animation: psyai-in 0.3s var(--psyai-ease) both;
}

.psyai-crisis::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 4px;
	background: var(--psyai-crisis-accent);
}

.psyai-crisis-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	margin-bottom: 8px;
}

.psyai-crisis-title > span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(217, 88, 63, 0.14);
	color: var(--psyai-crisis-accent);
}

.psyai-crisis-title svg {
	display: block;
	width: 17px;
	height: 17px;
}

.psyai-crisis-body p {
	margin: 0 0 0.5em;
}

.psyai-crisis-body p:last-child {
	margin-bottom: 0;
}

.psyai-crisis-body a {
	color: inherit;
	font-weight: 600;
}

/* Errors */
.psyai-error {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	font-size: 13.5px;
	color: var(--psyai-muted);
	padding: 10px 14px;
	border: 1px dashed var(--psyai-border);
	border-radius: 14px;
	background: var(--psyai-surface);
}

.psyai-root .psyai-retry {
	border: 1px solid var(--psyai-border);
	background: var(--psyai-bg);
	color: var(--psyai-text);
	border-radius: 999px;
	padding: 5px 14px;
	min-height: 32px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 550;
	box-shadow: none;
	transition: border-color 0.2s, background 0.2s;
}

@media (hover: hover) {
	.psyai-root .psyai-retry:hover {
		border-color: rgba(var(--psyai-primary-rgb), 0.6);
	}
}

.psyai-debug,
.psyai-debug-note {
	display: block;
	width: 100%;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 11.5px;
	color: var(--psyai-muted);
	white-space: pre-wrap;
	word-break: break-word;
}

.psyai-debug-note {
	text-align: center;
	opacity: 0.75;
}

/* A notice from the widget itself (e.g. the Test Console starting over). */
.psyai-system-note {
	align-self: center;
	max-width: 92%;
	padding: 6px 14px;
	border: 1px solid var(--psyai-border);
	border-radius: 999px;
	background: var(--psyai-surface);
	color: var(--psyai-muted);
	font-size: 12px;
	line-height: 1.4;
	text-align: center;
}

/* Suggestions: quick replies, on the visitor's side. */
.psyai-suggestions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
	padding: 2px 16px 12px;
}

.psyai-root .psyai-chip {
	border: 1px solid rgba(var(--psyai-primary-rgb), 0.38);
	background: var(--psyai-bg);
	color: var(--psyai-text);
	border-radius: 999px;
	padding: 8px 14px;
	min-height: 36px;
	font-size: 13.5px;
	line-height: 1.3;
	cursor: pointer;
	text-align: left;
	box-shadow: 0 2px 8px -3px rgba(18, 20, 40, 0.12);
	transition: background 0.2s, border-color 0.2s, transform 0.2s var(--psyai-ease), box-shadow 0.2s;
}

.psyai-root .psyai-chip:focus-visible {
	background: rgba(var(--psyai-primary-rgb), 0.1);
}

.psyai-root .psyai-chip:active {
	transform: scale(0.97);
}

@media (hover: hover) {
	.psyai-root .psyai-chip:hover {
		background: rgba(var(--psyai-primary-rgb), 0.08);
		border-color: rgba(var(--psyai-primary-rgb), 0.65);
		transform: translateY(-2px);
		box-shadow: 0 10px 20px -12px rgba(var(--psyai-primary-rgb), 0.8);
	}
}

/* Composer: a pill with the send button inside. */
.psyai-composer {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	margin: 4px 12px 8px;
	padding: 5px 5px 5px 16px;
	border: 1px solid var(--psyai-border);
	border-radius: 26px;
	background: var(--psyai-surface);
	flex: 0 0 auto;
	transition: border-color 0.2s, box-shadow 0.25s, background 0.2s;
}

.psyai-composer:focus-within {
	border-color: rgba(var(--psyai-primary-rgb), 0.6);
	background: var(--psyai-bg);
	box-shadow: 0 0 0 4px rgba(var(--psyai-primary-rgb), 0.14);
}

.psyai-root .psyai-input {
	flex: 1 1 auto;
	resize: none;
	width: auto;
	min-height: 40px;
	max-height: 140px;
	padding: 9px 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--psyai-text);
	font-size: 15px;
	line-height: 1.45;
	outline: none;
	box-shadow: none;
}

/* The composer shows the focus ring. */
.psyai-root .psyai-input:focus,
.psyai-root .psyai-input:focus-visible {
	outline: none;
	border: 0;
	box-shadow: none;
}

.psyai-root .psyai-input::placeholder {
	color: var(--psyai-muted);
	opacity: 1;
}

.psyai-root .psyai-send {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--psyai-border);
	color: var(--psyai-muted);
	cursor: pointer;
	overflow: hidden;
	box-shadow: none;
	transition: background 0.25s, color 0.25s, box-shadow 0.25s, transform 0.15s, opacity 0.2s;
}

.psyai-root.psyai-has-text .psyai-send {
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	box-shadow: 0 8px 18px -8px rgba(var(--psyai-primary-rgb), 0.85);
}

.psyai-send svg {
	width: 18px;
	height: 18px;
}

@media (hover: hover) {
	.psyai-root.psyai-has-text .psyai-send:hover:not(:disabled) {
		transform: scale(1.07);
	}
}

.psyai-root .psyai-send:active:not(:disabled) {
	transform: scale(0.92);
}

.psyai-root .psyai-send:disabled {
	opacity: 0.5;
	cursor: default;
}

.psyai-disclaimer {
	font-size: 11px;
	color: var(--psyai-muted);
	text-align: center;
	padding: 0 16px 10px;
	background: var(--psyai-bg);
	line-height: 1.35;
}

/* Consent / login gate */
.psyai-gate {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 20px;
	overflow-y: auto;
	background: radial-gradient(120% 60% at 50% 0%, rgba(var(--psyai-primary-rgb), 0.08) 0%, rgba(var(--psyai-primary-rgb), 0) 60%), var(--psyai-bg);
}

.psyai-gate-inner {
	width: 100%;
	max-width: 340px;
	text-align: center;
	margin: auto;
}

.psyai-root .psyai-gate-avatar {
	display: block;
	width: 74px;
	height: 74px;
	padding: 3px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--psyai-gradient);
	box-shadow: 0 14px 30px -12px rgba(var(--psyai-primary-rgb), 0.8);
	margin: 0 auto 16px !important;
}

.psyai-gate-text {
	text-align: left;
	font-size: 14px;
	line-height: 1.55;
	background: var(--psyai-surface);
	border: 1px solid var(--psyai-border);
	border-radius: 16px;
	padding: 14px 16px;
	margin-bottom: 18px;
}

.psyai-gate-text p {
	margin: 0 0 0.6em;
}

.psyai-gate-text p:last-child {
	margin-bottom: 0;
}

.psyai-root .psyai-gate-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	border: 0;
	border-radius: 999px;
	padding: 12px 24px;
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	font-weight: 650;
	cursor: pointer;
	text-decoration: none;
	box-shadow: 0 12px 24px -12px rgba(var(--psyai-primary-rgb), 0.9);
	transition: transform 0.2s var(--psyai-ease), box-shadow 0.2s, opacity 0.2s;
}

.psyai-root .psyai-gate-btn:active:not(:disabled) {
	transform: scale(0.97);
}

.psyai-root .psyai-gate-btn:disabled {
	opacity: 0.65;
	cursor: default;
}

@media (hover: hover) {
	.psyai-root .psyai-gate-btn:hover:not(:disabled) {
		transform: translateY(-1px);
		box-shadow: 0 16px 28px -12px rgba(var(--psyai-primary-rgb), 0.95);
	}
}

/* Intake offer & confirmation cards */
.psyai-offer,
.psyai-confirm {
	border-radius: 16px;
	padding: 14px 16px;
	font-size: 14px;
	animation: psyai-in 0.3s var(--psyai-ease) both;
}

/* Gradient border: the card on a gradient-filled border box. */
.psyai-offer {
	border: 1px solid transparent;
	background: linear-gradient(var(--psyai-bg), var(--psyai-bg)) padding-box, var(--psyai-gradient) border-box;
	box-shadow: 0 16px 32px -20px rgba(var(--psyai-primary-rgb), 0.8);
}

.psyai-offer-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	margin-bottom: 6px;
}

.psyai-offer-title > span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(var(--psyai-primary-rgb), 0.12);
	color: var(--psyai-accent-text);
}

.psyai-offer-title svg,
.psyai-offer-btn svg,
.psyai-sheet-title svg {
	display: block;
	width: 18px;
	height: 18px;
}

.psyai-offer p {
	margin: 0 0 12px;
	color: var(--psyai-text);
}

.psyai-root .psyai-offer-btn {
	position: relative;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 42px;
	border: 0;
	border-radius: 999px;
	padding: 10px 18px;
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	font-weight: 650;
	cursor: pointer;
	box-shadow: 0 12px 24px -12px rgba(var(--psyai-primary-rgb), 0.9);
	transition: transform 0.2s var(--psyai-ease), box-shadow 0.2s;
}

.psyai-root .psyai-offer-btn:active:not(:disabled) {
	transform: scale(0.97);
}

@media (hover: hover) {
	.psyai-root .psyai-offer-btn:hover:not(:disabled) {
		transform: translateY(-1px);
	}
}

.psyai-root .psyai-offer-btn:disabled {
	opacity: 0.5;
	cursor: default;
	box-shadow: none;
}

/* Light sweep across the button (animated once by GSAP; off-screen otherwise). */
.psyai-shine {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 45%;
	background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.45) 50%, rgba(255, 255, 255, 0) 100%);
	transform: translateX(-120%);
	pointer-events: none;
}

.psyai-confirm {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	background: var(--psyai-ok-bg);
	border: 1px solid var(--psyai-ok-border);
	color: var(--psyai-ok-text);
}

.psyai-confirm-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--psyai-ok-accent);
	color: #ffffff;
}

.psyai-confirm-icon svg {
	display: block;
	width: 17px;
	height: 17px;
}

/* Intake form: a bottom sheet over the dimmed conversation. */
.psyai-sheet-backdrop {
	position: absolute;
	inset: 0;
	z-index: 3;
	background: rgba(14, 16, 30, 0.4);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	animation: psyai-fade 0.25s ease-out both;
}

.psyai-sheet {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 4;
	max-height: calc(100% - 12px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 10px 18px 18px;
	background: var(--psyai-bg);
	border-radius: 22px 22px 0 0;
	box-shadow: 0 -18px 50px -14px rgba(14, 16, 30, 0.4);
	animation: psyai-sheet-up 0.35s var(--psyai-ease) both;
}

.psyai-sheet-handle {
	display: block;
	width: 38px;
	height: 4px;
	margin: 0 auto 14px;
	border-radius: 2px;
	background: var(--psyai-border);
}

.psyai-sheet-open .psyai-composer {
	display: none;
}

.psyai-sheet-title {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 6px;
	font-size: 17px;
	line-height: 1.3;
	color: var(--psyai-text);
}

.psyai-sheet-title svg {
	color: var(--psyai-accent-text);
}

.psyai-sheet-intro {
	margin: 0 0 16px;
	font-size: 14px;
	color: var(--psyai-muted);
}

.psyai-field-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.psyai-field {
	display: block;
	margin: 0 0 12px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--psyai-text);
}

.psyai-field small {
	font-weight: 400;
	color: var(--psyai-muted);
}

.psyai-root .psyai-field-input {
	display: block;
	width: 100%;
	min-height: 44px;
	margin-top: 5px;
	padding: 10px 13px;
	border: 1px solid var(--psyai-border);
	border-radius: 12px;
	background: var(--psyai-surface);
	color: var(--psyai-text);
	font: inherit;
	font-weight: 400;
	box-shadow: none;
	transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.psyai-root .psyai-field-input:focus {
	outline: none;
	border-color: rgba(var(--psyai-primary-rgb), 0.7);
	background: var(--psyai-bg);
	box-shadow: 0 0 0 4px rgba(var(--psyai-primary-rgb), 0.14);
}

.psyai-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.psyai-consent {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: 13px;
	line-height: 1.45;
	margin: 4px 0 14px;
	color: var(--psyai-text);
	cursor: pointer;
}

.psyai-consent input {
	margin-top: 2px !important;
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	accent-color: var(--psyai-primary);
}

/* Optional: share the conversation with the clinician (a choice, so it stands apart from the consent). */
.psyai-share {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	margin: 4px 0 12px;
	padding: 12px 14px;
	border: 1px solid var(--psyai-border);
	border-radius: 14px;
	background: var(--psyai-surface);
	font-size: 13.5px;
	line-height: 1.45;
	color: var(--psyai-text);
	cursor: pointer;
	transition: border-color 0.2s, background 0.2s;
}

.psyai-share:has(input:checked) {
	border-color: rgba(var(--psyai-primary-rgb), 0.55);
	background: rgba(var(--psyai-primary-rgb), 0.06);
}

.psyai-share input {
	margin-top: 2px !important;
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	accent-color: var(--psyai-primary);
}

.psyai-share-text {
	display: block;
	font-weight: 600;
}

.psyai-share small {
	display: block;
	margin-top: 3px;
	font-size: 12.5px;
	color: var(--psyai-muted);
}

.psyai-form-error {
	background: var(--psyai-crisis-bg);
	border: 1px solid var(--psyai-crisis-border);
	color: var(--psyai-crisis-text);
	border-radius: 12px;
	padding: 9px 13px;
	font-size: 13.5px;
	margin-bottom: 12px;
}

.psyai-sheet-actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 12px;
}

.psyai-root .psyai-link-btn {
	min-height: 40px;
	border: 0;
	background: transparent;
	color: var(--psyai-muted);
	cursor: pointer;
	padding: 8px;
	text-decoration: underline;
	text-underline-offset: 2px;
	box-shadow: none;
}

.psyai-privacy-note {
	margin: 12px 0 0;
	font-size: 11.5px;
	color: var(--psyai-muted);
	text-align: right;
}

@media (max-width: 360px) {
	.psyai-field-row {
		grid-template-columns: 1fr;
		gap: 0;
	}
}

.psyai-root :focus-visible {
	outline: 2px solid var(--psyai-primary);
	outline-offset: 2px;
}

.psyai-header :focus-visible {
	outline-color: var(--psyai-on-primary);
}

/* ---------------- Floating ---------------- */

.psyai-floating {
	position: fixed;
	bottom: 22px;
	z-index: 999990;
}

.psyai-floating.psyai-pos-right {
	right: 22px;
}

.psyai-floating.psyai-pos-left {
	left: 22px;
}

.psyai-floating .psyai-panel {
	position: absolute;
	bottom: 80px;
	width: var(--psyai-width);
	max-width: calc(100vw - 44px);
	height: min(680px, calc(100vh - 124px));
	height: min(680px, calc(100dvh - 124px));
	box-shadow: var(--psyai-shadow);
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.96);
	transition: opacity 0.22s ease, transform 0.3s var(--psyai-ease), visibility 0s linear 0.3s;
}

.psyai-pos-right .psyai-panel {
	right: 0;
	transform-origin: bottom right;
}

.psyai-pos-left .psyai-panel {
	left: 0;
	transform-origin: bottom left;
}

.psyai-floating.psyai-shown .psyai-panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.25s ease, transform 0.35s var(--psyai-ease);
}

/* GSAP drives the panel. */
.psyai-fx.psyai-floating .psyai-panel {
	transition: none;
}

.psyai-root .psyai-launcher {
	position: relative;
	display: block;
	width: 62px;
	height: 62px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--psyai-primary);
	background: var(--psyai-gradient);
	color: var(--psyai-on-primary);
	cursor: pointer;
	box-shadow: 0 14px 30px -10px rgba(var(--psyai-primary-rgb), 0.8), 0 4px 12px rgba(18, 20, 40, 0.18);
	transition: transform 0.3s var(--psyai-ease), box-shadow 0.3s, opacity 0.3s;
}

@media (hover: hover) {
	.psyai-root .psyai-launcher:hover {
		transform: scale(1.06);
		box-shadow: 0 18px 36px -10px rgba(var(--psyai-primary-rgb), 0.9), 0 6px 14px rgba(18, 20, 40, 0.2);
	}
}

.psyai-root .psyai-launcher:active {
	transform: scale(0.93);
}

/* Before its entrance animation (removed once GSAP is ready, or when it can't load). */
.psyai-root.psyai-launcher-pending .psyai-launcher {
	opacity: 0;
	transform: scale(0.4);
}

.psyai-launcher-ring {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--psyai-primary);
	opacity: 0;
	pointer-events: none;
}

.psyai-launcher-avatar,
.psyai-launcher-close {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.25s, transform 0.4s var(--psyai-ease);
}

.psyai-root .psyai-launcher-avatar img {
	width: 54px;
	height: 54px;
	border-radius: 50%;
	object-fit: cover;
	margin: 0 !important;
}

.psyai-launcher-avatar::after {
	content: "";
	position: absolute;
	right: 3px;
	bottom: 3px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--psyai-online);
	border: 2px solid #ffffff;
}

.psyai-launcher-close {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.psyai-launcher-close svg {
	width: 26px;
	height: 26px;
}

.psyai-is-open .psyai-launcher-avatar {
	opacity: 0;
	transform: rotate(30deg) scale(0.6);
}

.psyai-is-open .psyai-launcher-close {
	opacity: 1;
	transform: none;
}

/* Unread badge */
.psyai-root .psyai-unread {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	border: 2px solid #ffffff;
	background: var(--psyai-unread);
	color: #ffffff;
	font-size: 11.5px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	box-shadow: 0 4px 10px rgba(244, 63, 94, 0.45);
}

/* Greeting from the assistant above the launcher. */
.psyai-teaser {
	position: absolute;
	bottom: 78px;
	width: max-content;
	max-width: min(290px, calc(100vw - 44px));
	animation: psyai-in 0.4s var(--psyai-ease) both;
}

.psyai-pos-right .psyai-teaser {
	right: 0;
	transform-origin: 100% 100%;
}

.psyai-pos-left .psyai-teaser {
	left: 0;
	transform-origin: 0 100%;
}

.psyai-root .psyai-teaser-main {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	width: 100%;
	padding: 12px 16px 12px 12px;
	border: 1px solid var(--psyai-border);
	border-radius: 18px;
	border-bottom-right-radius: 6px;
	background: var(--psyai-bg);
	color: var(--psyai-text);
	text-align: left;
	cursor: pointer;
	box-shadow: var(--psyai-card-shadow);
	transition: transform 0.25s var(--psyai-ease), box-shadow 0.25s;
}

.psyai-root.psyai-pos-left .psyai-teaser-main {
	border-bottom-right-radius: 18px;
	border-bottom-left-radius: 6px;
}

@media (hover: hover) {
	.psyai-root .psyai-teaser-main:hover {
		transform: translateY(-2px);
		box-shadow: 0 22px 44px -16px rgba(18, 20, 40, 0.4);
	}
}

.psyai-root .psyai-teaser-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 auto;
	margin: 0 !important;
}

.psyai-teaser-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.psyai-teaser-name {
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--psyai-muted);
}

.psyai-teaser-text {
	font-size: 14.5px;
	font-weight: 500;
	line-height: 1.4;
}

.psyai-teaser-dots {
	display: none;
	gap: 4px;
	padding: 8px 0 4px;
}

.psyai-teaser-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--psyai-muted);
	opacity: 0.4;
	animation: psyai-blink 1.2s infinite ease-in-out;
}

.psyai-teaser-typing .psyai-teaser-text {
	display: none;
}

.psyai-teaser-typing .psyai-teaser-dots {
	display: inline-flex;
}

.psyai-root .psyai-teaser-close {
	position: absolute;
	top: -10px;
	right: -6px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 1px solid var(--psyai-border);
	border-radius: 50%;
	background: var(--psyai-bg);
	color: var(--psyai-muted);
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(18, 20, 40, 0.15);
}

/* A comfortable touch target around the small button. */
.psyai-root .psyai-teaser-close::after {
	content: "";
	position: absolute;
	inset: -9px;
}

.psyai-root.psyai-pos-left .psyai-teaser-close {
	right: auto;
	left: -6px;
}

.psyai-teaser-close svg {
	width: 14px;
	height: 14px;
}

.psyai-is-open .psyai-teaser {
	display: none;
}

/* Shortcode button */
.psyai-button {
	cursor: pointer;
}

/* ---------------- Full screen ---------------- */

html.psyai-full-lock,
html.psyai-full-lock body {
	overflow: hidden;
}

/* An inline chat in full screen sits above the page (it is moved to <body> meanwhile). */
.psyai-root.psyai-inline.psyai-maximized {
	position: fixed;
	inset: 0;
	z-index: 999990;
	width: auto;
	max-width: none;
	height: auto !important; /* Overrides the shortcode's height. */
	min-height: 0;
	margin: 0;
}

.psyai-floating.psyai-maximized .psyai-panel {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: auto;
	max-width: none;
	height: auto;
	transform-origin: 50% 50%;
}

.psyai-maximized .psyai-panel {
	border: 0;
	border-radius: 0;
}

.psyai-floating.psyai-maximized .psyai-launcher,
.psyai-floating.psyai-maximized .psyai-teaser {
	display: none;
}

/* A comfortable reading column, centred on wide screens. */
.psyai-maximized .psyai-header {
	padding-top: max(16px, env(safe-area-inset-top));
	padding-left: max(18px, calc((100% - 760px) / 2));
	padding-right: max(12px, calc((100% - 760px) / 2 - 6px));
}

.psyai-maximized .psyai-messages,
.psyai-maximized .psyai-suggestions {
	padding-left: max(16px, calc((100% - 760px) / 2));
	padding-right: max(16px, calc((100% - 760px) / 2));
}

.psyai-maximized .psyai-composer {
	width: calc(100% - 24px);
	max-width: 760px;
	margin-left: auto;
	margin-right: auto;
}

.psyai-maximized .psyai-disclaimer {
	padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.psyai-maximized .psyai-sheet {
	max-width: 640px;
	margin: 0 auto;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 520px) {
	.psyai-floating.psyai-hide-mobile {
		display: none;
	}

	.psyai-floating {
		bottom: 16px;
	}

	.psyai-floating.psyai-pos-right {
		right: 16px;
	}

	.psyai-floating.psyai-pos-left {
		left: 16px;
	}

	.psyai-floating .psyai-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
		transform: translateY(24px);
	}

	/* Clear the notch and the home indicator. */
	.psyai-floating .psyai-header {
		padding-top: max(16px, env(safe-area-inset-top));
	}

	.psyai-floating .psyai-disclaimer {
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}

	.psyai-floating.psyai-is-open .psyai-launcher,
	.psyai-floating .psyai-teaser {
		display: none;
	}

	/* The floating chat is already full screen on phones. */
	.psyai-root.psyai-floating .psyai-full-btn {
		display: none;
	}

	html.psyai-open-lock,
	html.psyai-open-lock body {
		overflow: hidden;
	}

	/* 16px prevents iOS from zooming in on focus. */
	.psyai-root .psyai-input,
	.psyai-root .psyai-field-input {
		font-size: 16px;
	}
}

/* ---------------- Motion (CSS fallback) ---------------- */

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

@keyframes psyai-fade {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes psyai-sheet-up {
	from {
		transform: translateY(100%);
	}
	to {
		transform: none;
	}
}

@keyframes psyai-blink {
	0%, 80%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* With GSAP running, these entrances are animated from JavaScript instead. */
.psyai-fx .psyai-row,
.psyai-fx .psyai-crisis,
.psyai-fx .psyai-offer,
.psyai-fx .psyai-confirm,
.psyai-fx .psyai-sheet,
.psyai-fx .psyai-sheet-backdrop,
.psyai-fx .psyai-teaser {
	animation: none;
}

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

/* Windows high-contrast mode: keep shapes visible where colour is removed. */
@media (forced-colors: active) {
	.psyai-bubble,
	.psyai-chip,
	.psyai-composer,
	.psyai-teaser-main,
	.psyai-offer,
	.psyai-crisis,
	.psyai-confirm,
	.psyai-sheet {
		border: 1px solid CanvasText;
	}

	.psyai-root .psyai-launcher,
	.psyai-root .psyai-send,
	.psyai-root .psyai-gate-btn,
	.psyai-root .psyai-offer-btn {
		border: 1px solid ButtonText;
	}
}

@media print {
	.psyai-floating {
		display: none !important;
	}
}
