#pioh-luna-root {
	--luna-accent: #7C4DA6;
	--luna-accent-dark: #5F3985;
	--luna-accent-pale: #EEE1F5;
	--luna-btn-size: 64px;
	--luna-panel-w: 340px;
	--luna-panel-h: 460px;
	--luna-offset: 24px;
	position: fixed;
	right: var(--luna-offset);
	bottom: var(--luna-offset);
	z-index: 99999;
	font-family: 'Karla', 'Inter', sans-serif;
}

#pioh-luna-toggle {
	width: var(--luna-btn-size);
	height: var(--luna-btn-size);
	border-radius: 50%;
	background: #FCF9FD;
	border: 1px solid rgba(201, 182, 228, 0.45);
	box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	line-height: 1;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#pioh-luna-toggle:hover {
	transform: scale(1.06);
	box-shadow: 0 12px 32px rgba(124, 77, 166, 0.28);
}
#pioh-luna-toggle:focus-visible {
	outline: 2px solid var(--luna-accent);
	outline-offset: 3px;
}

.pioh-luna-icon {
	width: calc(var(--luna-btn-size) * 0.56);
	height: auto;
	color: var(--luna-accent);
	display: block;
	filter: drop-shadow(0 2px 4px rgba(124, 77, 166, 0.22));
	animation: pioh-luna-breathe 4.2s ease-in-out infinite;
}

/* A slow, calm pulse — deliberately gentler than a flicker. */
@keyframes pioh-luna-breathe {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.07); }
}

@media (prefers-reduced-motion: reduce) {
	.pioh-luna-heart { animation: none; }
}

#pioh-luna-panel {
	position: absolute;
	bottom: calc(var(--luna-btn-size) + 14px);
	right: 0;
	width: var(--luna-panel-w);
	max-width: calc(100vw - 48px);
	height: var(--luna-panel-h);
	max-height: calc(100vh - 140px);
	background: var(--white, #fff);
	border-radius: 20px;
	box-shadow: 0 20px 50px rgba(43, 39, 51, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--line, #E7DCEF);
}
#pioh-luna-panel[hidden] { display: none; }

.pioh-luna-header {
	background: linear-gradient(135deg, var(--luna-accent-pale) 0%, var(--luna-accent) 190%);
	color: #4A3A55;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.pioh-luna-header strong { font-family: 'Lora', serif; font-size: 1rem; display: block; color: #3E3049; }
.pioh-luna-header span   { font-size: 0.72rem; opacity: 0.8; }
.pioh-luna-header-actions { display: flex; align-items: center; gap: 6px; }
.pioh-luna-header button {
	background: none;
	border: none;
	color: #4A3A55;
	font-size: 1rem;
	cursor: pointer;
	opacity: 0.75;
}
.pioh-luna-header button:hover { opacity: 1; }

#pioh-luna-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--cream, #FBF8FC);
}

.pioh-luna-bubble {
	max-width: 84%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 0.88rem;
	line-height: 1.45;
	white-space: pre-line;
}
.pioh-luna-assistant {
	background: var(--luna-accent-pale);
	color: var(--ink, #2B2733);
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}
.pioh-luna-user {
	background: var(--luna-accent);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}
.pioh-luna-crisis {
	background: #FFF4E5;
	border: 1px solid #E4A94F;
	max-width: 100%;
}
/* Animated typing indicator */
.pioh-luna-thinking {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 13px 16px;
	width: fit-content;
}
.pioh-luna-thinking span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--luna-accent);
	opacity: 0.35;
	animation: pioh-luna-typing 1.3s ease-in-out infinite;
}
.pioh-luna-thinking span:nth-child(2) { animation-delay: 0.18s; }
.pioh-luna-thinking span:nth-child(3) { animation-delay: 0.36s; }

@keyframes pioh-luna-typing {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30%           { opacity: 0.9; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
	.pioh-luna-thinking span { animation: none; opacity: 0.5; }
}

.pioh-luna-crisis-note {
	font-size: 0.7rem;
	color: var(--ink-soft, #6B6478);
	padding: 8px 16px;
	border-top: 1px dashed var(--line, #E7DCEF);
	background: var(--white, #fff);
}

#pioh-luna-form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--line, #E7DCEF);
	background: var(--white, #fff);
}
#pioh-luna-input {
	flex: 1;
	border: 1px solid var(--line, #E7DCEF);
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 0.85rem;
	font-family: inherit;
}
#pioh-luna-input:focus { outline: 2px solid var(--luna-accent); outline-offset: 1px; }
#pioh-luna-form button {
	background: var(--luna-accent);
	color: #fff;
	border: none;
	border-radius: 20px;
	padding: 9px 16px;
	font-size: 0.82rem;
	font-weight: 700;
	cursor: pointer;
}
#pioh-luna-form button:hover { background: var(--luna-accent-dark); }

@media (max-width: 480px) {
	#pioh-luna-panel { width: calc(100vw - 24px); right: -12px; height: 70vh; }
}


/* Custom uploaded icon */
.pioh-luna-icon-custom {
	width: calc(var(--luna-btn-size) * 0.62);
	height: calc(var(--luna-btn-size) * 0.62);
	object-fit: contain;
	border-radius: 50%;
}

/* Panel fills the screen width on phones regardless of the width setting. */
@media (max-width: 480px) {
	#pioh-luna-panel {
		width: calc(100vw - 24px);
		right: -12px;
		left: auto;
		height: min(70vh, var(--luna-panel-h));
	}
	#pioh-luna-root[style*="left"] #pioh-luna-panel,
	.pioh-luna-left #pioh-luna-panel { left: -12px; right: auto; }
}
