#dmac-widget {
	--dmac-blue: #6a3df0;
	--dmac-blue-dark: #5530d6;
	--dmac-bg: #f3f5f9;
	--dmac-text: #1b1f24;
	--dmac-muted: #6b7280;
	position: fixed;
	right: 16px;
	bottom: calc(16px + env(safe-area-inset-bottom));
	/* Closed: below the theme's cart drawer (9999) and modals; open: above everything. */
	z-index: 9000;
	font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: var(--dmac-text);
	-webkit-text-size-adjust: 100%;
}

#dmac-widget *,
#dmac-widget *::before,
#dmac-widget *::after {
	box-sizing: border-box;
}

#dmac-widget button {
	font-family: inherit;
	margin: 0;
}

/* ---------- Launcher (pill) ---------- */

#dmac-launcher {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	height: 56px;
	padding: 0 22px 0 16px;
	border: none;
	border-radius: 28px;
	background: var(--dmac-blue);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: 0.1px;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(106, 61, 240, 0.4);
	transition: transform 0.15s ease, background 0.15s ease;
}

#dmac-launcher:hover {
	background: var(--dmac-blue-dark);
	transform: translateY(-1px);
}

#dmac-launcher svg {
	width: 28px;
	height: 28px;
	flex: none;
}

#dmac-launcher::after {
	content: "";
	position: absolute;
	inset: -5px;
	border-radius: 34px;
	border: 2px solid var(--dmac-blue);
	opacity: 0;
	animation: dmac-ring 2.2s ease-out 1.5s 3;
	pointer-events: none;
}

@keyframes dmac-ring {
	0% { transform: scale(1); opacity: 0.7; }
	100% { transform: scale(1.18); opacity: 0; }
}

#dmac-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 10px;
	background: #e63946;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	box-shadow: 0 0 0 2px #fff;
}

/* ---------- Teaser bubble ---------- */

#dmac-bubble {
	position: absolute;
	right: 0;
	bottom: 70px;
	width: max-content;
	max-width: min(280px, calc(100vw - 32px));
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 34px 12px 12px;
	background: #fff;
	border-radius: 16px 16px 16px 4px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
	animation: dmac-pop 0.25s ease-out;
}

#dmac-bubble[hidden] {
	display: none;
}

.dmac-bubble-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	flex: none;
	object-fit: cover;
}

#dmac-bubble-close {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 28px;
	height: 28px;
	border: none;
	background: none;
	color: #9aa0a8;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

@keyframes dmac-pop {
	from { opacity: 0; transform: translateY(8px) scale(0.97); }
	to { opacity: 1; transform: none; }
}

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

#dmac-panel {
	position: fixed;
	right: 16px;
	bottom: calc(16px + env(safe-area-inset-bottom));
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 40px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#dmac-panel[hidden] {
	display: flex !important;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px);
	pointer-events: none;
}

#dmac-widget.dmac-open {
	z-index: 2147483000;
}

/* Cart page: icon-only launcher so it doesn't sit on the totals. */
.woocommerce-cart #dmac-launcher .dmac-launcher-label {
	display: none;
}

.woocommerce-cart #dmac-launcher {
	width: 56px;
	padding: 0;
	justify-content: center;
}

#dmac-widget.dmac-open #dmac-launcher,
#dmac-widget.dmac-open #dmac-bubble {
	display: none;
}

#dmac-header {
	flex: none;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 8px 12px 16px;
	background: var(--dmac-blue);
	color: #fff;
}

.dmac-avatar {
	position: relative;
	width: 40px;
	height: 40px;
	flex: none;
}

.dmac-avatar img {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #fff;
	object-fit: cover;
}

.dmac-online {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #2ecc71;
	box-shadow: 0 0 0 2px var(--dmac-blue);
}

.dmac-title {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.25;
}

.dmac-title strong {
	font-size: 16px;
	font-weight: 700;
}

.dmac-title small {
	font-size: 12.5px;
	opacity: 0.85;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#dmac-close {
	flex: none;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

#dmac-close:hover {
	background: rgba(255, 255, 255, 0.15);
}

#dmac-close svg {
	width: 22px;
	height: 22px;
}

/* ---------- Messages ---------- */

#dmac-messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 16px 12px 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: var(--dmac-bg);
}

.dmac-msg {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 18px;
	font-size: 15px;
	line-height: 1.42;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.dmac-msg.user {
	align-self: flex-end;
	background: var(--dmac-blue);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.dmac-msg.assistant {
	align-self: flex-start;
	background: #fff;
	color: var(--dmac-text);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.dmac-msg a {
	color: var(--dmac-blue);
	font-weight: 600;
	text-decoration: underline;
}

/* ---------- Product cards ---------- */

.dmac-products {
	align-self: stretch;
	flex-shrink: 0; /* overflow-x makes it shrinkable inside the column list */
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	padding: 2px 2px 6px;
	margin: 0 -12px 0 0;
	padding-right: 12px;
	scrollbar-width: none;
}

.dmac-products::-webkit-scrollbar {
	display: none;
}

.dmac-card {
	flex: 0 0 150px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 8px;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	color: var(--dmac-text);
	text-decoration: none;
	scroll-snap-align: start;
}

.dmac-products.single .dmac-card {
	flex-basis: 190px;
}

.dmac-card img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	border-radius: 10px;
	background: #fff;
}

.dmac-card-name {
	font-size: 13px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.dmac-card-price {
	font-size: 14px;
	font-weight: 700;
}

.dmac-card-price s {
	display: block;
	font-size: 12px;
	font-weight: 400;
	color: var(--dmac-muted);
}

.dmac-card-more {
	margin-top: auto;
	font-size: 13px;
	font-weight: 600;
	color: var(--dmac-blue);
}

.dmac-typing {
	display: flex;
	gap: 5px;
	padding: 14px 16px;
}

.dmac-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #a3aab5;
	animation: dmac-dot 1.2s infinite ease-in-out;
}

.dmac-typing span:nth-child(2) { animation-delay: 0.15s; }
.dmac-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dmac-dot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Quick replies ---------- */

#dmac-chips {
	flex: none;
	display: flex;
	flex-wrap: wrap; /* a mouse can't scroll a hidden horizontal scrollbar */
	gap: 8px;
	overflow-x: auto;
	padding: 4px 12px 10px;
	background: var(--dmac-bg);
	scrollbar-width: none;
}

#dmac-chips::-webkit-scrollbar {
	display: none;
}

#dmac-chips:empty {
	display: none;
}

.dmac-chip {
	flex: none;
	padding: 7px 12px;
	border: 1.5px solid var(--dmac-blue);
	border-radius: 18px;
	background: #fff;
	color: var(--dmac-blue);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
}

.dmac-chip:active {
	background: #e8f0fe;
}

/* ---------- Input ---------- */

#dmac-form {
	flex: none;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e6e9ee;
	background: #fff;
}

#dmac-input {
	flex: 1;
	min-width: 0;
	min-height: 44px;
	max-height: 120px;
	padding: 11px 14px;
	border: 1px solid #d7dbe0;
	border-radius: 22px;
	background: #f7f8fa;
	color: var(--dmac-text);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.3;
	resize: none;
	outline: none;
}

#dmac-input:focus {
	border-color: var(--dmac-blue);
	background: #fff;
}

#dmac-send {
	flex: none;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: var(--dmac-blue);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

#dmac-send svg {
	width: 20px;
	height: 20px;
	margin-left: 2px;
}

#dmac-send:disabled {
	opacity: 0.45;
	cursor: default;
}

/* ---------- Phone: full screen ---------- */

@media (max-width: 768px) {
	#dmac-launcher {
		height: 52px;
		padding: 0 18px 0 14px;
		font-size: 15px;
	}

	#dmac-launcher svg {
		width: 26px;
		height: 26px;
	}

	#dmac-bubble {
		bottom: 64px;
	}

	#dmac-panel {
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		width: 100%;
		max-width: none;
		height: 100vh;
		height: 100dvh;
		max-height: none;
		border-radius: 0;
		box-shadow: none;
	}

	#dmac-header {
		padding-top: calc(10px + env(safe-area-inset-top));
		padding-bottom: 10px;
	}

	#dmac-form {
		padding-bottom: calc(10px + env(safe-area-inset-bottom));
	}

	.dmac-msg {
		max-width: 86%;
	}
}

/* ---------- Dark theme: follows the site switch (html[data-theme], set by dm-site-tweaks/inc/dark.php) ---------- */

#dmac-widget {
	color-scheme: light;
}

html[data-theme="dark"] #dmac-widget {
	--dmac-bg: #0e1118;
	--dmac-text: #e9ebf3;
	--dmac-muted: #a0a7b8;
	--dmac-link: #b9a6ff;
	color-scheme: dark;
}

html[data-theme="dark"] #dmac-panel {
	background: #161a24;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .dmac-msg.assistant,
html[data-theme="dark"] .dmac-card,
html[data-theme="dark"] #dmac-bubble {
	background: #1e2331;
	color: var(--dmac-text);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] #dmac-bubble {
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .dmac-msg.assistant a,
html[data-theme="dark"] .dmac-card-more {
	color: var(--dmac-link);
}

/* Product photos are shot or cut out on white: keep them on a light tile. */
html[data-theme="dark"] .dmac-card img {
	background: #f3f5f9;
}

html[data-theme="dark"] .dmac-chip {
	border-color: #8b6cf6;
	background: #1e2331;
	color: var(--dmac-link);
}

html[data-theme="dark"] .dmac-chip:active {
	background: #2a2f45;
}

html[data-theme="dark"] .dmac-typing span {
	background: #6b7280;
}

html[data-theme="dark"] #dmac-form {
	border-top-color: #2a2f3e;
	background: #161a24;
}

html[data-theme="dark"] #dmac-input {
	border-color: #2a2f3e;
	background: #0e1118;
	color: var(--dmac-text);
}

html[data-theme="dark"] #dmac-input:focus {
	border-color: #8b6cf6;
	background: #0e1118;
}

html[data-theme="dark"] #dmac-input::placeholder {
	color: #8b93a7;
}

html[data-theme="dark"] #dmac-badge {
	box-shadow: 0 0 0 2px #0e1118;
}

html.dmac-lock,
html.dmac-lock body {
	overflow: hidden !important;
}

@media (prefers-reduced-motion: reduce) {
	#dmac-launcher::after,
	.dmac-typing span,
	#dmac-bubble {
		animation: none;
	}

	#dmac-panel,
	#dmac-launcher {
		transition: none;
	}
}

/* Very narrow windows (link previews ~200–360px): round icon button, no teaser over the content. */
@media (max-width: 359px) {
	#dmac-launcher {
		height: 48px;
		padding: 0 12px;
	}

	#dmac-launcher .dmac-launcher-label,
	#dmac-bubble {
		display: none !important;
	}
}
