.bab-ai-bubble,
.bab-ai-bubble * { box-sizing: border-box; }

.bab-ai-bubble {
	--bab-bubble-teal: #019389;
	--bab-bubble-ink: #303747;
	--bab-bubble-muted: #687181;
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 2147483647;
	color: var(--bab-bubble-ink);
	font: inherit;
}

.bab-ai-bubble [hidden] { display: none !important; }

.bab-ai-bubble__launcher {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 52px;
	padding: 0 18px;
	border: 0;
	border-radius: 999px;
	background: var(--bab-bubble-teal);
	box-shadow: 0 10px 28px rgba(27, 47, 64, .24);
	color: #fff;
	cursor: pointer;
	font: inherit;
	font-weight: 700;
}
.bab-ai-bubble__launcher:hover,
.bab-ai-bubble__launcher:focus { background: #017c74; }
.bab-ai-bubble__launcher:focus-visible,
.bab-ai-bubble__close:focus-visible,
.bab-ai-bubble__reset:focus-visible,
.bab-ai-bubble__suggestion:focus-visible,
.bab-ai-bubble__form button:focus-visible,
.bab-ai-bubble__login-button:focus-visible { outline: 3px solid rgba(1, 147, 137, .35); outline-offset: 3px; }
.bab-ai-bubble__launcher svg { width: 23px; height: 23px; fill: currentColor; }

.bab-ai-bubble__panel {
	position: absolute;
	right: 0;
	bottom: 66px;
	display: none;
	flex-direction: column;
	width: min(400px, calc(100vw - 32px));
	height: min(620px, calc(100dvh - 120px));
	min-height: 430px;
	overflow: hidden;
	border: 1px solid #dfe4e8;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 18px 55px rgba(27, 47, 64, .22);
}
.bab-ai-bubble.is-open .bab-ai-bubble__panel { display: flex; }

@media (min-width: 601px) {
	.bab-ai-bubble__panel {
		position: fixed;
		top: 20px;
		right: 20px;
		bottom: 20px;
		left: auto;
		width: min(400px, calc(100vw - 40px));
		height: auto;
		min-height: 0;
		max-height: none;
	}
}

.bab-ai-bubble__header {
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 18px 15px;
}
.bab-ai-bubble__header::after,
.bab-ai-bubble__form::before {
	content: "";
	position: absolute;
	left: 16px;
	right: 16px;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(1, 147, 137, .24) 18%, rgba(1, 147, 137, .34) 50%, rgba(1, 147, 137, .24) 82%, transparent);
	pointer-events: none;
}
.bab-ai-bubble__header::after { bottom: 0; }
.bab-ai-bubble__header h2 { margin: 0 0 3px; color: var(--bab-bubble-ink); font-size: 19px; line-height: 1.3; }
.bab-ai-bubble__header p { margin: 0; color: var(--bab-bubble-muted); font-size: 13px; line-height: 1.45; }
.bab-ai-bubble__close {
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f3f5f7;
	color: #4d5664;
	cursor: pointer;
	font: inherit;
	font-size: 25px;
	line-height: 1;
}

.bab-ai-bubble__chat { display: flex; flex: 1; min-height: 0; flex-direction: column; }

.bab-ai-bubble__resume {
	margin: 12px 14px 0;
	padding: 12px;
	border: 1px solid rgba(1, 147, 137, .28);
	border-radius: 10px;
	background: #f2fbfa;
	color: var(--bab-bubble-ink);
}
.bab-ai-bubble__resume p { margin: 0 0 10px; font-size: 13px; line-height: 1.45; }
.bab-ai-bubble__resume-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bab-ai-bubble__resume-continue,
.bab-ai-bubble__resume-dismiss {
	min-height: 36px;
	padding: 7px 11px;
	border-radius: 7px;
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
}
.bab-ai-bubble__resume-continue { border: 1px solid var(--bab-bubble-teal); background: var(--bab-bubble-teal); color: #fff; }
.bab-ai-bubble__resume-dismiss { border: 1px solid #cfd6dc; background: #fff; color: var(--bab-bubble-ink); }
.bab-ai-bubble__resume-error { margin-top: 10px !important; color: #a33; }

.bab-ai-bubble__messages {
	flex: 1;
	min-height: 170px;
	overflow-y: auto;
	padding: 16px;
	background: #fbfcfd;
}
.bab-ai-bubble__message { display: flex; flex-wrap: wrap; margin: 0 0 12px; }
.bab-ai-bubble__message--user { justify-content: flex-end; }
.bab-ai-bubble__message-text {
	max-width: 88%;
	padding: 10px 12px;
	border: 1px solid #e3e8ec;
	border-radius: 12px;
	background: #fff;
	white-space: pre-wrap;
	line-height: 1.5;
	font-size: 14px;
}
.bab-ai-bubble__message--user .bab-ai-bubble__message-text { border-color: var(--bab-bubble-teal); background: var(--bab-bubble-teal); color: #fff; }
.bab-ai-bubble__copy,
.bab-ai-bubble__reset {
	border: 0;
	background: transparent;
	color: var(--bab-bubble-teal);
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
}
.bab-ai-bubble__copy { width: 100%; margin: 4px 0 0 3px; padding: 0; text-align: left; }

.bab-ai-bubble__suggestions { display: flex; flex-wrap: wrap; gap: 7px; max-height: 112px; overflow-y: auto; padding: 12px 14px 0; }
.bab-ai-bubble__suggestion {
	padding: 7px 10px;
	border: 1px solid rgba(1, 147, 137, .35);
	border-radius: 999px;
	background: #f3fbfa;
	color: #007d75;
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
}
.bab-ai-bubble__suggestion:hover { background: #e4f7f5; }
.bab-ai-bubble__suggestion:disabled { opacity: .5; cursor: wait; }

.bab-ai-bubble__form { position: relative; display: flex; gap: 8px; padding: 12px 14px; }
.bab-ai-bubble__form::before { top: 0; }
.bab-ai-bubble__form textarea {
	flex: 1;
	min-height: 48px;
	max-height: 110px;
	resize: vertical;
	border: 1px solid #cfd6dc;
	border-radius: 9px;
	padding: 10px;
	font: inherit;
	font-size: 14px;
}
.bab-ai-bubble__form button {
	align-self: stretch;
	padding: 0 15px;
	border: 0;
	border-radius: 9px;
	background: var(--bab-bubble-teal);
	color: #fff;
	cursor: pointer;
	font: inherit;
	font-weight: 700;
}
.bab-ai-bubble__form button:disabled { opacity: .55; cursor: wait; }
.bab-ai-bubble__footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px 12px; color: var(--bab-bubble-muted); }
.bab-ai-bubble__footer span { max-width: 75%; font-size: 10px; line-height: 1.35; text-align: right; }
.bab-ai-bubble__reset { padding: 0; }

.bab-ai-bubble__login { margin: auto; padding: 32px 24px; text-align: center; }
.bab-ai-bubble__login h3 { margin: 0 0 8px; font-size: 20px; }
.bab-ai-bubble__login p { margin: 0 0 20px; color: var(--bab-bubble-muted); line-height: 1.5; }
.bab-ai-bubble__login-button {
	display: inline-block;
	padding: 10px 18px;
	border-radius: 8px;
	background: var(--bab-bubble-teal);
	color: #fff !important;
	font-weight: 700;
	text-decoration: none !important;
}

@media (max-width: 600px), (max-height: 600px) and (pointer: coarse) {
	html.bab-ai-bubble-open,
	body.bab-ai-bubble-open {
		overflow: hidden !important;
		overscroll-behavior: none;
	}
	.bab-ai-bubble { right: 12px; bottom: 12px; }
	.bab-ai-bubble.is-open {
		inset: 0;
		width: 100%;
		height: 100%;
	}
	.bab-ai-bubble__launcher { min-width: 52px; padding: 0 15px; }
	.bab-ai-bubble.is-open .bab-ai-bubble__launcher { display: none; }
	.bab-ai-bubble__panel {
		position: fixed;
		top: var(--bab-ai-viewport-top, 0px);
		left: var(--bab-ai-viewport-left, 0px);
		right: auto;
		bottom: auto;
		width: var(--bab-ai-viewport-width, 100vw);
		height: var(--bab-ai-viewport-height, 100dvh);
		max-width: none;
		max-height: none;
		min-height: 0;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		overscroll-behavior: contain;
	}
	.bab-ai-bubble__header {
		position: relative;
		z-index: 2;
		flex: 0 0 auto;
		gap: 8px;
		padding: max(14px, env(safe-area-inset-top)) 18px 13px;
		background: #fff;
	}
	.bab-ai-bubble__header h2 {
		margin-bottom: 0;
		font-size: 15px;
		line-height: 1.25;
	}
	.bab-ai-bubble__header p {
		display: none;
	}
	.bab-ai-bubble__close {
		flex: 0 0 28px;
		width: 28px;
		height: 28px;
		position: relative;
		font-size: 0;
	}
	.bab-ai-bubble__close::before {
		content: "";
		display: block;
		width: 9px;
		height: 9px;
		margin: -3px auto 0;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: rotate(45deg);
	}
	.bab-ai-bubble__chat { min-height: 0; }
	.bab-ai-bubble__messages {
		min-height: 0;
		padding: 16px 14px;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
	}
	.bab-ai-bubble__suggestions {
		flex-wrap: nowrap;
		max-height: none;
		overflow-x: auto;
		overflow-y: hidden;
		gap: 7px;
		padding: 10px 12px 0;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}
	.bab-ai-bubble__suggestion {
		flex: 0 0 auto;
		padding: 6px 9px;
		font-size: 11px;
		line-height: 1.25;
		white-space: nowrap;
	}
	.bab-ai-bubble__form {
		position: relative;
		z-index: 2;
		flex: 0 0 auto;
		padding: 10px 12px;
		background: #fff;
	}
	.bab-ai-bubble__form textarea {
		min-width: 0;
		font-size: 16px;
	}
	.bab-ai-bubble__form button { padding: 0 12px; }
	.bab-ai-bubble__footer {
		position: relative;
		z-index: 2;
		flex: 0 0 auto;
		gap: 8px;
		padding: 0 12px max(10px, env(safe-area-inset-bottom));
		background: #fff;
	}
	.bab-ai-bubble__reset { font-size: 11px; white-space: nowrap; }
	.bab-ai-bubble__footer span { font-size: 9px; line-height: 1.3; }
}

@media (max-width: 360px) {
	.bab-ai-bubble__launcher span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.bab-ai-bubble__launcher { width: 52px; padding: 0; justify-content: center; }
}

@media (prefers-reduced-motion: no-preference) {
	.bab-ai-bubble__panel { animation: bab-bubble-in .16s ease-out; }
	@keyframes bab-bubble-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
	@media (max-width: 600px), (max-height: 600px) and (pointer: coarse) {
		.bab-ai-bubble__panel { animation: bab-bubble-mobile-in .18s ease-out; }
		@keyframes bab-bubble-mobile-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
	}
}


/* Safe Markdown output */
.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text > :first-child {
	margin-top: 0;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text > :last-child {
	margin-bottom: 0;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text p {
	margin: 0 0 0.7em;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text ul,
.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text ol {
	margin: 0 0 0.8em 1.25em;
	padding: 0;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text li + li {
	margin-top: 0.35em;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text h3,
.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text h4,
.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text h5 {
	margin: 0.9em 0 0.45em;
	font-size: 1em;
	line-height: 1.35;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text a {
	text-decoration: underline;
	overflow-wrap: anywhere;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text code {
	font-family: monospace;
	font-size: 0.92em;
}

.bab-ai-bubble__message--assistant .bab-ai-bubble__message-text hr {
	margin: 1rem 0;
	border: 0;
	border-top: 1px solid #e1e5ea;
}


/* Active generation indicator */
.bab-ai-bubble__message--thinking .bab-ai-bubble__message-text {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
}
.bab-ai-bubble__thinking-dots { display: inline-flex; gap: .22rem; }
.bab-ai-bubble__thinking-dots i {
	width: .38rem;
	height: .38rem;
	border-radius: 50%;
	background: currentColor;
	opacity: .28;
	animation: bab-bubble-thinking 1.1s infinite ease-in-out;
}
.bab-ai-bubble__thinking-dots i:nth-child(2) { animation-delay: .16s; }
.bab-ai-bubble__thinking-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes bab-bubble-thinking {
	0%, 80%, 100% { transform: translateY(0); opacity: .25; }
	40% { transform: translateY(-3px); opacity: .85; }
}
@media (prefers-reduced-motion: reduce) {
	.bab-ai-bubble__thinking-dots i { animation: none; opacity: .6; }
}
