/* Smart Glossary — glossary assistant robot («مساعد المصطلحات الذكي»): floating robot with an open glossary book on its head, welcome card and chat window.
   Same look, motion and placement rules as the site assistant (DL Bot) and the other plugin assistants, under its own prefix (sgb). */
.sgb {
	--sgb-primary: #1769FF;
	--sgb-cyan: #36D9FF;
	--sgb-purple: #8057FF;
	--sgb-white: #F7FAFF;
	--sgb-face: #101827;
	--sgb-size-d: 100px;
	--sgb-size-m: 72px;
	--sgb-size: var(--sgb-size-d);
	--sgb-offset: 88px;
	--sgb-side: 18px;
	--sgb-ink: #14213D;
	--sgb-muted: #5B6B86;
	--sgb-glass: rgba(255, 255, 255, .80);
	--sgb-glass-2: rgba(247, 250, 255, .92);
	--sgb-line: rgba(23, 105, 255, .14);
	--sgb-bot-bg: #fff;
	--sgb-shadow: 0 18px 48px rgba(16, 24, 39, .18), 0 2px 8px rgba(16, 24, 39, .08);
	--sgb-font: inherit;
	--sgb-radius: 26px;
	--sgb-grad-head: linear-gradient(120deg, var(--sgb-primary) 0%, color-mix(in srgb, var(--sgb-primary) 55%, var(--sgb-purple)) 60%, var(--sgb-purple) 100%);
	--sgb-grad-btn: linear-gradient(135deg, var(--sgb-primary), var(--sgb-purple));
	/* robot colours (inline SVG) */
	--sgb-r-cyan: #36D9FF; --sgb-r-blue: #1769FF; --sgb-r-purple: #8057FF; --sgb-r-face: #101827; --sgb-r-face2: #080D18;
	--sgb-r-screen: #1C2A47; --sgb-r-hi: #9AF0FF; --sgb-r-deep: #0F4FD6; --sgb-r-tip: #E9FBFF;
	font-family: var(--sgb-font, inherit);
	direction: rtl;
	color: var(--sgb-ink);
}
html[data-theme="dark"] .sgb,
.sgb.sgb--dark {
	--sgb-ink: #E8EEFA;
	--sgb-muted: #A3B2CC;
	--sgb-glass: rgba(16, 24, 39, .82);
	--sgb-glass-2: rgba(22, 32, 52, .92);
	--sgb-line: rgba(54, 217, 255, .18);
	--sgb-bot-bg: rgba(30, 42, 66, .95);
	--sgb-shadow: 0 18px 48px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
}
/* «مطابق لثيم الموقع»: every colour comes from the dlarabic theme tokens (green / violet / dark palettes). */
.sgb.sgb--site {
	--sgb-primary: var(--teal, #1F7A56);
	--sgb-cyan: var(--mint, #41C48D);
	--sgb-purple: var(--grad-c, #1F7A56);
	--sgb-face: var(--navy, #0B1914);
	--sgb-ink: var(--ink, #111C18);
	--sgb-muted: var(--muted, #6E8279);
	--sgb-line: var(--line, #DCE5E0);
	--sgb-bot-bg: var(--card, #fff);
	--sgb-glass: color-mix(in srgb, var(--bg, #EAF0ED) 82%, transparent);
	--sgb-glass-2: color-mix(in srgb, var(--card, #fff) 92%, transparent);
	--sgb-shadow: 0 18px 48px rgba(var(--shade-rgb, 11, 25, 20), .22), 0 2px 8px rgba(var(--shade-rgb, 11, 25, 20), .08);
	--sgb-font: var(--font, inherit);
	--sgb-radius: 22px;
	--sgb-grad-head: var(--grad-135, linear-gradient(135deg, #0B1914, #15362A 45%, #1F7A56));
	--sgb-grad-btn: var(--grad-btn, linear-gradient(90deg, #15362A, #1F7A56));
	--sgb-r-cyan: var(--mint-l, #6EE7B7); --sgb-r-blue: var(--teal, #1F7A56); --sgb-r-purple: var(--mint, #41C48D);
	--sgb-r-face: var(--navy, #0B1914); --sgb-r-face2: var(--grad-a, #06100C); --sgb-r-screen: var(--navy-2, #15362A);
	--sgb-r-hi: color-mix(in srgb, var(--mint-l, #6EE7B7) 45%, #fff); --sgb-r-deep: var(--grad-b, #15362A); --sgb-r-tip: #fff;
}
html[data-theme="dark"] .sgb.sgb--site {
	--sgb-ink: var(--ink, #EEEDF7); --sgb-muted: var(--muted, #908CB0); --sgb-line: var(--line, #2E2A52); --sgb-bot-bg: var(--card, #1A1734);
	--sgb-glass: color-mix(in srgb, var(--bg, #0F0D22) 86%, transparent); --sgb-glass-2: color-mix(in srgb, var(--card, #1A1734) 94%, transparent);
}
html[data-theme="dark"] .sgb.sgb--site .sgb-msg a, html[data-theme="dark"] .sgb.sgb--site .sgb-chip { color: var(--mint-l, #B7CEFF); }
.sgb--site .sgb-welcome-title { color: var(--teal); }
.sgb *, .sgb *::before, .sgb *::after { box-sizing: border-box; }
.sgb [hidden] { display: none !important; }

/* ---------------- Floating robot button ---------------- */
.sgb-fab {
	position: fixed; z-index: 70; bottom: calc(var(--sgb-offset) + env(safe-area-inset-bottom, 0px));
	right: var(--sgb-side); left: auto;
	width: var(--sgb-size); height: var(--sgb-size); padding: 0; margin: 0;
	border: 0; background: none; cursor: pointer; border-radius: 50%;
	-webkit-tap-highlight-color: transparent; font: inherit; color: inherit;
}
.sgb--left .sgb-fab { right: auto; left: var(--sgb-side); }
.sgb-fab-glass {
	position: absolute; inset: 8% 8% 0; border-radius: 50%;
	background:
		radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .35) 45%, rgba(255, 255, 255, .12) 70%),
		linear-gradient(160deg, color-mix(in srgb, var(--sgb-cyan) 22%, transparent), color-mix(in srgb, var(--sgb-primary) 30%, transparent));
	border: 1.5px solid rgba(255, 255, 255, .75);
	-webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);
	box-shadow: 0 12px 30px color-mix(in srgb, var(--sgb-primary) 35%, transparent), 0 0 0 6px color-mix(in srgb, var(--sgb-primary) 10%, transparent), inset 0 -8px 18px color-mix(in srgb, var(--sgb-primary) 18%, transparent);
	transition: box-shadow .3s ease, transform .3s ease;
}
html[data-theme="dark"] .sgb-fab-glass, .sgb--dark .sgb-fab-glass {
	background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .28), rgba(255, 255, 255, .06) 55%), linear-gradient(160deg, rgba(54, 217, 255, .22), rgba(23, 105, 255, .35));
	border-color: rgba(255, 255, 255, .22);
}
.sgb-fab-robot {
	position: absolute; left: -6%; right: -6%; bottom: 2%; height: 112%;
	display: block; pointer-events: none;
	filter: drop-shadow(0 6px 10px rgba(16, 24, 39, .18));
}
.sgb-fab-robot > svg, .sgb-fab-robot > .sgb-lottie, .sgb-fab-robot > img { width: 100%; height: 100%; display: block; }
.sgb-fab:hover .sgb-fab-glass, .sgb-fab:focus-visible .sgb-fab-glass {
	box-shadow: 0 16px 36px color-mix(in srgb, var(--sgb-primary) 45%, transparent), 0 0 0 8px color-mix(in srgb, var(--sgb-cyan) 18%, transparent), inset 0 -8px 18px color-mix(in srgb, var(--sgb-primary) 18%, transparent);
}
.sgb-fab:focus-visible { outline: 3px solid var(--sgb-cyan); outline-offset: 4px; }
.sgb-badge {
	position: absolute; top: 6%; right: 8%; width: 14px; height: 14px; border-radius: 50%;
	background: var(--sgb-purple); border: 2px solid #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sgb-purple) 25%, transparent);
}
.sgb--left .sgb-badge { right: auto; left: 8%; }

/* Hover label «المساعد الذكي» */
.sgb-tip {
	position: absolute; top: 50%; right: calc(100% + 10px); transform: translate(6px, -50%);
	white-space: nowrap; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; line-height: 1.2;
	background: var(--sgb-face); color: #fff; box-shadow: 0 6px 18px rgba(16, 24, 39, .25);
	opacity: 0; visibility: hidden; transition: opacity .2s ease, transform .2s ease, visibility .2s;
	pointer-events: none;
}
.sgb--left .sgb-tip { right: auto; left: calc(100% + 10px); transform: translate(-6px, -50%); }
.sgb-fab:hover .sgb-tip, .sgb-fab:focus-visible .sgb-tip { opacity: 1; visibility: visible; transform: translate(0, -50%); }
@media (hover: none) { .sgb-tip { display: none; } }

/* Desktop / mobile visibility (CSS only, so page caching is unaffected). */
@media (max-width: 760px) {
	.sgb { --sgb-size: var(--sgb-size-m); --sgb-side: 12px; }
	.sgb--no-mobile .sgb-fab, .sgb--no-mobile .sgb-welcome { display: none !important; }
}
@media (min-width: 761px) {
	.sgb--no-desktop .sgb-fab, .sgb--no-desktop .sgb-welcome { display: none !important; }
}
html.sgb-is-open .sgb-fab { transform: scale(.92); }
@media (max-width: 760px) { html.sgb-is-open .sgb-fab { opacity: 0; pointer-events: none; } }

/* ---------------- Welcome card ---------------- */
.sgb-welcome {
	position: fixed; z-index: 71;
	bottom: calc(var(--sgb-offset) + env(safe-area-inset-bottom, 0px) + var(--sgb-size) * .25);
	right: calc(var(--sgb-side) + var(--sgb-size) + 10px);
	width: min(320px, calc(100vw - var(--sgb-size) - var(--sgb-side) * 2 - 20px));
	padding: 14px 16px 14px 40px; border-radius: 20px 20px 6px 20px;
	background: var(--sgb-glass-2); color: var(--sgb-ink);
	border: 1px solid rgba(255, 255, 255, .7);
	-webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
	box-shadow: var(--sgb-shadow);
	font-size: 14px; line-height: 1.8;
	opacity: 0; transform: translateY(10px) scale(.96); transform-origin: bottom right;
	transition: opacity .35s ease, transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
.sgb--left .sgb-welcome { right: auto; left: calc(var(--sgb-side) + var(--sgb-size) + 10px); border-radius: 20px 20px 20px 6px; transform-origin: bottom left; padding: 14px 40px 14px 16px; }
.sgb-welcome.is-in { opacity: 1; transform: none; }
.sgb-welcome::before {
	content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: 20px 20px 0 0;
	background: linear-gradient(90deg, var(--sgb-cyan), var(--sgb-primary), var(--sgb-purple));
}
.sgb-welcome p { margin: 0; white-space: pre-line; }
.sgb-welcome-title { display: block; font-weight: 800; font-size: 15px; color: var(--sgb-primary); margin-bottom: 2px; }
html[data-theme="dark"] .sgb-welcome-title, .sgb--dark .sgb-welcome-title { color: var(--sgb-cyan); }
.sgb-welcome-open {
	margin-top: 10px; border: 0; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
	padding: 7px 14px; border-radius: 999px; color: #fff;
	background: var(--sgb-grad-btn);
	box-shadow: 0 6px 16px color-mix(in srgb, var(--sgb-primary) 35%, transparent);
}
.sgb-x {
	position: absolute; top: 10px; left: 10px; width: 26px; height: 26px; padding: 0;
	border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
	background: color-mix(in srgb, var(--sgb-primary) 10%, transparent); color: var(--sgb-muted);
}
.sgb--left .sgb-welcome .sgb-x { left: auto; right: 10px; }
.sgb-x svg { width: 14px; height: 14px; }
.sgb-x:hover { background: color-mix(in srgb, var(--sgb-primary) 18%, transparent); color: var(--sgb-ink); }
@media (max-width: 760px) {
	.sgb-welcome, .sgb--left .sgb-welcome {
		right: var(--sgb-side); left: auto; width: min(320px, calc(100vw - 24px));
		bottom: calc(var(--sgb-offset) + env(safe-area-inset-bottom, 0px) + var(--sgb-size) + 12px);
		border-radius: 20px 20px 6px 20px; font-size: 13.5px;
	}
	.sgb--left .sgb-welcome { right: auto; left: var(--sgb-side); border-radius: 20px 20px 20px 6px; }
}

/* ---------------- Chat window ---------------- */
.sgb-window {
	position: fixed; z-index: 560;
	right: var(--sgb-side); left: auto;
	bottom: calc(var(--sgb-offset) + env(safe-area-inset-bottom, 0px) + var(--sgb-size) + 12px);
	width: 390px; height: min(600px, calc(100vh - var(--sgb-offset) - var(--sgb-size) - 96px));
	height: min(600px, calc(100dvh - var(--sgb-offset) - var(--sgb-size) - 96px));
	min-height: 320px;
	display: flex; flex-direction: column; overflow: hidden;
	border-radius: var(--sgb-radius); color: var(--sgb-ink);
	background: var(--sgb-glass);
	border: 1px solid rgba(255, 255, 255, .65);
	-webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
	box-shadow: var(--sgb-shadow);
	opacity: 0; transform: translateY(16px) scale(.97); transform-origin: bottom right;
	transition: opacity .25s ease, transform .3s cubic-bezier(.2, .9, .3, 1), height .3s ease;
}
html[data-theme="dark"] .sgb-window, .sgb--dark .sgb-window { border-color: rgba(255, 255, 255, .12); }
.sgb--left .sgb-window { right: auto; left: var(--sgb-side); transform-origin: bottom left; }
.sgb-window.is-in { opacity: 1; transform: none; }
.sgb-window::before {
	content: ""; position: absolute; inset: -40% -30% auto auto; width: 280px; height: 280px; border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--sgb-cyan) 22%, transparent), transparent 70%);
	pointer-events: none;
}
.sgb-window::after {
	content: ""; position: absolute; inset: auto auto -30% -25%; width: 260px; height: 260px; border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--sgb-purple) 16%, transparent), transparent 70%);
	pointer-events: none;
}

.sgb-head {
	position: relative; z-index: 1; display: flex; align-items: center; gap: 10px;
	padding: 12px 14px; color: #fff;
	background: var(--sgb-grad-head);
	box-shadow: 0 6px 18px color-mix(in srgb, var(--sgb-primary) 25%, transparent);
}
.sgb-avatar {
	width: 46px; height: 46px; flex: none; border-radius: 16px; position: relative;
	background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .35);
	display: grid; place-items: center; overflow: visible;
}
.sgb-avatar .sgb-robot { width: 54px; height: 54px; margin-top: -6px; }
.sgb-head-txt { flex: 1; min-width: 0; line-height: 1.3; }
.sgb-head-txt h2 { margin: 0; font-size: 16.5px; font-weight: 800; color: #fff; letter-spacing: .2px; font-family: inherit; direction: ltr; text-align: right; }
.sgb-head-txt small { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; margin-top: 2px; }
.sgb-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #FFC24B; box-shadow: 0 0 0 3px rgba(255, 255, 255, .2); flex: none; }
.sgb[data-conn="on"] .sgb-status-dot { background: #3BE39B; animation: sgbPing 2.4s ease-out infinite; }
.sgb[data-conn="off"] .sgb-status-dot { background: #FF7A85; }
@keyframes sgbPing { 0% { box-shadow: 0 0 0 0 rgba(59, 227, 155, .6); } 80%, 100% { box-shadow: 0 0 0 7px rgba(59, 227, 155, 0); } }
.sgb-ibtn {
	width: 34px; height: 34px; padding: 0; border: 0; border-radius: 11px; cursor: pointer; flex: none;
	background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center;
	transition: background .2s ease;
}
.sgb-ibtn svg { width: 17px; height: 17px; }
.sgb-ibtn:hover { background: rgba(255, 255, 255, .26); }
.sgb-ibtn:focus-visible, .sgb-send:focus-visible, .sgb-chip:focus-visible, .sgb-welcome-open:focus-visible, .sgb-x:focus-visible { outline: 3px solid var(--sgb-cyan); outline-offset: 2px; }

.sgb-log {
	position: relative; z-index: 1; flex: 1; overflow-y: auto; overscroll-behavior: contain;
	padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px;
	scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--sgb-primary) 30%, transparent) transparent;
}
.sgb-msg {
	max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.85;
	overflow-wrap: anywhere; animation: sgbIn .3s ease both;
}
@keyframes sgbIn { from { opacity: 0; transform: translateY(6px); } }
.sgb-msg--bot { align-self: flex-start; background: var(--sgb-bot-bg); border: 1px solid var(--sgb-line); border-top-right-radius: 6px; box-shadow: 0 2px 10px rgba(16, 24, 39, .05); }
.sgb-msg--user { align-self: flex-end; color: #fff; border-top-left-radius: 6px; background: var(--sgb-grad-btn); box-shadow: 0 6px 16px color-mix(in srgb, var(--sgb-primary) 25%, transparent); }
.sgb-msg--err { border-color: rgba(255, 122, 133, .45); background: color-mix(in srgb, #FF7A85 8%, var(--sgb-bot-bg)); }
.sgb-msg p, .sgb-msg li, .sgb-chip, .sgb-welcome p { unicode-bidi: plaintext; }
.sgb-msg p { margin: 0 0 6px; }
.sgb-msg p:last-child { margin-bottom: 0; }
.sgb-msg h3, .sgb-msg h4 { margin: 6px 0 4px; font-size: 15px; font-weight: 800; color: inherit; }
.sgb-msg ul, .sgb-msg ol { margin: 4px 0 6px; padding-inline-start: 22px; }
.sgb-msg li { margin: 2px 0; }
.sgb-msg a { color: var(--sgb-primary); text-decoration: underline; text-underline-offset: 3px; }
html[data-theme="dark"] .sgb-msg a, .sgb--dark .sgb-msg a { color: var(--sgb-cyan); }
.sgb-msg code { direction: ltr; unicode-bidi: isolate; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: color-mix(in srgb, var(--sgb-primary) 9%, transparent); padding: 1px 6px; border-radius: 6px; }
.sgb-msg pre { direction: ltr; text-align: left; margin: 6px 0; padding: 10px 12px; border-radius: 12px; overflow-x: auto; background: var(--sgb-face); color: #DDE8FF; }
.sgb-msg pre code { background: none; padding: 0; color: inherit; }
.sgb-msg blockquote { margin: 6px 0; padding: 4px 12px; border-inline-start: 3px solid var(--sgb-cyan); color: var(--sgb-muted); }
.sgb-msg .sgb-cite {
	display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 2px;
	border-radius: 6px; font-size: 11px; font-weight: 800; line-height: 1; text-decoration: none; vertical-align: 2px;
	background: color-mix(in srgb, var(--sgb-primary) 12%, transparent); color: var(--sgb-primary);
}
.sgb-sources { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--sgb-line); display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.sgb-sources > span { color: var(--sgb-muted); font-weight: 700; }
.sgb-sources a { display: flex; gap: 8px; align-items: baseline; text-decoration: none; color: var(--sgb-ink); line-height: 1.5; }
.sgb-sources a b { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; font-size: 11px; color: #fff; background: var(--sgb-primary); }
.sgb-sources a small { color: var(--sgb-muted); margin-inline-start: auto; flex: none; }
.sgb-sources a:hover { color: var(--sgb-primary); }
.sgb-fallback { display: inline-block; margin-top: 8px; font-weight: 700; }

.sgb-typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.sgb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sgb-primary); opacity: .35; animation: sgbDot 1.2s infinite ease-in-out; }
.sgb-typing i:nth-child(2) { animation-delay: .15s; background: color-mix(in srgb, var(--sgb-primary) 50%, var(--sgb-purple)); }
.sgb-typing i:nth-child(3) { animation-delay: .3s; background: var(--sgb-purple); }
@keyframes sgbDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.sgb-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.sgb-chip {
	border: 1px solid color-mix(in srgb, var(--sgb-primary) 28%, transparent); cursor: pointer; font: inherit; font-size: 13px; line-height: 1.5;
	padding: 6px 12px; border-radius: 999px; color: var(--sgb-primary); text-align: right;
	background: color-mix(in srgb, var(--sgb-primary) 7%, var(--sgb-bot-bg));
	transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}
html[data-theme="dark"] .sgb-chip, .sgb--dark .sgb-chip { color: var(--sgb-cyan); border-color: rgba(54, 217, 255, .3); }
.sgb-chip:hover { background: color-mix(in srgb, var(--sgb-primary) 15%, var(--sgb-bot-bg)); transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--sgb-primary) 18%, transparent); }

.sgb-form {
	position: relative; z-index: 1; display: flex; align-items: flex-end; gap: 8px;
	margin: 6px 12px 0; padding: 6px 6px 6px 8px; border-radius: 20px;
	background: var(--sgb-bot-bg); border: 1px solid var(--sgb-line);
	box-shadow: 0 4px 14px rgba(16, 24, 39, .06);
}
.sgb-form:focus-within { border-color: color-mix(in srgb, var(--sgb-primary) 55%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sgb-primary) 12%, transparent); }
.sgb-input {
	flex: 1; min-height: 40px; max-height: 130px; resize: none; border: 0; outline: 0; background: transparent;
	font: inherit; font-size: 14.5px; line-height: 1.7; color: var(--sgb-ink); padding: 7px 8px; direction: rtl; text-align: right;
}
.sgb-input::placeholder { color: var(--sgb-muted); opacity: .85; }
.sgb-send {
	width: 40px; height: 40px; flex: none; border: 0; border-radius: 14px; cursor: pointer; color: #fff; display: grid; place-items: center;
	background: var(--sgb-grad-btn);
	box-shadow: 0 6px 14px color-mix(in srgb, var(--sgb-primary) 35%, transparent);
	transition: transform .2s ease, opacity .2s ease;
}
.sgb-send svg { width: 18px; height: 18px; }
.sgb-send:hover { transform: translateY(-1px); }
.sgb-send:disabled { opacity: .5; cursor: progress; transform: none; }
.sgb-note { position: relative; z-index: 1; margin: 6px 14px 10px; font-size: 11.5px; color: var(--sgb-muted); text-align: center; line-height: 1.5; }
.sgb-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Minimised: header only */
.sgb-window.is-min { height: 70px; min-height: 0; }
.sgb-window.is-min .sgb-log, .sgb-window.is-min .sgb-form, .sgb-window.is-min .sgb-note { display: none; }
.sgb-window.is-min .sgb-ibtn--min svg { transform: rotate(180deg); }

@media (max-width: 760px) {
	.sgb-window, .sgb--left .sgb-window {
		left: 8px; right: 8px; width: auto;
		bottom: calc(8px + env(safe-area-inset-bottom, 0px));
		height: min(640px, calc(100vh - 80px)); height: min(640px, calc(100dvh - 80px));
		border-radius: 24px; transform-origin: bottom center;
	}
	.sgb-window.is-min { height: 70px; }
	.sgb-msg { font-size: 14px; max-width: 92%; }
	.sgb-input { font-size: 16px; } /* no iOS zoom */
}

/* ---------------- Robot rig (SVG + CSS engine) ---------------- */
.sgb-robot { overflow: visible; }
.sgb-robot .sgb-rig, .sgb-robot .sgb-body, .sgb-robot .sgb-head, .sgb-robot .sgb-eyes, .sgb-robot .sgb-arm,
.sgb-robot .sgb-shadow, .sgb-robot .sgb-ant-glow, .sgb-robot .sgb-chest-glow, .sgb-robot .sgb-star, .sgb-robot .sgb-dot, .sgb-robot .sgb-z {
	transform-box: fill-box;
}
.sgb-robot .sgb-body, .sgb-robot .sgb-head { transform-origin: 50% 100%; }
.sgb-robot .sgb-eyes, .sgb-robot .sgb-shadow, .sgb-robot .sgb-ant-glow, .sgb-robot .sgb-chest-glow, .sgb-robot .sgb-star, .sgb-robot .sgb-dot, .sgb-robot .sgb-z { transform-origin: 50% 50%; }
.sgb-robot .sgb-arm { transform-origin: 50% 0; }
.sgb-robot .sgb-eyes { transition: transform .35s ease; }
.sgb-robot .sgb-mouth { opacity: 0; transition: opacity .3s ease; }
.sgb-robot .sgb-mouth-smile { opacity: 1; }
.sgb-robot .sgb-fx { opacity: 0; transition: opacity .35s ease; }
.sgb-robot .sgb-ant-glow, .sgb-robot .sgb-chest-glow { transition: opacity .4s ease; }

/* Floating */
.sgb-anim .sgb-fab-robot { animation: sgbFloat 6s ease-in-out infinite; }
@keyframes sgbFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.sgb-anim .sgb-fab-glass { animation: sgbGlow 6s ease-in-out infinite; }
@keyframes sgbGlow { 0%, 100% { filter: none; } 50% { filter: brightness(1.05) drop-shadow(0 0 10px color-mix(in srgb, var(--sgb-cyan) 45%, transparent)); } }

/* IDLE */
.sgb-anim [data-state="idle"] .sgb-body { animation: sgbBreath 4s ease-in-out infinite; }
.sgb-anim [data-state="idle"] .sgb-head { animation: sgbHeadIdle 4s ease-in-out infinite; }
.sgb-anim [data-state="idle"] .sgb-eyes { animation: sgbBlink 4s ease-in-out infinite; }
.sgb-anim [data-state="idle"] .sgb-arm-l { animation: sgbSwayL 4s ease-in-out infinite; }
.sgb-anim [data-state="idle"] .sgb-arm-r { animation: sgbSwayR 4s ease-in-out infinite; }
.sgb-anim [data-state="idle"] .sgb-ant-glow, .sgb-anim [data-state="idle"] .sgb-chest-glow { animation: sgbPulse 4s ease-in-out infinite; }
@keyframes sgbBreath { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, 1.022); } }
@keyframes sgbHeadIdle { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-1.2px) rotate(2deg); } 50% { transform: translateY(-2.5px) rotate(0); } 75% { transform: translateY(-1.2px) rotate(-2deg); } }
@keyframes sgbBlink { 0%, 69%, 77%, 100% { transform: scaleY(1); } 73% { transform: scaleY(.1); } }
@keyframes sgbSwayL { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(4deg); } }
@keyframes sgbSwayR { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
@keyframes sgbPulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

/* WELCOME (3s, once) */
[data-state="welcome"] .sgb-mouth-smile, [data-state="success"] .sgb-mouth-smile { opacity: 0; }
[data-state="welcome"] .sgb-mouth-big, [data-state="success"] .sgb-mouth-big { opacity: 1; }
[data-state="welcome"] .sgb-eyes { transform: scaleY(.72); }
[data-state="welcome"] .sgb-head { transform: rotate(-6deg); transition: transform .4s ease; }
.sgb-anim [data-state="welcome"] .sgb-arm-l { animation: sgbWave 3s ease-in-out both; }
.sgb-anim [data-state="welcome"] .sgb-head { animation: sgbHeadWelcome 3s ease-in-out both; }
.sgb-anim [data-state="welcome"] .sgb-ant-glow, .sgb-anim [data-state="welcome"] .sgb-chest-glow { opacity: 1; }
@keyframes sgbWave {
	0% { transform: rotate(0); } 13% { transform: rotate(140deg); } 27% { transform: rotate(112deg); } 40% { transform: rotate(140deg); }
	53% { transform: rotate(112deg); } 67% { transform: rotate(140deg); } 80% { transform: rotate(120deg); } 100% { transform: rotate(0); }
}
@keyframes sgbHeadWelcome { 0%, 100% { transform: rotate(0); } 15%, 80% { transform: rotate(-6deg); } }

/* THINKING (loop) */
[data-state="thinking"] .sgb-mouth-smile { opacity: 0; }
[data-state="thinking"] .sgb-mouth-flat { opacity: 1; }
[data-state="thinking"] .sgb-fx-think { opacity: 1; }
[data-state="thinking"] .sgb-ant-glow, [data-state="thinking"] .sgb-chest-glow { opacity: 1; }
[data-state="thinking"] .sgb-arm-r { transform: rotate(-126deg); transition: transform .5s cubic-bezier(.3, .9, .3, 1); }
.sgb-anim [data-state="thinking"] .sgb-eyes { animation: sgbScan 2s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-head { animation: sgbHeadThink 2s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-ant-glow { animation: sgbAntThink 1s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-chest-glow { animation: sgbPulse 1s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-dot { animation: sgbDotPop 1.2s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-dot-1 { animation-delay: .2s; }
.sgb-anim [data-state="thinking"] .sgb-dot-2 { animation-delay: .4s; }
@keyframes sgbScan { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-5px, -2px); } 50% { transform: translate(5px, -2px); } 80% { transform: translate(-5px, -2px); } }
@keyframes sgbHeadThink { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(5deg); } }
@keyframes sgbAntThink { 0%, 100% { transform: scale(1); opacity: .6; } 50% { transform: scale(1.4); opacity: 1; } }
@keyframes sgbDotPop { 0%, 100% { transform: scale(.8); opacity: .3; } 40% { transform: scale(1.25); opacity: 1; } }

/* SUCCESS (2s, once) */
[data-state="success"] .sgb-eyes { transform: scale(1.1, .55); }
[data-state="success"] .sgb-fx-star { opacity: 1; }
.sgb-anim [data-state="success"] .sgb-rig { animation: sgbHop 2s ease-in-out both; }
.sgb-anim [data-state="success"] .sgb-shadow { animation: sgbShadow 2s ease-in-out both; }
.sgb-anim [data-state="success"] .sgb-arm-l { animation: sgbCheerL 2s ease-in-out both; }
.sgb-anim [data-state="success"] .sgb-arm-r { animation: sgbCheerR 2s ease-in-out both; }
.sgb-anim [data-state="success"] .sgb-star { animation: sgbStar 1.4s ease-out both; }
.sgb-anim [data-state="success"] .sgb-star-1 { animation-delay: .15s; }
.sgb-anim [data-state="success"] .sgb-star-2 { animation-delay: .3s; }
.sgb-anim [data-state="success"] .sgb-star-3 { animation-delay: .45s; }
.sgb-anim [data-state="success"] .sgb-ant-glow { animation: sgbAntThink 1s ease-in-out 2; }
@keyframes sgbHop { 0%, 100% { transform: translateY(0); } 15% { transform: translateY(3px); } 35% { transform: translateY(-14px); } 55% { transform: translateY(0); } 65% { transform: translateY(2px); } 75% { transform: translateY(0); } }
@keyframes sgbShadow { 0%, 100% { transform: scale(1); } 35% { transform: scale(.72); } 55% { transform: scale(1); } }
@keyframes sgbCheerL { 0%, 100% { transform: rotate(0); } 25%, 75% { transform: rotate(140deg); } }
@keyframes sgbCheerR { 0%, 100% { transform: rotate(0); } 25%, 75% { transform: rotate(-140deg); } }
@keyframes sgbStar { 0% { transform: scale(.3) rotate(0); opacity: 0; } 30% { transform: scale(1.2) rotate(45deg); opacity: 1; } 100% { transform: scale(.7) rotate(90deg); opacity: 0; } }

/* SLEEP */
[data-state="sleep"] .sgb-mouth-smile { opacity: 0; }
[data-state="sleep"] .sgb-mouth-sleep { opacity: 1; }
[data-state="sleep"] .sgb-eyes { transform: scaleY(.12); }
[data-state="sleep"] .sgb-head { transform: translateY(2px) rotate(8deg); transition: transform .8s ease; }
[data-state="sleep"] .sgb-ant-glow, [data-state="sleep"] .sgb-chest-glow { opacity: .2; }
[data-state="sleep"] .sgb-fx-sleep { opacity: 1; }
.sgb-anim [data-state="sleep"] .sgb-head { animation: sgbHeadSleep 5s ease-in-out infinite; }
.sgb-anim [data-state="sleep"] .sgb-body { animation: sgbBreath 5s ease-in-out infinite; }
.sgb-anim [data-state="sleep"] .sgb-z { animation: sgbZ 4s ease-in-out infinite; }
.sgb-anim [data-state="sleep"] .sgb-z-1 { animation-delay: 1.6s; }
@keyframes sgbHeadSleep { 0%, 100% { transform: translateY(2px) rotate(7deg); } 50% { transform: translateY(4px) rotate(9deg); } }
@keyframes sgbZ { 0% { transform: translate(0, 6px) scale(.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(8px, -14px) scale(1.15); opacity: 0; } }

/* Reduced motion / animations off: poses only, no movement. */
.sgb-static *, .sgb-static *::before, .sgb-static *::after { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
	.sgb-rm *, .sgb-rm *::before, .sgb-rm *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* Robot effect colours (follow the palette) */
.sgb-robot .sgb-mouth { stroke: var(--sgb-r-cyan); }
.sgb-robot .sgb-star-0, .sgb-robot .sgb-star-2, .sgb-robot .sgb-dot-0 { fill: var(--sgb-r-cyan); }
.sgb-robot .sgb-star-1, .sgb-robot .sgb-star-3, .sgb-robot .sgb-dot-2 { fill: var(--sgb-r-purple); }
.sgb-robot .sgb-dot-1 { fill: var(--sgb-r-blue); }
.sgb-robot .sgb-z-0 { stroke: var(--sgb-r-blue); }
.sgb-robot .sgb-z-1 { stroke: var(--sgb-r-purple); }

/* ---------------- Drag & drop + window popping out of the robot's head (1.2) ---------------- */
.sgb--drag .sgb-fab { touch-action: none; cursor: grab; }
.sgb.sgb--dragging .sgb-fab { cursor: grabbing; transition: none; transform: scale(1.06); }
.sgb.sgb--dragging .sgb-fab-glass { box-shadow: 0 22px 46px rgba(16, 24, 39, .28); }
.sgb.sgb--dragging .sgb-tip { opacity: 0 !important; }
html.sgb-no-select, html.sgb-no-select * { -webkit-user-select: none !important; user-select: none !important; }
/* Free position chosen by the visitor (left/top of the robot in px). */
.sgb.sgb--free .sgb-fab { left: var(--sgb-fx); top: var(--sgb-fy); right: auto; bottom: auto; }
.sgb.sgb--free .sgb-welcome { left: var(--sgb-cl); right: auto; top: var(--sgb-ct); bottom: var(--sgb-cb); }

/* The chat window is placed by JS right above (or below) the robot's head and grows out of it. */
.sgb.sgb-placed .sgb-window { transform-origin: var(--sgb-wo, 50% 100%); transition: opacity .28s ease, transform .42s cubic-bezier(.2, 1.1, .3, 1), height .3s ease; }
.sgb.sgb-placed .sgb-window:not(.is-in) { transform: scale(.06); opacity: 0; }
/* Same on every screen size: anchored to the robot, sized to the room available. */
.sgb.sgb-placed .sgb-window { left: var(--sgb-wl); right: auto; top: var(--sgb-wt); bottom: var(--sgb-wb); width: var(--sgb-ww, 390px); height: var(--sgb-wh); min-height: 0; }
.sgb.sgb-placed .sgb-window.is-min { height: 70px; }
@media (max-width: 760px) {
	.sgb.sgb-placed .sgb-window { border-radius: 22px; }
	/* The robot stays visible while the window is open: the window comes out of its head. */
	html.sgb-is-open .sgb.sgb-placed .sgb-fab { opacity: 1; pointer-events: auto; }
}
.sgb-stem {
	position: fixed; z-index: 561; width: 18px; height: 18px; pointer-events: none;
	left: var(--sgb-sx); top: var(--sgb-sy);
	background: var(--sgb-glass-2); border: 1px solid rgba(255, 255, 255, .65);
	-webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
	transform: rotate(45deg) scale(0); opacity: 0;
	transition: opacity .2s ease .12s, transform .3s cubic-bezier(.2, 1.3, .3, 1) .12s;
}
.sgb-stem.is-up { border-top: 0; border-left: 0; }
.sgb-stem.is-down { border-bottom: 0; border-right: 0; }
html.sgb-is-open .sgb-stem.is-on { opacity: 1; transform: rotate(45deg) scale(1); }
.sgb-ibtn--pin[hidden] { display: none !important; }
.sgb-stem.is-down { background: var(--sgb-grad-head); border: 0; }

.sgb-head-txt small { overflow: hidden; }
.sgb-head-txt small > span { white-space: nowrap; }
/* Four header buttons (pin shown): tighten so the status text stays whole. */
.sgb.sgb--free .sgb-head { gap: 7px; }
.sgb.sgb--free .sgb-ibtn { width: 31px; height: 31px; border-radius: 10px; }

/* ---------------- Research assistant additions ---------------- */
.sgb { z-index: 70; }
/* Prompt bubble on the head: the cursor blinks, the bubble follows the head. */
.sgb-robot .sgb-cap, .sgb-robot .sgb-tassel { transform-box: fill-box; }
.sgb-robot .sgb-tassel { transform-origin: 0 0; }
.sgb-anim [data-state="idle"] .sgb-tassel { animation: sgbTassel 4s ease-in-out infinite; }
.sgb-anim [data-state="thinking"] .sgb-tassel { animation: sgbTassel 1s ease-in-out infinite; }
.sgb-anim [data-state="success"] .sgb-tassel { animation: sgbTassel .5s ease-in-out 4; }
.sgb-anim [data-state="welcome"] .sgb-tassel { animation: sgbTassel .75s ease-in-out 4; }
@keyframes sgbTassel { 0%, 45%, 100% { opacity: 1; } 55%, 90% { opacity: .15; } }
/* Header avatar: the bubble needs head room. */
.sgb-avatar .sgb-robot { width: 56px; height: 56px; margin-top: -10px; }
/* Context line under the header (tool page / navigator results). */
.sgb-ctx { position: relative; z-index: 1; padding: 6px 14px; font-size: 12.5px; font-weight: 700; line-height: 1.6; background: color-mix(in srgb, var(--sgb-primary) 10%, var(--sgb-bot-bg)); color: var(--sgb-primary); border-bottom: 1px solid var(--sgb-line); }
html[data-theme="dark"] .sgb-ctx { color: var(--sgb-cyan); }
.sgb-window.is-min .sgb-ctx { display: none; }
/* Tool pages linked under an answer, and the "chat not enabled" links. */
.sgb-links { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--sgb-line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.sgb-links > span { color: var(--sgb-muted); font-weight: 700; width: 100%; }
.sgb-msg .sgb-links a { text-decoration: none; padding: 2px 10px; border-radius: 999px; font-weight: 700; background: color-mix(in srgb, var(--sgb-primary) 10%, transparent); }
.sgb-msg a[dir="ltr"] { unicode-bidi: isolate; }
.sgb-input:disabled { cursor: not-allowed; }
.sgb-form:has(.sgb-input:disabled) { opacity: .7; }
.sgb-welcome-open { text-decoration: none; display: inline-block; }
.sgb .sgb-welcome-title { color: var(--teal, var(--sgb-primary)); }

/* Glossary pages: the glossary assistant is the only assistant (theme button, sheet, DL Bot and the other section assistants hidden). */
body.sg-solo-assistant .ai-fab, body.sg-solo-assistant .ai-backdrop, body.sg-solo-assistant #ai-sheet, body.sg-solo-assistant #dl-bot, body.sg-solo-assistant #dlrt-ai, body.sg-solo-assistant #dlap-ai, body.sg-solo-assistant #ap-ai, body.sg-solo-assistant #aipg-ai { display: none !important; }

/* Glossary book on the head (A | ع): the letters glow in turn; faster while the assistant thinks. */
.sgb-robot .sgb-glyph { transform-box: fill-box; transform-origin: 50% 50%; }
.sgb-anim .sgb-glyph { animation: sgbGlyph 4s ease-in-out infinite; }
.sgb-anim .sgb-glyph-ar { animation-delay: -2s; }
.sgb-anim [data-state="thinking"] .sgb-glyph { animation-duration: 1.2s; }
.sgb-anim [data-state="sleep"] .sgb-glyph { animation: none; opacity: .4; }
@keyframes sgbGlyph { 0%, 100% { opacity: .65; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.08); } }
.sgb-rm .sgb-glyph { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .sgb-rm .sgb-glyph { animation: none !important; } }
/* Term cards inside an answer. */
.sgb-msg .sgb-term-name { font-weight: 800; }
.sgb-msg .sgb-term-name [dir="ltr"] { unicode-bidi: isolate; }
.sgb-msg .sgb-meta { display: block; font-size: 12px; color: var(--sgb-muted); margin-top: 2px; }
.sgb-msg a.sgb-chip { text-decoration: none; display: inline-flex; align-items: center; }

/* Answers composed from the generator's guide and the project data (no AI). */
.sgb-msg .sgb-src { display: block; margin-top: 8px; font-size: 11.5px; color: var(--sgb-muted); }
.sgb-msg p, .sgb-msg li { text-align: justify; }
