/* Kreativa Assistant — follows the theme palette (light/dark) with brand-green fallbacks. */
.kasst {
	--kasst-bg: var(--wp--preset--color--surface, #191919);
	--kasst-ink: var(--wp--preset--color--contrast, #fff);
	--kasst-line: color-mix(in srgb, var(--kasst-ink) 14%, transparent);
	--kasst-accent: var(--wp--preset--color--primary, #9bed44);
	--kasst-bottom: 24px;
	position: fixed;
	z-index: 9990;
	right: 24px;
	bottom: var(--kasst-bottom);
	font-size: 15px;
	line-height: 1.45;
	color: var(--kasst-ink);
}
/* Signed-in desktop users have the inbox chat button in the corner; sit above it. */
body.logged-in .kasst { --kasst-bottom: 92px; }
@media (max-width: 781px) {
	/* Phones: above the bottom tab bar (the inbox popup is hidden there). */
	.kasst, body.logged-in .kasst { right: 14px; --kasst-bottom: calc(80px + env(safe-area-inset-bottom)); }
	body:has(.kpush-bar) .kasst:not(.is-open) { --kasst-bottom: calc(150px + env(safe-area-inset-bottom)); }
}

.kasst__fab {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 52px;
	padding: 0 18px 0 16px;
	border: 0;
	border-radius: 999px;
	background: var(--kasst-accent);
	color: #0a0a0a;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);
	transition: transform 0.15s ease;
}
.kasst__fab:hover { transform: translateY(-2px); }
.kasst__fab:focus-visible, .kasst button:focus-visible { outline: 2px solid var(--kasst-accent); outline-offset: 2px; }
.kasst__fab svg { width: 22px; height: 22px; }
.kasst.is-open .kasst__fab { display: none; }
@media (max-width: 781px) {
	.kasst__fab { width: 52px; padding: 0; justify-content: center; }
	.kasst__fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

.kasst__panel {
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 28px));
	height: min(560px, calc(100dvh - var(--kasst-bottom) - 90px));
	border: 1px solid var(--kasst-line);
	border-radius: 20px;
	background: var(--kasst-bg);
	box-shadow: 0 24px 60px rgb(0 0 0 / 0.45);
	overflow: hidden;
}
.kasst__panel[hidden] { display: none; }

.kasst__head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--kasst-line); }
.kasst__head div { flex: 1; min-width: 0; }
.kasst__head strong { display: block; font-size: 15px; }
.kasst__head small { display: block; font-size: 12px; opacity: 0.65; }
.kasst__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--kasst-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--kasst-accent) 25%, transparent); }
.kasst__head button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: 0.75; }
.kasst__head button:hover { opacity: 1; background: var(--kasst-line); }

.kasst__log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.kasst__msg { max-width: 85%; padding: 9px 13px; border-radius: 16px; overflow-wrap: anywhere; }
.kasst__msg--bot { align-self: flex-start; background: color-mix(in srgb, var(--kasst-ink) 8%, transparent); border-bottom-left-radius: 6px; }
.kasst__msg--user { align-self: flex-end; background: var(--kasst-accent); color: #0a0a0a; border-bottom-right-radius: 6px; }
.kasst__msg a { color: var(--kasst-accent); text-decoration: underline; }
.kasst__msg--typing { display: flex; gap: 4px; padding: 13px 14px; }
.kasst__msg--typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: kasst-dot 1s infinite; }
.kasst__msg--typing i:nth-child(2) { animation-delay: 0.15s; }
.kasst__msg--typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes kasst-dot { 50% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .kasst__msg--typing i { animation: none; } .kasst__fab { transition: none; } }

.kasst__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.kasst__chips[hidden] { display: none; }
.kasst__chips button { padding: 6px 12px; border: 1px solid var(--kasst-line); border-radius: 999px; background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.kasst__chips button:hover { border-color: var(--kasst-accent); }

.kasst__form { display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 10px 10px 6px 14px; border-top: 1px solid var(--kasst-line); }
/* Doubled class beats the theme's textarea min-height and focus ring. */
.kasst.kasst .kasst__form textarea { flex: 1; box-sizing: border-box; height: 40px; min-height: 0; max-height: 120px; margin: 0; padding: 9px 12px; border: 1px solid var(--kasst-line); border-radius: 14px; background: transparent; color: inherit; font: inherit; line-height: 20px; resize: none; box-shadow: none; outline: 0; }
.kasst.kasst .kasst__form textarea:focus { border-color: var(--kasst-accent); box-shadow: none; outline: 0; }
.kasst__form button { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--kasst-accent); color: #0a0a0a; cursor: pointer; }
.kasst__form button svg { width: 18px; height: 18px; }
.kasst__note { margin: 0; padding: 0 14px 10px; font-size: 11px; opacity: 0.55; }
