/* DL Bot — floating robot, welcome card and chat window. RTL first. */
.dlb {
	--dlb-primary: #1769FF;
	--dlb-cyan: #36D9FF;
	--dlb-purple: #8057FF;
	--dlb-white: #F7FAFF;
	--dlb-face: #101827;
	--dlb-size-d: 100px;
	--dlb-size-m: 72px;
	--dlb-size: var(--dlb-size-d);
	--dlb-offset: 88px;
	--dlb-side: 18px;
	--dlb-ink: #14213D;
	--dlb-muted: #5B6B86;
	--dlb-glass: rgba(255, 255, 255, .80);
	--dlb-glass-2: rgba(247, 250, 255, .92);
	--dlb-line: rgba(23, 105, 255, .14);
	--dlb-bot-bg: #fff;
	--dlb-shadow: 0 18px 48px rgba(16, 24, 39, .18), 0 2px 8px rgba(16, 24, 39, .08);
	--dlb-font: inherit;
	--dlb-radius: 26px;
	--dlb-grad-head: linear-gradient(120deg, var(--dlb-primary) 0%, color-mix(in srgb, var(--dlb-primary) 55%, var(--dlb-purple)) 60%, var(--dlb-purple) 100%);
	--dlb-grad-btn: linear-gradient(135deg, var(--dlb-primary), var(--dlb-purple));
	/* robot colours (inline SVG) */
	--dlb-r-cyan: #36D9FF; --dlb-r-blue: #1769FF; --dlb-r-purple: #8057FF; --dlb-r-face: #101827; --dlb-r-face2: #080D18;
	--dlb-r-screen: #1C2A47; --dlb-r-hi: #9AF0FF; --dlb-r-deep: #0F4FD6; --dlb-r-tip: #E9FBFF;
	font-family: var(--dlb-font, inherit);
	direction: rtl;
	color: var(--dlb-ink);
}
html[data-theme="dark"] .dlb,
.dlb.dlb--dark {
	--dlb-ink: #E8EEFA;
	--dlb-muted: #A3B2CC;
	--dlb-glass: rgba(16, 24, 39, .82);
	--dlb-glass-2: rgba(22, 32, 52, .92);
	--dlb-line: rgba(54, 217, 255, .18);
	--dlb-bot-bg: rgba(30, 42, 66, .95);
	--dlb-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). */
.dlb.dlb--site {
	--dlb-primary: var(--teal, #1F7A56);
	--dlb-cyan: var(--mint, #41C48D);
	--dlb-purple: var(--grad-c, #1F7A56);
	--dlb-face: var(--navy, #0B1914);
	--dlb-ink: var(--ink, #111C18);
	--dlb-muted: var(--muted, #6E8279);
	--dlb-line: var(--line, #DCE5E0);
	--dlb-bot-bg: var(--card, #fff);
	--dlb-glass: color-mix(in srgb, var(--bg, #EAF0ED) 82%, transparent);
	--dlb-glass-2: color-mix(in srgb, var(--card, #fff) 92%, transparent);
	--dlb-shadow: 0 18px 48px rgba(var(--shade-rgb, 11, 25, 20), .22), 0 2px 8px rgba(var(--shade-rgb, 11, 25, 20), .08);
	--dlb-font: var(--font, inherit);
	--dlb-radius: 22px;
	--dlb-grad-head: var(--grad-135, linear-gradient(135deg, #0B1914, #15362A 45%, #1F7A56));
	--dlb-grad-btn: var(--grad-btn, linear-gradient(90deg, #15362A, #1F7A56));
	--dlb-r-cyan: var(--mint-l, #6EE7B7); --dlb-r-blue: var(--teal, #1F7A56); --dlb-r-purple: var(--mint, #41C48D);
	--dlb-r-face: var(--navy, #0B1914); --dlb-r-face2: var(--grad-a, #06100C); --dlb-r-screen: var(--navy-2, #15362A);
	--dlb-r-hi: color-mix(in srgb, var(--mint-l, #6EE7B7) 45%, #fff); --dlb-r-deep: var(--grad-b, #15362A); --dlb-r-tip: #fff;
}
html[data-theme="dark"] .dlb.dlb--site {
	--dlb-ink: var(--ink, #EEEDF7); --dlb-muted: var(--muted, #908CB0); --dlb-line: var(--line, #2E2A52); --dlb-bot-bg: var(--card, #1A1734);
	--dlb-glass: color-mix(in srgb, var(--bg, #0F0D22) 86%, transparent); --dlb-glass-2: color-mix(in srgb, var(--card, #1A1734) 94%, transparent);
}
html[data-theme="dark"] .dlb.dlb--site .dlb-msg a, html[data-theme="dark"] .dlb.dlb--site .dlb-chip { color: var(--mint-l, #B7CEFF); }
.dlb--site .dlb-welcome-title { color: var(--teal); }
.dlb *, .dlb *::before, .dlb *::after { box-sizing: border-box; }
.dlb [hidden] { display: none !important; }

/* ---------------- Floating robot button ---------------- */
.dlb-fab {
	position: fixed; z-index: 70; bottom: calc(var(--dlb-offset) + env(safe-area-inset-bottom, 0px));
	right: var(--dlb-side); left: auto;
	width: var(--dlb-size); height: var(--dlb-size); padding: 0; margin: 0;
	border: 0; background: none; cursor: pointer; border-radius: 50%;
	-webkit-tap-highlight-color: transparent; font: inherit; color: inherit;
}
.dlb--left .dlb-fab { right: auto; left: var(--dlb-side); }
.dlb-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(--dlb-cyan) 22%, transparent), color-mix(in srgb, var(--dlb-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(--dlb-primary) 35%, transparent), 0 0 0 6px color-mix(in srgb, var(--dlb-primary) 10%, transparent), inset 0 -8px 18px color-mix(in srgb, var(--dlb-primary) 18%, transparent);
	transition: box-shadow .3s ease, transform .3s ease;
}
html[data-theme="dark"] .dlb-fab-glass, .dlb--dark .dlb-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);
}
.dlb-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));
}
.dlb-fab-robot > svg, .dlb-fab-robot > .dlb-lottie, .dlb-fab-robot > img { width: 100%; height: 100%; display: block; }
.dlb-fab:hover .dlb-fab-glass, .dlb-fab:focus-visible .dlb-fab-glass {
	box-shadow: 0 16px 36px color-mix(in srgb, var(--dlb-primary) 45%, transparent), 0 0 0 8px color-mix(in srgb, var(--dlb-cyan) 18%, transparent), inset 0 -8px 18px color-mix(in srgb, var(--dlb-primary) 18%, transparent);
}
.dlb-fab:focus-visible { outline: 3px solid var(--dlb-cyan); outline-offset: 4px; }
.dlb-badge {
	position: absolute; top: 6%; right: 8%; width: 14px; height: 14px; border-radius: 50%;
	background: var(--dlb-purple); border: 2px solid #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--dlb-purple) 25%, transparent);
}
.dlb--left .dlb-badge { right: auto; left: 8%; }

/* Hover label «المساعد الذكي» */
.dlb-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(--dlb-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;
}
.dlb--left .dlb-tip { right: auto; left: calc(100% + 10px); transform: translate(-6px, -50%); }
.dlb-fab:hover .dlb-tip, .dlb-fab:focus-visible .dlb-tip { opacity: 1; visibility: visible; transform: translate(0, -50%); }
@media (hover: none) { .dlb-tip { display: none; } }

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

/* ---------------- Welcome card ---------------- */
.dlb-welcome {
	position: fixed; z-index: 71;
	bottom: calc(var(--dlb-offset) + env(safe-area-inset-bottom, 0px) + var(--dlb-size) * .25);
	right: calc(var(--dlb-side) + var(--dlb-size) + 10px);
	width: min(320px, calc(100vw - var(--dlb-size) - var(--dlb-side) * 2 - 20px));
	padding: 14px 16px 14px 40px; border-radius: 20px 20px 6px 20px;
	background: var(--dlb-glass-2); color: var(--dlb-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(--dlb-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);
}
.dlb--left .dlb-welcome { right: auto; left: calc(var(--dlb-side) + var(--dlb-size) + 10px); border-radius: 20px 20px 20px 6px; transform-origin: bottom left; padding: 14px 40px 14px 16px; }
.dlb-welcome.is-in { opacity: 1; transform: none; }
.dlb-welcome::before {
	content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: 20px 20px 0 0;
	background: linear-gradient(90deg, var(--dlb-cyan), var(--dlb-primary), var(--dlb-purple));
}
.dlb-welcome p { margin: 0; white-space: pre-line; }
.dlb-welcome-title { display: block; font-weight: 800; font-size: 15px; color: var(--dlb-primary); margin-bottom: 2px; }
html[data-theme="dark"] .dlb-welcome-title, .dlb--dark .dlb-welcome-title { color: var(--dlb-cyan); }
.dlb-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(--dlb-grad-btn);
	box-shadow: 0 6px 16px color-mix(in srgb, var(--dlb-primary) 35%, transparent);
}
.dlb-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(--dlb-primary) 10%, transparent); color: var(--dlb-muted);
}
.dlb--left .dlb-welcome .dlb-x { left: auto; right: 10px; }
.dlb-x svg { width: 14px; height: 14px; }
.dlb-x:hover { background: color-mix(in srgb, var(--dlb-primary) 18%, transparent); color: var(--dlb-ink); }
@media (max-width: 760px) {
	.dlb-welcome, .dlb--left .dlb-welcome {
		right: var(--dlb-side); left: auto; width: min(320px, calc(100vw - 24px));
		bottom: calc(var(--dlb-offset) + env(safe-area-inset-bottom, 0px) + var(--dlb-size) + 12px);
		border-radius: 20px 20px 6px 20px; font-size: 13.5px;
	}
	.dlb--left .dlb-welcome { right: auto; left: var(--dlb-side); border-radius: 20px 20px 20px 6px; }
}

/* ---------------- Chat window ---------------- */
.dlb-window {
	position: fixed; z-index: 560;
	right: var(--dlb-side); left: auto;
	bottom: calc(var(--dlb-offset) + env(safe-area-inset-bottom, 0px) + var(--dlb-size) + 12px);
	width: 390px; height: min(600px, calc(100vh - var(--dlb-offset) - var(--dlb-size) - 96px));
	height: min(600px, calc(100dvh - var(--dlb-offset) - var(--dlb-size) - 96px));
	min-height: 320px;
	display: flex; flex-direction: column; overflow: hidden;
	border-radius: var(--dlb-radius); color: var(--dlb-ink);
	background: var(--dlb-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(--dlb-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"] .dlb-window, .dlb--dark .dlb-window { border-color: rgba(255, 255, 255, .12); }
.dlb--left .dlb-window { right: auto; left: var(--dlb-side); transform-origin: bottom left; }
.dlb-window.is-in { opacity: 1; transform: none; }
.dlb-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(--dlb-cyan) 22%, transparent), transparent 70%);
	pointer-events: none;
}
.dlb-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(--dlb-purple) 16%, transparent), transparent 70%);
	pointer-events: none;
}

.dlb-head {
	position: relative; z-index: 1; display: flex; align-items: center; gap: 10px;
	padding: 12px 14px; color: #fff;
	background: var(--dlb-grad-head);
	box-shadow: 0 6px 18px color-mix(in srgb, var(--dlb-primary) 25%, transparent);
}
.dlb-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;
}
.dlb-avatar .dlb-robot { width: 54px; height: 54px; margin-top: -6px; }
.dlb-head-txt { flex: 1; min-width: 0; line-height: 1.3; }
.dlb-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; }
.dlb-head-txt small { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; margin-top: 2px; }
.dlb-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #FFC24B; box-shadow: 0 0 0 3px rgba(255, 255, 255, .2); flex: none; }
.dlb[data-conn="on"] .dlb-status-dot { background: #3BE39B; animation: dlbPing 2.4s ease-out infinite; }
.dlb[data-conn="off"] .dlb-status-dot { background: #FF7A85; }
@keyframes dlbPing { 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); } }
.dlb-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;
}
.dlb-ibtn svg { width: 17px; height: 17px; }
.dlb-ibtn:hover { background: rgba(255, 255, 255, .26); }
.dlb-ibtn:focus-visible, .dlb-send:focus-visible, .dlb-chip:focus-visible, .dlb-welcome-open:focus-visible, .dlb-x:focus-visible { outline: 3px solid var(--dlb-cyan); outline-offset: 2px; }

.dlb-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(--dlb-primary) 30%, transparent) transparent;
}
.dlb-msg {
	max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.85;
	overflow-wrap: anywhere; animation: dlbIn .3s ease both;
}
@keyframes dlbIn { from { opacity: 0; transform: translateY(6px); } }
.dlb-msg--bot { align-self: flex-start; background: var(--dlb-bot-bg); border: 1px solid var(--dlb-line); border-top-right-radius: 6px; box-shadow: 0 2px 10px rgba(16, 24, 39, .05); }
.dlb-msg--user { align-self: flex-end; color: #fff; border-top-left-radius: 6px; background: var(--dlb-grad-btn); box-shadow: 0 6px 16px color-mix(in srgb, var(--dlb-primary) 25%, transparent); }
.dlb-msg--err { border-color: rgba(255, 122, 133, .45); background: color-mix(in srgb, #FF7A85 8%, var(--dlb-bot-bg)); }
.dlb-msg p, .dlb-msg li, .dlb-chip, .dlb-welcome p { unicode-bidi: plaintext; }
.dlb-msg p { margin: 0 0 6px; }
.dlb-msg p:last-child { margin-bottom: 0; }
.dlb-msg h3, .dlb-msg h4 { margin: 6px 0 4px; font-size: 15px; font-weight: 800; color: inherit; }
.dlb-msg ul, .dlb-msg ol { margin: 4px 0 6px; padding-inline-start: 22px; }
.dlb-msg li { margin: 2px 0; }
.dlb-msg a { color: var(--dlb-primary); text-decoration: underline; text-underline-offset: 3px; }
html[data-theme="dark"] .dlb-msg a, .dlb--dark .dlb-msg a { color: var(--dlb-cyan); }
.dlb-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(--dlb-primary) 9%, transparent); padding: 1px 6px; border-radius: 6px; }
.dlb-msg pre { direction: ltr; text-align: left; margin: 6px 0; padding: 10px 12px; border-radius: 12px; overflow-x: auto; background: var(--dlb-face); color: #DDE8FF; }
.dlb-msg pre code { background: none; padding: 0; color: inherit; }
.dlb-msg blockquote { margin: 6px 0; padding: 4px 12px; border-inline-start: 3px solid var(--dlb-cyan); color: var(--dlb-muted); }
.dlb-msg .dlb-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(--dlb-primary) 12%, transparent); color: var(--dlb-primary);
}
.dlb-sources { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--dlb-line); display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.dlb-sources > span { color: var(--dlb-muted); font-weight: 700; }
.dlb-sources a { display: flex; gap: 8px; align-items: baseline; text-decoration: none; color: var(--dlb-ink); line-height: 1.5; }
.dlb-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(--dlb-primary); }
.dlb-sources a small { color: var(--dlb-muted); margin-inline-start: auto; flex: none; }
.dlb-sources a:hover { color: var(--dlb-primary); }
.dlb-fallback { display: inline-block; margin-top: 8px; font-weight: 700; }

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

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

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

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

@media (max-width: 760px) {
	.dlb-window, .dlb--left .dlb-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;
	}
	.dlb-window.is-min { height: 70px; }
	.dlb-msg { font-size: 14px; max-width: 92%; }
	.dlb-input { font-size: 16px; } /* no iOS zoom */
}

/* ---------------- Theme compatibility ---------------- */
body.dlb-replaces-theme .ai-fab,
body.dlb-replaces-theme .ai-backdrop,
body.dlb-replaces-theme #ai-sheet { display: none !important; }
/* «اسأل هذا الكتاب» box (theme markup): DL Bot avatar instead of the book glyph, so the box matches the robot that answers. */
body.dlb-replaces-theme .ask-book .ab-ico {
	flex: 0 0 52px; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
	background: rgba(255, 255, 255, .92) url(../robot/robot-site.svg) 50% 18% / 132% auto no-repeat;
	border: 2px solid rgba(255, 255, 255, .55);
	box-shadow: 0 6px 18px rgba(0, 0, 0, .18), inset 0 -6px 12px rgba(31, 122, 86, .10);
}
body.dlb-replaces-theme .ask-book .ab-ico svg { display: none; }
body.dlb-replaces-theme .ask-book { direction: rtl; }
body.dlb-replaces-theme .ask-book .ab-head { align-items: center; }

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

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

/* IDLE */
.dlb-anim [data-state="idle"] .dlb-body { animation: dlbBreath 4s ease-in-out infinite; }
.dlb-anim [data-state="idle"] .dlb-head { animation: dlbHeadIdle 4s ease-in-out infinite; }
.dlb-anim [data-state="idle"] .dlb-eyes { animation: dlbBlink 4s ease-in-out infinite; }
.dlb-anim [data-state="idle"] .dlb-arm-l { animation: dlbSwayL 4s ease-in-out infinite; }
.dlb-anim [data-state="idle"] .dlb-arm-r { animation: dlbSwayR 4s ease-in-out infinite; }
.dlb-anim [data-state="idle"] .dlb-ant-glow, .dlb-anim [data-state="idle"] .dlb-chest-glow { animation: dlbPulse 4s ease-in-out infinite; }
@keyframes dlbBreath { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, 1.022); } }
@keyframes dlbHeadIdle { 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 dlbBlink { 0%, 69%, 77%, 100% { transform: scaleY(1); } 73% { transform: scaleY(.1); } }
@keyframes dlbSwayL { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(4deg); } }
@keyframes dlbSwayR { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
@keyframes dlbPulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

/* WELCOME (3s, once) */
[data-state="welcome"] .dlb-mouth-smile, [data-state="success"] .dlb-mouth-smile { opacity: 0; }
[data-state="welcome"] .dlb-mouth-big, [data-state="success"] .dlb-mouth-big { opacity: 1; }
[data-state="welcome"] .dlb-eyes { transform: scaleY(.72); }
[data-state="welcome"] .dlb-head { transform: rotate(-6deg); transition: transform .4s ease; }
.dlb-anim [data-state="welcome"] .dlb-arm-l { animation: dlbWave 3s ease-in-out both; }
.dlb-anim [data-state="welcome"] .dlb-head { animation: dlbHeadWelcome 3s ease-in-out both; }
.dlb-anim [data-state="welcome"] .dlb-ant-glow, .dlb-anim [data-state="welcome"] .dlb-chest-glow { opacity: 1; }
@keyframes dlbWave {
	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 dlbHeadWelcome { 0%, 100% { transform: rotate(0); } 15%, 80% { transform: rotate(-6deg); } }

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

/* SUCCESS (2s, once) */
[data-state="success"] .dlb-eyes { transform: scale(1.1, .55); }
[data-state="success"] .dlb-fx-star { opacity: 1; }
.dlb-anim [data-state="success"] .dlb-rig { animation: dlbHop 2s ease-in-out both; }
.dlb-anim [data-state="success"] .dlb-shadow { animation: dlbShadow 2s ease-in-out both; }
.dlb-anim [data-state="success"] .dlb-arm-l { animation: dlbCheerL 2s ease-in-out both; }
.dlb-anim [data-state="success"] .dlb-arm-r { animation: dlbCheerR 2s ease-in-out both; }
.dlb-anim [data-state="success"] .dlb-star { animation: dlbStar 1.4s ease-out both; }
.dlb-anim [data-state="success"] .dlb-star-1 { animation-delay: .15s; }
.dlb-anim [data-state="success"] .dlb-star-2 { animation-delay: .3s; }
.dlb-anim [data-state="success"] .dlb-star-3 { animation-delay: .45s; }
.dlb-anim [data-state="success"] .dlb-ant-glow { animation: dlbAntThink 1s ease-in-out 2; }
@keyframes dlbHop { 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 dlbShadow { 0%, 100% { transform: scale(1); } 35% { transform: scale(.72); } 55% { transform: scale(1); } }
@keyframes dlbCheerL { 0%, 100% { transform: rotate(0); } 25%, 75% { transform: rotate(140deg); } }
@keyframes dlbCheerR { 0%, 100% { transform: rotate(0); } 25%, 75% { transform: rotate(-140deg); } }
@keyframes dlbStar { 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"] .dlb-mouth-smile { opacity: 0; }
[data-state="sleep"] .dlb-mouth-sleep { opacity: 1; }
[data-state="sleep"] .dlb-eyes { transform: scaleY(.12); }
[data-state="sleep"] .dlb-head { transform: translateY(2px) rotate(8deg); transition: transform .8s ease; }
[data-state="sleep"] .dlb-ant-glow, [data-state="sleep"] .dlb-chest-glow { opacity: .2; }
[data-state="sleep"] .dlb-fx-sleep { opacity: 1; }
.dlb-anim [data-state="sleep"] .dlb-head { animation: dlbHeadSleep 5s ease-in-out infinite; }
.dlb-anim [data-state="sleep"] .dlb-body { animation: dlbBreath 5s ease-in-out infinite; }
.dlb-anim [data-state="sleep"] .dlb-z { animation: dlbZ 4s ease-in-out infinite; }
.dlb-anim [data-state="sleep"] .dlb-z-1 { animation-delay: 1.6s; }
@keyframes dlbHeadSleep { 0%, 100% { transform: translateY(2px) rotate(7deg); } 50% { transform: translateY(4px) rotate(9deg); } }
@keyframes dlbZ { 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. */
.dlb-static *, .dlb-static *::before, .dlb-static *::after { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
	.dlb-rm *, .dlb-rm *::before, .dlb-rm *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* ---------------- Admin preview stage ---------------- */
.dlb--preview .dlb-fab, .dlb--preview .dlb-welcome, .dlb--preview .dlb-window { position: absolute; }
.dlb--preview { position: relative; }

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

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

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

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

/* 1.4.0 English edition (html[dir=ltr] on /en/ pages): text inside the robot reads left to right. The robot keeps the
   corner and position the visitor chose. */
html[dir="ltr"] .dlb-welcome, html[dir="ltr"] .dlb-window { direction: ltr; }
html[dir="ltr"] .dlb-head-txt h2, html[dir="ltr"] .dlb-chip, html[dir="ltr"] .dlb-input { text-align: left; }
html[dir="ltr"] .dlb-input { direction: ltr; }
html[dir="ltr"] .dlb-msg--bot { border-top-right-radius: 18px; border-top-left-radius: 6px; }
html[dir="ltr"] .dlb-msg--user { border-top-left-radius: 18px; border-top-right-radius: 6px; }
