#alap-chat-root {
	--alap-brand: #6366F1;
	--alap-radius: 18px;
	position: fixed;
	z-index: 999999;
	bottom: 24px;
	right: 24px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.alap-bubble {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	box-shadow: 0 10px 30px rgba(0,0,0,.25);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border: none;
	transition: transform .2s ease, box-shadow .2s ease;
}
.alap-bubble:hover { transform: scale(1.06); box-shadow: 0 14px 36px rgba(0,0,0,.3); }
.alap-bubble svg { width: 28px; height: 28px; fill: #fff; }
.alap-bubble-photo {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255,255,255,.85);
}

.alap-bubble-pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--alap-brand);
	opacity: .5;
	animation: alap-pulse 2.4s ease-out infinite;
}
@keyframes alap-pulse {
	0% { transform: scale(1); opacity: .45; }
	100% { transform: scale(1.6); opacity: 0; }
}

.alap-window {
	position: absolute;
	bottom: 78px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 120px);
	border-radius: var(--alap-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: rgba(255,255,255,.75);
	backdrop-filter: blur(18px);
	-webkit-backdrop-filter: blur(18px);
	border: 1px solid rgba(255,255,255,.4);
	box-shadow: 0 20px 60px rgba(0,0,0,.25);
	transform-origin: bottom right;
	transform: scale(.9) translateY(12px);
	opacity: 0;
	pointer-events: none;
	transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
}
#alap-chat-root.alap-open .alap-window {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: all;
}

#alap-chat-root.alap-dark .alap-window {
	background: rgba(24,24,32,.85);
	border-color: rgba(255,255,255,.08);
	color: #f1f1f4;
}

.alap-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
}
.alap-header img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #fff; }
.alap-header-title { font-weight: 600; font-size: 15px; flex: 1; }
.alap-header-sub { font-size: 11px; opacity: .85; }
.alap-icon-btn {
	background: rgba(255,255,255,.18);
	border: none;
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.alap-icon-btn:hover { background: rgba(255,255,255,.3); }
.alap-icon-btn svg { width: 16px; height: 16px; }

.alap-main {
	flex: 1;
	display: flex;
	position: relative;
	overflow: hidden;
	min-height: 0;
}

.alap-chat-panel {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.alap-sidebar-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.35);
	z-index: 5;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease;
}
#alap-chat-root.alap-sidebar-open .alap-sidebar-backdrop {
	opacity: 1;
	pointer-events: all;
}

.alap-sidebar {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 78%;
	max-width: 280px;
	background: #fff;
	color: #1d2327;
	z-index: 6;
	display: flex;
	flex-direction: column;
	transform: translateX(-100%);
	transition: transform .22s cubic-bezier(.2,.8,.2,1);
	box-shadow: 4px 0 20px rgba(0,0,0,.15);
}
#alap-chat-root.alap-dark .alap-sidebar { background: #1c1c26; color: #f1f1f4; }
#alap-chat-root.alap-sidebar-open .alap-sidebar { transform: translateX(0); }

.alap-sidebar-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px;
	border-bottom: 1px solid rgba(0,0,0,.08);
}
#alap-chat-root.alap-dark .alap-sidebar-header { border-bottom-color: rgba(255,255,255,.08); }
.alap-sidebar-header .alap-icon-btn {
	background: rgba(0,0,0,.06);
	color: #3c434a;
}
#alap-chat-root.alap-dark .alap-sidebar-header .alap-icon-btn { background: rgba(255,255,255,.1); color: #f1f1f4; }

.alap-new-chat-btn {
	flex: 1;
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	border: none;
	padding: 9px 12px;
	border-radius: 10px;
	font-weight: 600;
	font-size: 13px;
	cursor: pointer;
	text-align: left;
	display: flex;
	align-items: center;
	gap: 6px;
}
.alap-new-chat-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.alap-conversation-list {
	flex: 1;
	overflow-y: auto;
	padding: 6px;
}
.alap-conversation-item {
	padding: 10px 10px;
	border-radius: 10px;
	cursor: pointer;
	margin-bottom: 2px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.alap-conversation-item:hover { background: rgba(0,0,0,.05); }
#alap-chat-root.alap-dark .alap-conversation-item:hover { background: rgba(255,255,255,.08); }
.alap-conversation-item-active { background: rgba(0,0,0,.08); }
#alap-chat-root.alap-dark .alap-conversation-item-active { background: rgba(255,255,255,.12); }
.alap-conversation-text { flex: 1; min-width: 0; }
.alap-conversation-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alap-conversation-preview { font-size: 11.5px; color: #8a8a8f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.alap-conversation-course {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .02em;
	color: var(--alap-brand);
	background: color-mix(in srgb, var(--alap-brand) 12%, transparent);
	padding: 2px 7px;
	border-radius: 6px;
	margin-top: 5px;
}
.alap-conversation-loading, .alap-conversation-empty { padding: 14px; font-size: 12.5px; color: #8a8a8f; text-align: center; }
.alap-conversation-delete {
	background: none;
	border: none;
	cursor: pointer;
	opacity: .4;
	padding: 5px;
	flex-shrink: 0;
	color: #b32d2e;
	display: flex;
	align-items: center;
}
.alap-conversation-delete:hover { opacity: 1; background: rgba(179,45,46,.1); border-radius: 6px; }
.alap-conversation-delete svg { width: 14px; height: 14px; }

.alap-body {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.alap-msg-row { display: flex; align-items: flex-end; gap: 8px; }
.alap-msg-row-user { justify-content: flex-end; }
.alap-msg-avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; overflow: hidden; }
.alap-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.alap-msg-avatar-fallback {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

.alap-msg { max-width: 85%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; overflow: hidden; }
.alap-msg-assistant {
	background: #fff;
	color: #1d2327;
	border-bottom-left-radius: 4px;
	box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
#alap-chat-root.alap-dark .alap-msg-assistant { background: #2a2a36; color: #f1f1f4; }
.alap-msg-user {
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	border-bottom-right-radius: 4px;
}
.alap-msg code { background: rgba(0,0,0,.08); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.alap-msg pre { background: rgba(0,0,0,.85); color: #f1f1f4; padding: 10px; border-radius: 8px; overflow-x: auto; }
.alap-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0; max-width: 100%; }
.alap-msg table { border-collapse: collapse; width: 100%; margin: 0; }
.alap-msg th, .alap-msg td { border: 1px solid rgba(0,0,0,.12); padding: 4px 6px; font-size: 11.5px; white-space: normal; word-break: break-word; min-width: 56px; }
.alap-chart-wrap { position: relative; width: 100%; max-width: 100%; height: 220px; margin: 10px 0; background: rgba(0,0,0,.02); border-radius: 8px; padding: 8px; box-sizing: border-box; }
.alap-chart-wrap canvas { max-width: 100%; }
#alap-chat-root.alap-dark .alap-chart-wrap { background: rgba(255,255,255,.05); }
.alap-tv-chart-wrap { position: relative; width: 100%; max-width: 100%; height: 320px; margin: 10px 0; border-radius: 8px; overflow: hidden; }
.alap-md-heading { display: block; font-weight: 700; margin: 10px 0 4px; line-height: 1.3; }
.alap-md-heading:first-child { margin-top: 0; }
.alap-md-h1 { font-size: 17px; }
.alap-md-h2 { font-size: 15.5px; }
.alap-md-h3 { font-size: 14.5px; }
.alap-msg-assistant .alap-md-h3 { color: var(--alap-brand); }
.alap-md-h4, .alap-md-h5, .alap-md-h6 { font-size: 13.5px; text-transform: uppercase; letter-spacing: .02em; opacity: .8; }

.alap-msg-actions { display: flex; gap: 6px; margin-top: 6px; }
.alap-msg-actions button {
	background: none;
	border: none;
	cursor: pointer;
	opacity: .5;
	padding: 3px;
	color: #6b6b70;
	display: flex;
	align-items: center;
}
.alap-msg-actions button:hover { opacity: 1; }
.alap-msg-actions button:disabled { opacity: .3; cursor: default; }
.alap-msg-actions button.alap-action-active { opacity: 1; color: var(--alap-brand); }
.alap-msg-actions button.alap-action-flash { opacity: 1; color: var(--alap-brand); }
.alap-msg-actions button svg { width: 14px; height: 14px; }
#alap-chat-root.alap-dark .alap-msg-actions button { color: #b8b8c0; }
.alap-msg-actions button[data-action="download-pdf"] {
	gap: 4px;
	font-size: 11px;
	font-weight: 600;
	opacity: .75;
	padding: 3px 8px;
	border-radius: 8px;
	background: rgba(0,0,0,.04);
}
#alap-chat-root.alap-dark .alap-msg-actions button[data-action="download-pdf"] { background: rgba(255,255,255,.08); }

.alap-typing { display: flex; gap: 4px; align-self: flex-start; padding: 10px 13px; }
.alap-typing span { width: 6px; height: 6px; border-radius: 50%; background: #aaa; animation: alap-blink 1.2s infinite; }
.alap-typing span:nth-child(2) { animation-delay: .2s; }
.alap-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes alap-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.alap-form { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.alap-form input[type="text"], .alap-form input[type="tel"], .alap-form input[type="date"], .alap-form input[type="email"], .alap-form input[type="number"] {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(0,0,0,.15);
	font-size: 13.5px;
	background: rgba(255,255,255,.7);
}
#alap-chat-root.alap-dark .alap-form input { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.15); }
.alap-form button, .alap-cta-btn {
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	border: none;
	padding: 10px 14px;
	border-radius: 10px;
	font-weight: 600;
	cursor: pointer;
	font-size: 13.5px;
}
.alap-form button:disabled { opacity: .6; cursor: not-allowed; }

.alap-composer {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid rgba(0,0,0,.08);
	align-items: flex-end;
}
.alap-attach-btn {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid rgba(0,0,0,.12);
	background: rgba(0,0,0,.03);
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #4b4b52;
}
.alap-attach-btn svg { width: 18px; height: 18px; }
.alap-attach-btn:hover { background: rgba(0,0,0,.08); }
#alap-chat-root.alap-dark .alap-attach-btn { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.05); color: #fff; }
.alap-msg-image {
	display: block;
	max-width: 220px;
	max-height: 220px;
	border-radius: 10px;
	margin-bottom: 6px;
	object-fit: cover;
}
#alap-chat-root.alap-dark .alap-composer { border-top-color: rgba(255,255,255,.08); }
.alap-composer textarea {
	flex: 1;
	resize: none;
	border-radius: 12px;
	border: 1px solid rgba(0,0,0,.15);
	padding: 10px 12px;
	font-size: 13.5px;
	max-height: 90px;
	background: rgba(255,255,255,.7);
	font-family: inherit;
}
#alap-chat-root.alap-dark .alap-composer textarea { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.15); }
.alap-send-btn {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}
.alap-send-btn svg { width: 18px; height: 18px; }
.alap-send-btn:disabled { opacity: .5; cursor: not-allowed; }

.alap-sidebar-footer {
	padding: 10px;
	border-top: 1px solid rgba(0,0,0,.08);
}
#alap-chat-root.alap-dark .alap-sidebar-footer { border-top-color: rgba(255,255,255,.08); }
.alap-logout-btn {
	width: 100%;
	background: none;
	border: 1px solid rgba(0,0,0,.12);
	border-radius: 10px;
	padding: 9px 12px;
	font-size: 13px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	color: #b32d2e;
}
.alap-logout-btn svg { width: 15px; height: 15px; }
.alap-logout-btn:hover { background: rgba(179,45,46,.08); }
#alap-chat-root.alap-dark .alap-logout-btn { border-color: rgba(255,255,255,.15); }

.alap-student-card { background: rgba(255,255,255,.6); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.alap-student-card img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.alap-student-card .alap-student-name { font-weight: 600; font-size: 13.5px; }
.alap-student-card .alap-student-meta { font-size: 11.5px; color: #666; }

.alap-error-text { color: #b32d2e; font-size: 12.5px; }
.alap-link-btn {
	background: none !important;
	color: var(--alap-brand) !important;
	border: none !important;
	padding: 4px 0 !important;
	font-weight: 500;
	font-size: 12.5px;
	text-decoration: underline;
	cursor: pointer;
	align-self: flex-start;
}

.alap-quiz { margin-top: 10px; }
.alap-quiz-question { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,.08); }
#alap-chat-root.alap-dark .alap-quiz-question { border-bottom-color: rgba(255,255,255,.08); }
.alap-quiz-question:last-of-type { border-bottom: none; }
.alap-quiz-question-text { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.alap-quiz-options { display: flex; flex-direction: column; gap: 6px; }
.alap-quiz-option {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 13px;
	padding: 6px 8px;
	border-radius: 8px;
	cursor: pointer;
	border: 1px solid rgba(0,0,0,.1);
}
#alap-chat-root.alap-dark .alap-quiz-option { border-color: rgba(255,255,255,.12); }
.alap-quiz-option:hover { background: rgba(0,0,0,.03); }
#alap-chat-root.alap-dark .alap-quiz-option:hover { background: rgba(255,255,255,.05); }
.alap-quiz-option input { margin-top: 2px; }
.alap-quiz-option-correct { background: rgba(16,138,79,.12); border-color: rgba(16,138,79,.4); }
.alap-quiz-option-incorrect { background: rgba(179,45,46,.1); border-color: rgba(179,45,46,.4); }
.alap-quiz-explanation { font-size: 12px; margin-top: 6px; padding: 6px 8px; border-radius: 8px; }
.alap-quiz-explanation-correct { background: rgba(16,138,79,.08); color: #0a5132; }
.alap-quiz-explanation-incorrect { background: rgba(179,45,46,.08); color: #842029; }
.alap-quiz-submit {
	background: linear-gradient(135deg, var(--alap-brand), color-mix(in srgb, var(--alap-brand) 80%, black));
	color: #fff;
	border: none;
	padding: 9px 16px;
	border-radius: 10px;
	font-weight: 600;
	font-size: 13px;
	cursor: pointer;
	margin-top: 4px;
}
.alap-quiz-submit:disabled { opacity: .5; cursor: not-allowed; }
.alap-quiz-score { margin-top: 10px; font-weight: 700; font-size: 14px; }

@media (max-width: 480px) {
	.alap-window { width: calc(100vw - 24px); right: -12px; height: calc(100vh - 140px); }
}

/* Custom scrollbars — subtle and theme-neutral, so the browser/OS's own
   default (accent-colored) scrollbar never clashes with the widget's colors. */
.alap-body, .alap-sidebar, .alap-conversation-list, .alap-table-wrap {
	scrollbar-width: thin;
	scrollbar-color: rgba(0,0,0,.18) transparent;
}
.alap-body::-webkit-scrollbar,
.alap-sidebar::-webkit-scrollbar,
.alap-conversation-list::-webkit-scrollbar,
.alap-table-wrap::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}
.alap-body::-webkit-scrollbar-track,
.alap-sidebar::-webkit-scrollbar-track,
.alap-conversation-list::-webkit-scrollbar-track,
.alap-table-wrap::-webkit-scrollbar-track {
	background: transparent;
}
.alap-body::-webkit-scrollbar-thumb,
.alap-sidebar::-webkit-scrollbar-thumb,
.alap-conversation-list::-webkit-scrollbar-thumb,
.alap-table-wrap::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.18);
	border-radius: 10px;
}
.alap-body::-webkit-scrollbar-thumb:hover,
.alap-sidebar::-webkit-scrollbar-thumb:hover,
.alap-conversation-list::-webkit-scrollbar-thumb:hover,
.alap-table-wrap::-webkit-scrollbar-thumb:hover {
	background: rgba(0,0,0,.3);
}
#alap-chat-root.alap-dark .alap-body,
#alap-chat-root.alap-dark .alap-sidebar,
#alap-chat-root.alap-dark .alap-conversation-list,
#alap-chat-root.alap-dark .alap-table-wrap {
	scrollbar-color: rgba(255,255,255,.25) transparent;
}
#alap-chat-root.alap-dark .alap-body::-webkit-scrollbar-thumb,
#alap-chat-root.alap-dark .alap-sidebar::-webkit-scrollbar-thumb,
#alap-chat-root.alap-dark .alap-conversation-list::-webkit-scrollbar-thumb,
#alap-chat-root.alap-dark .alap-table-wrap::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,.25);
}
