/* BittyBot widget — liquid glass aesthetic, scoped under .bittybot to avoid theme conflicts */

/* -------------------------------------------------------------------------
 *  Theme-conflict armor
 *  Many WordPress themes apply aggressive styles to all buttons/inputs
 *  (uppercase text, custom colors, padding overrides). Reset key properties
 *  inside our scope so the widget always looks the way it was designed.
 * ------------------------------------------------------------------------- */

.bittybot-stage,
.bittybot-stage * {
	box-sizing: border-box;
}

.bittybot button,
.bittybot__history button {
	text-transform: none !important;
	text-decoration: none !important;
	letter-spacing: normal;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	line-height: normal;
	min-height: 0;
	min-width: 0;
}

.bittybot input,
.bittybot textarea,
.bittybot__history input,
.bittybot__history textarea {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-transform: none !important;
	letter-spacing: normal;
}

.bittybot a {
	text-decoration-style: solid;
	background: transparent;
}

.bittybot-stage {
	position: relative;
	max-width: 1040px;
	margin: 1.5rem auto;
	padding: 0;
	min-height: 600px;
	display: flex;
	align-items: stretch;
	gap: 20px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* The avatar now sits BESIDE the chat in its own visible column */
.bittybot-avatar {
	flex: 0 0 320px;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	position: relative;
	overflow: visible;
}
.bittybot-avatar svg {
	width: 100%;
	max-width: 320px;
	height: auto;
	opacity: 0.88;
	filter: drop-shadow(0 8px 24px rgba(10, 37, 64, 0.18));
}

/* Soft atmospheric backdrop spans the entire stage */
.bittybot-stage::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	background:
		radial-gradient(ellipse 60% 70% at 80% 50%, rgba(245, 185, 66, 0.22) 0%, transparent 65%),
		radial-gradient(ellipse 80% 80% at 20% 30%, rgba(10, 37, 64, 0.10) 0%, transparent 60%),
		linear-gradient(135deg, #f4f6fb 0%, #e8edf5 100%);
	border-radius: 22px;
}

/* The chat panel itself — liquid glass */
.bittybot {
	--bb-brand:        #0a2540;
	--bb-accent:       #f5b942;
	--bb-text:         #1a2236;
	--bb-muted:        #5b6479;
	--bb-glass:        rgba(255, 255, 255, 0.55);
	--bb-glass-strong: rgba(255, 255, 255, 0.78);
	--bb-glass-border: rgba(255, 255, 255, 0.45);
	--bb-radius:       18px;

	flex: 1 1 auto;
	min-width: 0;
	position: relative;
	z-index: 1;
	background: var(--bb-glass);
	backdrop-filter: blur(28px) saturate(180%);
	-webkit-backdrop-filter: blur(28px) saturate(180%);
	border: 1px solid var(--bb-glass-border);
	border-radius: var(--bb-radius);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.6) inset,
		0 10px 40px rgba(10, 37, 64, 0.12),
		0 2px 8px rgba(10, 37, 64, 0.06);
	font-size: 15px;
	line-height: 1.55;
	color: var(--bb-text);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	min-height: 600px;
}

/* Fallback for browsers without backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	.bittybot { background: rgba(255, 255, 255, 0.92); }
}

.bittybot__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 22px;
	background: linear-gradient(135deg, rgba(10, 37, 64, 0.95) 0%, rgba(13, 46, 82, 0.92) 100%);
	backdrop-filter: blur(20px);
	color: #fff;
	border-bottom: 1px solid rgba(245, 185, 66, 0.18);
	position: relative;
}
.bittybot__header::after {
	content: '';
	position: absolute;
	left: 22px;
	right: 22px;
	bottom: 0;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(245, 185, 66, 0.6), transparent);
}

.bittybot__brand {
	display: flex;
	align-items: center;
	gap: 11px;
	font-weight: 500;
	letter-spacing: 0.02em;
	font-size: 16px;
}

.bittybot__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--bb-accent);
	box-shadow: 0 0 0 0 rgba(245, 185, 66, 0.7), 0 0 14px rgba(245, 185, 66, 0.6);
	animation: bb-pulse 2.4s ease-in-out infinite;
}

@keyframes bb-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(245, 185, 66, 0.7), 0 0 14px rgba(245, 185, 66, 0.6); }
	50%      { box-shadow: 0 0 0 8px rgba(245, 185, 66, 0),   0 0 18px rgba(245, 185, 66, 0.9); }
}

.bittybot__header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.bittybot__clear,
.bittybot__history-btn {
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.22);
	color: #fff;
	padding: 6px 14px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: all 0.18s ease;
	backdrop-filter: blur(6px);
	font-family: inherit;
}
.bittybot__clear:hover,
.bittybot__history-btn:hover {
	background: rgba(255, 255, 255, 0.16);
	border-color: rgba(245, 185, 66, 0.5);
}

.bittybot__messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 24px 22px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-height: 60vh;
	scroll-behavior: smooth;
}
.bittybot__messages::-webkit-scrollbar { width: 8px; }
.bittybot__messages::-webkit-scrollbar-thumb {
	background: rgba(10, 37, 64, 0.18);
	border-radius: 4px;
}
.bittybot__messages::-webkit-scrollbar-thumb:hover { background: rgba(10, 37, 64, 0.32); }

.bittybot__msg {
	display: flex;
	max-width: 88%;
	animation: bb-msg-in 0.32s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.bittybot__msg--bot  { align-self: flex-start; }
.bittybot__msg--user { align-self: flex-end; }
.bittybot__msg--welcome { align-self: center; max-width: 92%; }

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

.bittybot__bubble {
	padding: 13px 17px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/* Stop iOS / Android from inflating reply text, and keep every message inside the panel */
.bittybot, .bittybot * { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.bittybot__messages { min-width: 0; }
.bittybot__msg { min-width: 0; }
.bittybot__bubble img, .bittybot__bubble pre { max-width: 100%; }
.bittybot__bubble pre { overflow-x: auto; white-space: pre-wrap; }

/* Headings and rules inside replies */
.bittybot__bubble .bb-h { font-weight: 700; color: var(--bb-brand); line-height: 1.3; margin: 0.9em 0 0.35em; }
.bittybot__bubble .bb-h:first-child { margin-top: 0; }
.bittybot__bubble .bb-h1 { font-size: 1.15em; }
.bittybot__bubble .bb-h2 { font-size: 1.07em; }
.bittybot__bubble .bb-h3 { font-size: 1em; }
.bittybot__bubble .bb-rule { border: 0; border-top: 1px solid rgba(10, 37, 64, 0.12); margin: 0.9em 0; }
.bittybot__bubble .bb-table-wrap { max-width: 100%; }
/* Table cells break between words, never inside a word or a price; the table scrolls sideways instead */
.bittybot__bubble .bb-table td, .bittybot__bubble .bb-table th { overflow-wrap: normal; word-break: normal; }
.bittybot__bubble .bb-table td.bb-num { white-space: nowrap; }

/* Bot bubble — bright glass card with gold accent, clearly distinct from surface */
.bittybot__msg--bot .bittybot__bubble {
	background: var(--bb-glass-strong);
	backdrop-filter: blur(14px) saturate(160%);
	-webkit-backdrop-filter: blur(14px) saturate(160%);
	border: 1px solid rgba(255, 255, 255, 0.7);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.9) inset,
		0 4px 14px rgba(10, 37, 64, 0.08),
		0 1px 3px rgba(10, 37, 64, 0.04);
	border-bottom-left-radius: 4px;
	color: var(--bb-text);
	position: relative;
}

/* Subtle gold accent strip on the bot bubble's left edge */
.bittybot__msg--bot .bittybot__bubble::before {
	content: '';
	position: absolute;
	left: 0;
	top: 14px;
	bottom: 14px;
	width: 3px;
	background: linear-gradient(180deg, transparent, var(--bb-accent), transparent);
	border-radius: 0 2px 2px 0;
	opacity: 0.6;
}

/* User bubble — solid navy, high contrast */
.bittybot__msg--user .bittybot__bubble {
	background: linear-gradient(135deg, #0a2540 0%, #143862 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
	box-shadow: 0 4px 14px rgba(10, 37, 64, 0.22);
}

.bittybot__bubble p { margin: 0.4em 0; }
.bittybot__bubble p:first-child { margin-top: 0; }
.bittybot__bubble p:last-child { margin-bottom: 0; }

.bittybot__bubble strong { font-weight: 600; }
.bittybot__bubble ul,
.bittybot__bubble ol { margin: 0.5em 0; padding-left: 1.5em; }
.bittybot__bubble li { margin: 0.25em 0; }
.bittybot__bubble code {
	background: rgba(10, 37, 64, 0.08);
	padding: 1px 6px;
	border-radius: 5px;
	font-size: 0.9em;
	font-family: ui-monospace, "SF Mono", Monaco, Consolas, monospace;
}
.bittybot__msg--user .bittybot__bubble code {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}
.bittybot__bubble a {
	color: var(--bb-brand);
	text-decoration: underline;
	text-decoration-color: rgba(245, 185, 66, 0.5);
	text-underline-offset: 2px;
}
.bittybot__msg--user .bittybot__bubble a { color: var(--bb-accent); }

/* Prestigious table styling */
.bittybot__bubble .bb-table-wrap {
	margin: 12px 0 4px;
	overflow-x: auto;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.7);
	border: 1px solid rgba(10, 37, 64, 0.08);
	box-shadow: 0 2px 8px rgba(10, 37, 64, 0.04);
}
.bittybot__bubble .bb-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
	background: transparent;
}
.bittybot__bubble .bb-table thead {
	background: linear-gradient(180deg, rgba(10, 37, 64, 0.04) 0%, rgba(10, 37, 64, 0.06) 100%);
}
.bittybot__bubble .bb-table th {
	text-align: left;
	padding: 11px 14px;
	font-weight: 600;
	color: var(--bb-brand);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-bottom: 2px solid var(--bb-accent);
	white-space: nowrap;
}
.bittybot__bubble .bb-table td {
	padding: 11px 14px;
	border-bottom: 1px solid rgba(10, 37, 64, 0.06);
	color: var(--bb-text);
	vertical-align: top;
}
.bittybot__bubble .bb-table tbody tr:last-child td { border-bottom: 0; }
.bittybot__bubble .bb-table tbody tr {
	transition: background 0.15s ease;
}
.bittybot__bubble .bb-table tbody tr:hover {
	background: rgba(245, 185, 66, 0.07);
}
.bittybot__bubble .bb-table td.bb-num,
.bittybot__bubble .bb-table th.bb-num {
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

/* Welcome message centering */
.bittybot__msg--welcome .bittybot__bubble {
	text-align: center;
	padding: 18px 24px;
}
.bittybot__msg--welcome .bittybot__bubble::before { display: none; }

/* Citations under bot replies */
.bittybot__citations {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid rgba(10, 37, 64, 0.1);
	font-size: 12px;
	color: var(--bb-muted);
}
.bittybot__citations strong { color: var(--bb-text); display: block; margin-bottom: 4px; }
.bittybot__citations ol { padding-left: 1.4em; margin: 4px 0 0; }
.bittybot__citations a { color: var(--bb-brand); }

/* Thinking indicator */
.bittybot__thinking {
	display: inline-flex;
	gap: 5px;
	padding: 2px 0;
	margin-right: 10px;
	vertical-align: middle;
}
.bittybot__thinking span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--bb-brand);
	opacity: 0.6;
	animation: bb-dot 1.3s infinite ease-in-out;
}
.bittybot__thinking span:nth-child(2) { animation-delay: 0.16s; }
.bittybot__thinking span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bb-dot {
	0%, 80%, 100% { opacity: 0.25; transform: scale(0.75); }
	40%           { opacity: 1;    transform: scale(1); }
}

.bittybot__status {
	display: inline-block;
	font-size: 13px;
	color: var(--bb-muted);
	font-style: italic;
	vertical-align: middle;
}

/* Composer */
.bittybot__composer {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 14px 18px;
	border-top: 1px solid rgba(10, 37, 64, 0.08);
	background: rgba(255, 255, 255, 0.6);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
}

.bittybot__input {
	flex: 1 1 auto;
	resize: none;
	border: 1px solid rgba(10, 37, 64, 0.12);
	border-radius: 14px;
	padding: 13px 16px;
	font: inherit;
	font-size: 16px;          /* 16px: an iPhone does not zoom in on it */
	line-height: 1.45;
	color: var(--bb-text);
	outline: none;
	min-height: 84px;         /* about three lines to start; grows to 300px as you type (widget.js) */
	max-height: 300px;
	background: rgba(255, 255, 255, 0.85);
	transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
	font-family: inherit;
}
.bittybot__input::placeholder { color: rgba(91, 100, 121, 0.7); }
.bittybot__input:focus {
	border-color: var(--bb-brand);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.08);
}

/* Send button — clear, premium pill with text + arrow */
.bittybot__send {
	flex: 0 0 auto;
	border: 0;
	border-radius: 999px;
	padding: 11px 22px 11px 24px;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: #fff;
	cursor: pointer;
	background: linear-gradient(135deg, #0a2540 0%, #1a4675 100%);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.2) inset,
		0 4px 12px rgba(10, 37, 64, 0.28),
		0 1px 3px rgba(10, 37, 64, 0.16);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	transition: transform 0.15s ease, box-shadow 0.18s ease, background 0.18s ease;
	font-family: inherit;
}
.bittybot__send::after {
	content: '\2192';
	font-size: 18px;
	font-weight: 400;
	line-height: 1;
	transition: transform 0.2s ease;
}
.bittybot__send:hover {
	background: linear-gradient(135deg, #0d2e52 0%, #1f5189 100%);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.25) inset,
		0 6px 18px rgba(10, 37, 64, 0.34),
		0 2px 5px rgba(10, 37, 64, 0.2);
	transform: translateY(-1px);
}
.bittybot__send:hover::after { transform: translateX(3px); }
.bittybot__send:active { transform: translateY(0); }
.bittybot__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
}
.bittybot__send:disabled:hover::after { transform: none; }

.bittybot__error {
	color: #b3261e;
	font-size: 13px;
}

.bittybot-locked {
	max-width: 480px;
	margin: 2rem auto;
	padding: 1.6rem 1.8rem;
	border: 1px solid rgba(10, 37, 64, 0.12);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.7);
	backdrop-filter: blur(20px);
	color: #5b6479;
	text-align: center;
}
.bittybot-locked a { color: #0a2540; font-weight: 600; }
.bittybot-locked p { margin: 0 0 1.1rem; line-height: 1.5; }
/* the theme colours links like body text - the button sets its own look */
.bittybot-locked a.bittybot-locked__btn,
.bittybot a.bittybot__signin {
	display: inline-block;
	min-height: 44px;
	padding: 11px 26px;
	border-radius: 999px;
	background: #0a2540;
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	line-height: 22px;
	text-decoration: none;
	box-shadow: 0 4px 14px rgba(10, 37, 64, 0.22);
	box-sizing: border-box;
}
.bittybot-locked a.bittybot-locked__btn:hover,
.bittybot-locked a.bittybot-locked__btn:focus,
.bittybot a.bittybot__signin:hover,
.bittybot a.bittybot__signin:focus { background: #163a5f; color: #fff; text-decoration: none; }
.bittybot a.bittybot__signin { margin-top: 10px; padding: 8px 20px; min-height: 40px; }
.bittybot__signin-note { display: block; margin-top: 6px; color: #5b6479; font-size: 13px; }
@media (max-width: 520px) {
	.bittybot-locked { margin: 1.25rem 16px; padding: 1.4rem 1.1rem; }
	.bittybot-locked a.bittybot-locked__btn { display: block; width: 100%; }
}

@media (max-width: 960px) {
	.bittybot-stage {
		max-width: 720px;
		gap: 0;
	}
	.bittybot-avatar { display: none; }
}

@media (max-width: 700px) {
	.bittybot__input { min-height: 64px; max-height: 220px; }
	.bittybot-stage {
		margin: 0;
		padding: 0;
		border-radius: 0;
		min-height: 100vh;
		flex-direction: column;
	}
	.bittybot-stage::before { border-radius: 0; }
	.bittybot {
		border-radius: 0;
		border-left: 0;
		border-right: 0;
		min-height: 100vh;
	}
	.bittybot__messages { max-height: none; }
}

/* -------------------------------------------------------------------------
 *  History drawer
 * ------------------------------------------------------------------------- */

.bittybot__history {
	flex: 1 1 auto;
	overflow-y: auto;
	background: rgba(255, 255, 255, 0.4);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	display: flex;
	flex-direction: column;
	min-height: 0;
}

/* Bulletproof [hidden] — class display rules have higher specificity than the global [hidden] selector, so we must override explicitly */
.bittybot__history[hidden],
.bittybot__messages[hidden] { display: none !important; }

.bittybot__history-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 22px;
	border-bottom: 1px solid rgba(10, 37, 64, 0.1);
	background: rgba(255, 255, 255, 0.5);
	position: sticky;
	top: 0;
	z-index: 1;
}

.bittybot__history-back {
	background: rgba(10, 37, 64, 0.04) !important;
	border: 1px solid rgba(10, 37, 64, 0.12) !important;
	color: #0a2540 !important;
	padding: 6px 12px;
	border-radius: 8px;
	font-size: 13px;
	cursor: pointer;
	font-family: inherit;
	font-weight: 500;
	transition: background 0.15s ease;
}
.bittybot__history-back:hover {
	background: rgba(10, 37, 64, 0.08) !important;
	color: #0a2540 !important;
}

.bittybot__history-title {
	font-weight: 600;
	color: var(--bb-brand);
	font-size: 14px;
	letter-spacing: 0.02em;
}

.bittybot__history-list {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 8px 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.bittybot__history-empty {
	padding: 30px 16px;
	text-align: center;
	color: var(--bb-muted);
	font-size: 14px;
}

.bittybot__history-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.7);
	border: 1px solid rgba(10, 37, 64, 0.06);
	transition: all 0.15s ease;
}
.bittybot__history-item:hover {
	background: rgba(255, 255, 255, 0.95);
	border-color: rgba(10, 37, 64, 0.15);
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(10, 37, 64, 0.06);
}

.bittybot__history-item--other {
	border-left: 3px solid var(--bb-accent);
}

.bittybot__history-item-main {
	flex: 1 1 auto;
	min-width: 0;
	cursor: pointer;
}

.bittybot__history-item-title {
	font-size: 14px;
	color: var(--bb-text);
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.4;
}

.bittybot__history-item-meta {
	font-size: 11px;
	color: var(--bb-muted);
	margin-top: 2px;
	letter-spacing: 0.02em;
}
.bittybot__history-item-user {
	color: var(--bb-brand);
	font-weight: 600;
	background: rgba(245, 185, 66, 0.15);
	padding: 1px 6px;
	border-radius: 3px;
}

.bittybot__history-item-delete {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: transparent;
	border: 0;
	color: var(--bb-muted);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.4;
	transition: all 0.15s ease;
	font-family: inherit;
}
.bittybot__history-item:hover .bittybot__history-item-delete { opacity: 1; }
.bittybot__history-item-delete:hover {
	background: rgba(179, 38, 30, 0.1);
	color: #b3261e;
}

/* -------------------------------------------------------------------------
 *  Read-only banner
 * ------------------------------------------------------------------------- */

.bittybot__readonly {
	padding: 10px 22px;
	background: rgba(245, 185, 66, 0.15);
	color: var(--bb-brand);
	font-size: 13px;
	border-bottom: 1px solid rgba(245, 185, 66, 0.3);
	text-align: center;
}
.bittybot__readonly strong { font-weight: 600; }

/* -------------------------------------------------------------------------
 *  Per-message action bar (Export PNG button)
 * ------------------------------------------------------------------------- */

.bittybot__msg {
	flex-direction: column;
	align-items: flex-start;
}
.bittybot__msg--user { align-items: flex-end; }
.bittybot__msg--welcome { align-items: center; }

.bittybot__msg-actions {
	margin-top: 6px;
	padding-left: 4px;
	opacity: 0;
	transition: opacity 0.2s ease;
}
.bittybot__msg:hover .bittybot__msg-actions,
.bittybot__msg:focus-within .bittybot__msg-actions {
	opacity: 1;
}
/* Always show on last message for discoverability */
.bittybot__msg:last-child .bittybot__msg-actions { opacity: 0.7; }
.bittybot__msg:last-child:hover .bittybot__msg-actions { opacity: 1; }

.bittybot__export-btn {
	background: rgba(255, 255, 255, 0.7);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border: 1px solid rgba(10, 37, 64, 0.12);
	color: var(--bb-brand);
	padding: 5px 12px;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 500;
	letter-spacing: 0.03em;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-family: inherit;
	transition: all 0.15s ease;
}
/* your messages: Edit / Copy / Resend sit under the bubble, on the right */
.bittybot__msg--user .bittybot__msg-actions { padding-left: 0; padding-right: 4px; display: flex; gap: 6px; justify-content: flex-end; }
.bittybot__msg--bot .bittybot__msg-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bittybot__msg-actions[hidden], .bittybot__bubble[hidden] { display: none !important; }
.bittybot--readonly .bb-act-edit,
.bittybot--readonly .bb-act-resend { display: none; }
/* editing a sent message in place */
.bittybot__msg.is-editing { align-self: stretch; width: 100%; max-width: 100%; }
.bittybot__edit { width: min(640px, 100%); margin-left: auto; display: flex; flex-direction: column; gap: 8px; }
.bittybot__edit-in {
	width: 100%; box-sizing: border-box; resize: vertical; min-height: 84px; max-height: 300px;
	padding: 12px 14px; border-radius: 14px; border: 2px solid var(--bb-brand, #0a2540); background: #fff;
	font: inherit; font-size: 16px; line-height: 1.45; color: var(--bb-text); outline: none;
}
.bittybot__edit-note { font-size: 12px; color: rgba(91, 100, 121, 0.9); text-align: right; }
.bittybot__edit-f { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.bittybot__export-btn:hover {
	background: rgba(255, 255, 255, 0.95);
	border-color: var(--bb-accent);
	color: var(--bb-brand);
	transform: translateY(-1px);
	box-shadow: 0 2px 6px rgba(10, 37, 64, 0.08);
}
.bittybot__export-btn:disabled {
	opacity: 0.6;
	cursor: wait;
	transform: none;
}
.bittybot__export-btn span {
	font-size: 13px;
	line-height: 1;
}

/* -------------------------------------------------------------------------
 *  Blockquotes — internal staff notes vs regular quotes
 * ------------------------------------------------------------------------- */

.bittybot__bubble blockquote {
	margin: 14px 0;
	font-size: 13.5px;
	line-height: 1.55;
	quotes: none;
}
.bittybot__bubble blockquote p { margin: 0.3em 0; }
.bittybot__bubble blockquote p:first-child { margin-top: 0; }
.bittybot__bubble blockquote p:last-child { margin-bottom: 0; }

/* Theme-conflict armor: many WP themes inject a large curly-quote character via
 * `blockquote::before { content: '"' }`. Kill it cleanly. We target only the
 * blockquote itself and its direct <p> children, NOT all descendants, so our
 * own label pseudo-element is unaffected. */
.bittybot__bubble blockquote::before,
.bittybot__bubble blockquote::after,
.bittybot__bubble blockquote > p::before,
.bittybot__bubble blockquote > p::after {
	content: none !important;
	display: none !important;
}

.bittybot__bubble blockquote.bb-quote {
	background: rgba(10, 37, 64, 0.04);
	border-left: 3px solid rgba(10, 37, 64, 0.25);
	border-radius: 0 8px 8px 0;
	padding: 10px 14px 10px 16px;
	color: #5b6479;
	font-style: italic;
}

/* Internal note — refined liquid-glass gold card */
.bittybot__bubble blockquote.bb-internal {
	position: relative;
	background: linear-gradient(135deg,
		rgba(255, 247, 224, 0.78) 0%,
		rgba(245, 185, 66, 0.20) 100%);
	backdrop-filter: blur(14px) saturate(160%);
	-webkit-backdrop-filter: blur(14px) saturate(160%);
	border: 1px solid rgba(245, 185, 66, 0.42);
	border-radius: 14px;
	padding: 14px 18px 15px;
	color: #4a3d1f;
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.85) inset,
		0 -1px 0 rgba(245, 185, 66, 0.14) inset,
		0 4px 18px rgba(245, 185, 66, 0.18),
		0 2px 6px rgba(10, 37, 64, 0.06);
}

.bittybot__bubble blockquote.bb-internal .bb-internal-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	color: #7a5a14;
	background: linear-gradient(135deg,
		rgba(245, 185, 66, 0.52) 0%,
		rgba(245, 185, 66, 0.30) 100%);
	padding: 4px 11px 4px 9px;
	border-radius: 999px;
	margin-bottom: 10px;
	border: 1px solid rgba(245, 185, 66, 0.48);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.55) inset,
		0 1px 2px rgba(122, 90, 20, 0.08);
}
.bittybot__bubble blockquote.bb-internal .bb-internal-label::before {
	content: '\1F441';
	font-size: 11px;
	opacity: 0.9;
	line-height: 1;
}

/* Inline code inside internal notes — softer tone so it pops on the gold background */
.bittybot__bubble blockquote.bb-internal code {
	background: rgba(255, 255, 255, 0.65);
	border: 1px solid rgba(245, 185, 66, 0.3);
	color: #5a4715;
}

/* -------------------------------------------------------------------------
 *  Avatar — active working state (when BittyBot is processing)
 * ------------------------------------------------------------------------- */

.bittybot-avatar svg {
	transition: filter 0.4s ease;
}
.bittybot-stage--working .bittybot-avatar svg {
	animation: bb-avatar-working 0.9s ease-in-out infinite;
}
@keyframes bb-avatar-working {
	0%, 100% {
		filter: drop-shadow(0 8px 24px rgba(245, 185, 66, 0.35));
		transform: scale(1) rotate(-1.5deg);
	}
	25% {
		filter: drop-shadow(0 12px 32px rgba(245, 185, 66, 0.55));
		transform: scale(1.035) rotate(0.8deg);
	}
	50% {
		filter: drop-shadow(0 18px 48px rgba(245, 185, 66, 0.9));
		transform: scale(1.07) rotate(1.5deg);
	}
	75% {
		filter: drop-shadow(0 12px 32px rgba(245, 185, 66, 0.55));
		transform: scale(1.035) rotate(-0.8deg);
	}
}

/* Speed up the inner element animations significantly to suggest BittyBot is thinking hard */

/* Lumi */
.bittybot-stage--working .bb-lm-root  { animation-duration: 1.8s !important; }
.bittybot-stage--working .bb-lm-tilt  { animation-duration: 1.8s !important; }
.bittybot-stage--working .bb-lm-pulse { animation-duration: 0.55s !important; }
.bittybot-stage--working .bb-lm-scan  { animation-duration: 0.9s !important; }
.bittybot-stage--working .bb-lm-shim,
.bittybot-stage--working .bb-lm-shim2 { animation-duration: 0.45s !important; }

/* Spark — eyes dart and blink, antenna pulses fast, body wiggles */
.bittybot-stage--working .bb-spark-root  { animation-duration: 1s !important; }
.bittybot-stage--working .bb-spark-eye-l,
.bittybot-stage--working .bb-spark-eye-r { animation-duration: 1.1s !important; }
.bittybot-stage--working .bb-spark-pulse { animation-duration: 0.5s !important; }

/* Nexus — rings spin much faster, core throbs */
.bittybot-stage--working .bb-nx-cw    { animation-duration: 3.5s !important; }
.bittybot-stage--working .bb-nx-ccw   { animation-duration: 2.3s !important; }
.bittybot-stage--working .bb-nx-cw2   { animation-duration: 2.8s !important; }
.bittybot-stage--working .bb-nx-ccw2  { animation-duration: 1.1s !important; }
.bittybot-stage--working .bb-nx-pulse,
.bittybot-stage--working .bb-nx-core  { animation-duration: 0.65s !important; }
.bittybot-stage--working .bb-nx-d1,
.bittybot-stage--working .bb-nx-d2,
.bittybot-stage--working .bb-nx-d3    { animation-duration: 1.4s !important; }

/* -------------------------------------------------------------------------
 *  Mobile (iPhone 12 Pro 390px, iPhone 16 Pro Max 440px, etc.)
 * ------------------------------------------------------------------------- */

@media (max-width: 700px) {
	html, body { overflow-x: hidden; }

	.bittybot-stage {
		margin: 0;
		padding: 0;
		border-radius: 0;
		min-height: 100vh;
		min-height: 100dvh;
		flex-direction: column;
		max-width: 100%;
		width: 100%;
	}
	.bittybot-stage::before { border-radius: 0; }
	.bittybot {
		border-radius: 0;
		border-left: 0;
		border-right: 0;
		min-height: 100vh;
		min-height: 100dvh;
	}
	.bittybot__messages { max-height: none; padding: 16px 12px; gap: 12px; }
	.bittybot__history-list { padding: 10px 10px 14px; }

	/* Header: tighter, but title + both action buttons must fit on iPhone SE width */
	.bittybot__header { padding: 12px 14px; }
	.bittybot__brand { gap: 8px; font-size: 14px; }
	.bittybot__title { font-size: 15px; }
	.bittybot__header-actions { gap: 6px; }
	.bittybot__clear,
	.bittybot__history-btn {
		padding: 6px 11px;
		font-size: 11.5px;
	}

	/* Bubbles roomier on touch screens */
	.bittybot__msg { max-width: 94%; }
	.bittybot__bubble { padding: 12px 14px; font-size: 14.5px; line-height: 1.55; }

	/* Welcome bubble shouldn't be too wide on mobile either */
	.bittybot__msg--welcome { max-width: 100%; }
	.bittybot__msg--welcome .bittybot__bubble { padding: 14px 18px; }

	/* Composer: 16px input prevents iOS auto-zoom on focus */
	.bittybot__composer {
		padding: 10px 12px;
		padding-bottom: max(10px, env(safe-area-inset-bottom));
		gap: 8px;
	}
	.bittybot__input {
		font-size: 16px;
		padding: 11px 14px;
	}
	.bittybot__send {
		padding: 11px 18px;
		font-size: 14px;
	}

	/* Bot replies use the full width on a phone; the user's own bubble stays to the right */
	.bittybot__msg--bot { max-width: 100%; width: 100%; }
	.bittybot__msg--bot .bittybot__bubble { width: 100%; font-size: 15px; }

	/* Tables: two columns scroll sideways if they must; three or more become one card per row */
	.bittybot__bubble .bb-table-wrap { margin-left: -4px; margin-right: -4px; }
	.bittybot__bubble .bb-table { font-size: 13px; }
	.bittybot__bubble .bb-table th,
	.bittybot__bubble .bb-table td { padding: 9px 11px; }
	.bittybot__bubble .bb-table th { white-space: normal; }

	.bittybot__bubble .bb-table-wrap:has(.bb-table--stack) { background: transparent; border: 0; box-shadow: none; overflow: visible; margin-left: 0; margin-right: 0; }
	.bittybot__bubble .bb-table--stack,
	.bittybot__bubble .bb-table--stack tbody,
	.bittybot__bubble .bb-table--stack tr,
	.bittybot__bubble .bb-table--stack td { display: block; width: 100%; }
	.bittybot__bubble .bb-table--stack thead { display: none; }
	.bittybot__bubble .bb-table--stack tr {
		background: rgba(255, 255, 255, 0.75);
		border: 1px solid rgba(10, 37, 64, 0.08);
		border-left: 3px solid var(--bb-accent);
		border-radius: 10px;
		padding: 4px 0;
		margin: 0 0 8px;
	}
	.bittybot__bubble .bb-table--stack tr:last-child { margin-bottom: 0; }
	.bittybot__bubble .bb-table--stack td {
		display: flex;
		gap: 12px;
		justify-content: space-between;
		align-items: baseline;
		text-align: right !important;
		overflow-wrap: anywhere;
		padding: 6px 12px;
		border-bottom: 1px solid rgba(10, 37, 64, 0.05);
	}
	.bittybot__bubble .bb-table--stack tr td:last-child { border-bottom: 0; }
	.bittybot__bubble .bb-table--stack td::before {
		content: attr(data-label);
		flex: 0 0 auto;
		max-width: 45%;
		text-align: left;
		font-size: 10.5px;
		font-weight: 600;
		letter-spacing: 0.05em;
		text-transform: uppercase;
		color: var(--bb-brand);
		opacity: 0.75;
	}
	.bittybot__bubble .bb-table--stack td:first-child {
		font-weight: 600;
		font-size: 14px;
		text-align: left !important;
		display: block;
	}
	.bittybot__bubble .bb-table--stack td:first-child::before { display: block; max-width: none; margin-bottom: 2px; }
	.bittybot__bubble .bb-table--stack td:empty { display: none; }

	/* History panel + items */
	.bittybot__history-header { padding: 12px 14px; gap: 10px; }
	.bittybot__history-title { font-size: 13px; }
	.bittybot__history-back { padding: 6px 10px; font-size: 12px; }
	.bittybot__history-item { padding: 11px 12px; }
	.bittybot__history-item-title { font-size: 14px; }
	.bittybot__history-item-meta { font-size: 11px; }
	.bittybot__history-item-delete {
		width: 32px;
		height: 32px;
		font-size: 20px;
		opacity: 0.6;
	}

	/* Per-message action bar (export PNG): always visible on touch */
	.bittybot__msg-actions { opacity: 0.85 !important; margin-top: 8px; }
	.bittybot__export-btn { padding: 6px 13px; font-size: 12px; }

	/* Read-only banner */
	.bittybot__readonly { padding: 10px 14px; font-size: 12.5px; }
}

/* Extra-narrow phones (iPhone SE 320, older Androids) */
@media (max-width: 360px) {
	.bittybot__title { font-size: 14px; }
	.bittybot__clear,
	.bittybot__history-btn { padding: 5px 9px; font-size: 11px; }
	.bittybot__brand .bittybot__dot { width: 7px; height: 7px; }
}

/* -------------------------------------------------------------------------
 *  Products in an answer (1.8.0): names in the reply link to their pages;
 *  (QuickInvoice) beside each - in its row of the results table, after the
 *  price - ticks it; "Add all to QuickInvoice" at the bottom of the results
 * ------------------------------------------------------------------------- */

.bittybot__bubble a.bb-ilink {
	color: var(--bb-brand);
	text-decoration: underline;
	text-decoration-color: rgba(245, 185, 66, 0.9);
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
	border-radius: 3px;
}
.bittybot__bubble a.bb-ilink:hover { background: rgba(245, 185, 66, 0.18); }

.bittybot .bb-qib {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: 8px;
	padding: 3px 9px 3px 8px;
	border-radius: 999px;
	border: 1px solid rgba(10, 37, 64, 0.2);
	background: #fff;
	color: var(--bb-brand);
	font-size: 11.5px;
	font-weight: 600;
	line-height: 1.35;
	vertical-align: middle;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}
.bittybot .bb-qib::before { content: '+'; font-size: 13px; font-weight: 700; line-height: 1; }
.bittybot .bb-qib:hover { border-color: var(--bb-accent); background: #fffaf0; }
.bittybot .bb-qib[aria-pressed="true"] { background: var(--bb-accent); border-color: var(--bb-accent); }
.bittybot .bb-qib[aria-pressed="true"]::before { content: '\2713'; font-size: 12px; }

/* the QuickInvoice column at the end of a results table; the send button under the results */
.bittybot__bubble .bb-table th.bb-qcol,
.bittybot__bubble .bb-table td.bb-qcol { width: 1%; white-space: nowrap; padding-left: 4px; text-align: right; }
.bittybot__bubble .bb-table td.bb-qcol .bb-qib { margin-left: 0; }
.bb-qi { margin-top: 12px; }
.bb-qi[hidden], .bb-qi__send[hidden] { display: none; }
.bb-qi__send { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid rgba(10, 37, 64, 0.1); align-self: stretch; }
.bittybot .bb-qi__go {
	display: inline-flex;
	align-items: center;
	padding: 9px 18px;
	border-radius: 999px;
	background: linear-gradient(135deg, #0a2540 0%, #1a4675 100%);
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	box-shadow: 0 4px 12px rgba(10, 37, 64, 0.25);
}
.bittybot .bb-qi__go:hover { box-shadow: 0 6px 16px rgba(10, 37, 64, 0.32); color: #fff; }
.bb-qi__x { border: 0; background: none; padding: 6px 4px; font-size: 12.5px; color: var(--bb-muted); cursor: pointer; }
.bb-qi__x:hover { color: var(--bb-brand); }

/* -------------------------------------------------------------------------
 *  Filling the view (1.8.0): widget.js sets the stage's width (nearly edge to
 *  edge, out of the theme's content column) and --bb-fill, the height from
 *  where the console starts to the bottom of the screen. The avatar is slimmer
 *  and steps aside on smaller screens.
 * ------------------------------------------------------------------------- */

.bittybot-stage { max-width: none; margin-top: 12px; margin-bottom: 12px; min-height: 0; gap: 16px; }
.bittybot-avatar { flex: 0 0 clamp(150px, 13vw, 230px); }
.bittybot { height: var(--bb-fill, 80vh); min-height: 0; }
.bittybot__messages { max-height: none; min-height: 0; }

@media (max-width: 1100px) {
	.bittybot-stage { gap: 0; }
	.bittybot-avatar { display: none; }
}

@media (max-width: 700px) {
	.bittybot-stage { margin-top: 0; margin-bottom: 0; min-height: 0; }
	.bittybot { min-height: 0; }
	.bittybot .bb-qib { padding: 4px 10px 4px 9px; }
	.bittybot__bubble .bb-table--stack td.bb-qcol { justify-content: flex-end; width: 100%; }
	.bittybot__bubble .bb-table--stack td.bb-qcol:empty { display: none; }
	.bittybot__bubble .bb-table--stack td.bb-qcol::before { display: none; }
}
