#psa-root {
	--psa-accent: #1f4e79;
	--psa-bg: #ffffff;
	--psa-text: #1d2327;
	--psa-muted: #646970;
	--psa-bot-bg: #f1f3f5;
	--psa-border: #dcdcde;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--psa-text);
}
#psa-root.psa-pos-right { right: 20px; }
#psa-root.psa-pos-left  { left: 20px; }
#psa-root *, #psa-root *::before, #psa-root *::after { box-sizing: border-box; }

.psa-launcher {
	display: flex; align-items: center; gap: 8px;
	margin-left: auto;
	padding: 12px 18px 12px 14px;
	border: 0; border-radius: 999px;
	background: var(--psa-accent); color: #fff;
	font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0,0,0,.22);
	transition: transform .15s ease;
}
.psa-pos-left .psa-launcher { margin-left: 0; margin-right: auto; }
.psa-launcher:hover { transform: translateY(-2px); }
.psa-launcher:focus-visible, #psa-root button:focus-visible, .psa-input:focus-visible { outline: 3px solid #f0b400; outline-offset: 2px; }
.psa-open .psa-launcher-label { display: none; }
.psa-open .psa-launcher { padding: 12px; }

.psa-panel {
	display: flex; flex-direction: column;
	width: 420px; max-width: calc(100vw - 32px);
	height: 620px; max-height: calc(100vh - 110px);
	margin-bottom: 12px;
	background: var(--psa-bg);
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(0,0,0,.25);
	overflow: hidden;
}
.psa-panel[hidden] { display: none; }

.psa-head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 12px 12px 12px 16px;
	background: var(--psa-accent); color: #fff;
}
.psa-title { display: flex; flex-direction: column; }
.psa-title strong { font-size: 16px; }
.psa-sub { font-size: 12px; opacity: .85; }
.psa-actions { display: flex; gap: 4px; }
.psa-icon-btn {
	width: 34px; height: 34px; border: 0; border-radius: 8px;
	background: rgba(255,255,255,.15); color: #fff;
	font-size: 20px; line-height: 1; cursor: pointer;
}
.psa-icon-btn:hover { background: rgba(255,255,255,.28); }

.psa-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.psa-msg { display: flex; flex-direction: column; max-width: 92%; }
.psa-bot { align-self: flex-start; }
.psa-user { align-self: flex-end; }
.psa-bubble { padding: 9px 13px; border-radius: 14px; word-wrap: break-word; }
.psa-bot .psa-bubble { background: var(--psa-bot-bg); border-bottom-left-radius: 4px; padding: 12px 15px; line-height: 1.5; }
.psa-user .psa-bubble { background: var(--psa-accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.psa-error .psa-bubble { background: #fcf0f1; color: #8a2424; }
.psa-bubble p { margin: 0 0 12px; }
.psa-bubble p:last-child { margin-bottom: 0; }
.psa-bubble ul { margin: 4px 0 6px 18px; padding: 0; }
.psa-bubble li { margin: 2px 0; }
.psa-cite { font-size: 10px; font-weight: 700; color: var(--psa-accent); margin-left: 1px; }

.psa-sources { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 5px 4px 0; font-size: 12.5px; }
.psa-sources-label { color: var(--psa-muted); }
.psa-sources a { color: var(--psa-accent); text-decoration: underline; }

.psa-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.psa-chip {
	padding: 7px 11px; border: 1px solid var(--psa-accent); border-radius: 999px;
	background: #fff; color: var(--psa-accent);
	font-family: inherit; font-weight: 500; font-size: 13px; line-height: 1.25; text-align: left; cursor: pointer;
}
.psa-chip:hover { background: var(--psa-accent); color: #fff; }

.psa-typing .psa-bubble { display: flex; gap: 4px; padding: 13px 14px; }
.psa-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--psa-muted); animation: psa-dot 1.2s infinite ease-in-out; }
.psa-typing span:nth-child(2) { animation-delay: .15s; }
.psa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes psa-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.psa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.psa-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--psa-border); }
/* #psa-root + !important: site themes often restyle every textarea/button */
#psa-root .psa-input {
	flex: 1; resize: none; box-sizing: border-box;
	height: 44px !important; min-height: 44px !important; max-height: 120px !important;
	margin: 0 !important; padding: 10px 14px !important; line-height: 1.4 !important;
	border: 1px solid var(--psa-border) !important; border-radius: 22px !important; box-shadow: none !important;
	font: inherit; font-size: 15px; color: var(--psa-text); background: #fff;
}
#psa-root .psa-send {
	flex: none; width: 44px !important; height: 44px !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important;
	display: flex; align-items: center; justify-content: center;
	border: 0 !important; border-radius: 50% !important;
	background: var(--psa-accent) !important; color: #fff !important; cursor: pointer; box-shadow: none !important;
}
#psa-root .psa-send svg { width: 20px; height: 20px; display: block; }
.psa-send:disabled { opacity: .55; cursor: default; }
.psa-disclaimer { padding: 2px 14px 10px; font-size: 11.5px; line-height: 1.4; color: var(--psa-muted); }
.psa-disc-body { display: none; max-height: 34vh; overflow-y: auto; }
.psa-disc-open .psa-disc-body { display: block; }
.psa-disc-body p { margin: 0 0 6px; }
.psa-disc-body a { color: inherit; text-decoration: underline; }
.psa-disc-toggle { display: block; background: none; border: 0; padding: 4px 0; margin: 0; font: inherit; font-size: 11.5px; color: var(--psa-muted); text-decoration: underline; cursor: pointer; text-align: left; }
.psa-disc-open .psa-disc-toggle { font-weight: 600; text-decoration: none; }

@media (max-width: 480px) {
	#psa-root { bottom: 12px; }
	#psa-root.psa-pos-right { right: 12px; }
	#psa-root.psa-pos-left { left: 12px; }
	.psa-open .psa-panel {
		position: fixed; inset: 0; width: 100vw; max-width: none; height: 100%; max-height: none;
		margin: 0; border-radius: 0;
	}
	.psa-open .psa-launcher { display: none; }
	.psa-input { font-size: 16px; } /* prevents iOS zoom */
}
@media (prefers-reduced-motion: reduce) {
	.psa-launcher, .psa-typing span { transition: none; animation: none; }
}
