/* =========================================================
   Session End Modal — matches .selfo-session-end-modal* markup
   ========================================================= */

.selfo-session-end-modal[hidden] {
	display: none !important;
}

.selfo-session-end-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	font-family: inherit;
	direction: ltr;
	font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.selfo-session-end-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(2px);
}

.selfo-session-end-modal__panel {
	position: relative;
	z-index: 1;
	width: min(420px, 100%);
	max-height: min(90vh, 640px);
	overflow: auto;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	padding: 28px 24px 20px;
	text-align: left;
}

/* دکمه بستن — بزرگ‌تر و واضح‌تر تا فریزِ ناشی از ندیدن close تکرار نشود */
.selfo-session-end-modal__close {
	position: absolute;
	top: 8px;
	left: 10px;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 999px;
	background: #f1f5f9;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	color: #334155;
}

.selfo-session-end-modal__close:hover,
.selfo-session-end-modal__close:focus-visible {
	background: #e2e8f0;
	color: #0f172a;
	outline: none;
}

.selfo-session-end-modal__identities {
	display: grid;
	gap: 8px;
	margin: 4px 0 14px;
	text-align: left;
}

.selfo-session-end-modal__identity[hidden] {
	display: none !important;
}

.selfo-session-end-modal__identity {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border: 1px solid #dbeafe;
	border-radius: 14px;
	background: #f8fbff;
}

.selfo-session-end-modal__identity--quest {
	border-color: #fef3c7;
	background: #fffbeb;
}

.selfo-session-end-modal__identity-icon {
	width: 75px;
	height: 75px;
	flex: 0 0 75px;
	object-fit: contain;
	display: block;
	border-radius: 12px;
	background: #f8fafc;
	padding: 4px;
}

.selfo-session-end-modal__identity-label,
.selfo-session-end-modal__identity-name {
	display: block;
}

.selfo-session-end-modal__identity-label {
	margin-bottom: 3px;
	color: #64748b;
	font-size: 0.82rem;
	font-weight: 700;
}

.selfo-session-end-modal__identity-name {
	color: #1e3a8a;
	font-size: 1rem;
	line-height: 1.55;
}

.selfo-session-end-modal__title {
	margin: 8px 0 10px;
	font-size: 1.3rem;
	font-weight: 700;
	color: #1e3a8a;
	line-height: 1.4;
}

/* حالت موفقیت / تلاش دوباره */
.selfo-session-end-modal.is-success .selfo-session-end-modal__title {
	color: #15803d;
}

.selfo-session-end-modal.is-fail .selfo-session-end-modal__title {
	color: #b45309;
}

/* امتیاز کودک‌پسند — دو خط: بج شرکت + کیفیت (بدون «آستانه») */
.selfo-session-end-modal__score {
	margin: 0 0 12px;
	font-size: 1rem;
	font-weight: 700;
	color: #334155;
	line-height: 1.7;
	white-space: pre-line; /* پشتیبانی از \n بین بج و کیفیت */
}

.selfo-session-end-modal__score[hidden] {
	display: none !important;
}

.selfo-session-end-modal__attempt {
	margin: 8px 0;
	color: #475569;
	font-size: .9rem;
	font-weight: 700;
}

.selfo-session-end-modal__assessment {
	margin: 14px 0;
	padding: 12px 14px;
	border: 1px solid #dbeafe;
	border-radius: 12px;
	background: #f8fbff;
	color: #1e293b;
}

.selfo-session-end-modal__objective-summary p {
	margin: 0;
	font-weight: 700;
}

.selfo-session-end-modal__criteria {
	display: grid;
	gap: 8px;
}

.selfo-session-end-modal__table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 8px;
	font-size: .92rem;
}

.selfo-session-end-modal__table td {
	padding: 9px 10px;
	border-bottom: 1px solid #e2e8f0;
}

.selfo-session-end-modal__table td:last-child {
	text-align: right;
	font-weight: 700;
	color: #1e3a8a;
}

.selfo-session-end-modal__teacher-note {
	margin: 14px 0;
	padding: 10px 12px;
	border-radius: 10px;
	background: #fff7ed;
	color: #9a3412;
	font-size: .88rem;
	line-height: 1.6;
}

.selfo-session-end-modal__model-feedback {
	margin: 12px 0 16px;
	padding: 12px 14px;
	border-radius: 10px;
	background: #f0fdf4;
	color: #166534;
	font-size: .92rem;
	line-height: 1.7;
}

.selfo-session-end-modal__teacher-feedback {
	margin: 12px 0 16px;
	padding: 12px 14px;
	border-radius: 10px;
	background: #eef2ff;
	color: #3730a3;
	font-size: .92rem;
	line-height: 1.7;
	white-space: pre-line;
}


.selfo-session-end-modal__body {
	margin: 0 0 20px;
	color: #334155;
	line-height: 1.75;
	font-size: 1rem;
	white-space: pre-wrap;
}

.selfo-session-end-modal__feedback {
	margin: -4px 0 20px;
	border: 1px solid #bfdbfe;
	border-radius: 12px;
	background: #eff6ff;
	color: #1e3a8a;
	text-align: right;
}

.selfo-session-end-modal__feedback[hidden] {
	display: none !important;
}

.selfo-session-end-modal__feedback summary {
	padding: 12px 14px;
	cursor: pointer;
	font-weight: 700;
}

.selfo-session-end-modal__feedback-list {
	margin: 0;
	padding: 0 32px 14px 14px;
	color: #334155;
	line-height: 1.8;
}

.selfo-session-end-modal__feedback-list li + li {
	margin-top: 6px;
}

.selfo-session-end-modal__ok {
	border: 0;
	border-radius: 12px;
	padding: 12px 28px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	background: #2563eb;
	color: #fff;
	min-width: 120px;
}

.selfo-session-end-modal__ok:hover,
.selfo-session-end-modal__ok:focus-visible {
	background: #1d4ed8;
	outline: none;
}

/* قفل اسکرول صفحه وقتی مودال باز است */
body.selfo-modal-open {
	overflow: hidden;
}

/* موبایل */
@media (max-width: 480px) {
	.selfo-session-end-modal {
		padding: 12px;
	}

	.selfo-session-end-modal__panel {
		padding: 24px 16px 16px;
		border-radius: 14px;
	}

	.selfo-session-end-modal__title {
		font-size: 1.2rem;
	}

}

/* ═══════════════════════════════════════════
   Quest CTA Card — rendered after Fantasy step 4
   ═══════════════════════════════════════════ */

.selfo-quest-cta-card {
	margin: 14px 0 0;
	animation: selfo-quest-card-in 0.4s ease-out both;
}

@keyframes selfo-quest-card-in {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

.selfo-quest-cta-card__inner {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
	background: linear-gradient(
		135deg,
		#fdf4ff 0%,
		#fef9ff 50%,
		#fffbeb 100%
	);
	border: 1.5px solid #f0abfc;
	border-radius: 14px;
	box-shadow:
		0 4px 14px rgba(168, 85, 247, 0.12),
		0 2px 6px rgba(251, 191, 36, 0.08);
}

.selfo-quest-cta-card__header {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
}

.selfo-quest-cta-card__tag {
	display: inline-flex;
	align-items: center;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 700;
	color: #7c3aed;
	background: #f3e8ff;
	border-radius: 20px;
	white-space: nowrap;
}

.selfo-quest-cta-card__badge {
	width: 42px;
	height: 42px;
	object-fit: cover;
	border-radius: 10px;
	border: 1.5px solid #f0abfc;
	box-shadow: 0 2px 6px rgba(168, 85, 247, 0.15);
}

.selfo-quest-cta-card__title {
	font-size: 17px;
	font-weight: 800;
	color: #5b21b6;
	margin: 2px 0 0;
	line-height: 1.4;
}

.selfo-quest-cta-card__subtitle {
	font-size: 13px;
	color: #6d28d9;
	opacity: 0.85;
	margin: 0;
	line-height: 1.5;
}

.selfo-quest-cta-card__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 700;
	color: #3f3a2f;
	background: linear-gradient(135deg, #f6c453 0%, #f0a91f 100%);
	border: none;
	border-radius: 10px;
	text-decoration: none;
	cursor: pointer;
	box-shadow:
		0 3px 10px rgba(240, 169, 31, 0.35),
		inset 0 1px 0 rgba(255, 255, 255, 0.15);
	transition: all 0.2s ease;
	white-space: nowrap;
}

.selfo-quest-cta-card__btn:hover {
	background: linear-gradient(135deg, #ffd66b 0%, #f6b52e 100%);
	box-shadow:
		0 4px 14px rgba(240, 169, 31, 0.45),
		inset 0 1px 0 rgba(255, 255, 255, 0.2);
	transform: translateY(-1px);
}

.selfo-quest-cta-card__btn:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

/* =========================================
   مورد ۱ و ۲: تغییر رنگ دکمه‌های گشت‌گذار و داستان
   ========================================= */
.selfo-cta-btn.selfo-tour-btn,
.selfo-cta-btn.selfo-cta-quest,
.selfo-cta-btn.selfo-fantasy-btn {
    background-color: #E7B50E !important; /* رنگ سازمانی شما */
    color: #000 !important; /* رنگ تیره برای خوانایی بهتر روی زرد */
    border: none;
    border-radius: 8px; /* نرم کردن گوشه دکمه‌ها */
    transition: all 0.3s ease;
}

.selfo-cta-btn.selfo-tour-btn:hover,
.selfo-cta-btn.selfo-cta-quest:hover,
.selfo-cta-btn.selfo-fantasy-btn:hover {
    background-color: #cda10d !important; /* رنگ کمی تیره‌تر برای هاور */
}
.selfo-cta-btn.selfo-cta-quest {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    max-width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.selfo-cta-btn.selfo-cta-quest:hover,
.selfo-cta-btn.selfo-cta-quest:focus {
    text-decoration: none;
}


/* =========================================
   مورد ۳: استایل باکس متنی (Textarea) چت
   ========================================= */
.selfo-chat-input {
    resize: none; /* جلوگیری از تغییر اندازه دستی توسط کاربر */
    border-radius: 8px;
    padding: 10px 15px;
    font-family: inherit;
    line-height: 1.5;
}

.selfo-chat-app--writing-challenge .selfo-chat-input {
    min-height: 132px;
    height: 132px;
    resize: vertical;
    line-height: 1.6;
    padding: 14px 16px;
}

.selfo-chat-app--writing-challenge .selfo-chat-input::placeholder {
    opacity: .78;
}

/* =========================================
   مورد ۴: استایل پیام‌های کاربر و مدل (شبیه تلگرام/واتس‌اپ)
   ========================================= */
/* تنظیم کانتینر اصلی پیام‌ها روی حالت فلکس باکس */
.selfo-chat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    overflow-y: auto;
}

.selfo-quest-start-strip{display:flex;align-items:center;justify-content:space-between;gap:14px;margin:0 0 10px;padding:10px 12px;border:1px solid #dbe5f0;border-radius:12px;background:#f8fbff}
.selfo-quest-start-strip__identity{display:flex;align-items:center;gap:9px;min-width:0;color:#1f3048}
.selfo-quest-start-strip__identity img{width:38px;height:38px;object-fit:cover;border-radius:10px;background:#eef2f8}
.selfo-quest-start-strip__identity strong,.selfo-quest-start-strip__identity span{display:block}
.selfo-quest-start-strip__identity strong{color:#287fa1;font-size:11px;text-transform:uppercase;letter-spacing:.03em}
.selfo-quest-start-strip__identity span{margin-top:2px;overflow:hidden;color:#52657d;font-size:12px;font-weight:700;text-overflow:ellipsis;white-space:nowrap}
.selfo-quest-start-strip__modes{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}
.selfo-quest-mode-btn{min-height:34px;padding:7px 10px;border:1px solid #8f98a5;border-radius:8px;background:#a3a5a8;color:#fff;font:inherit;font-size:11px;font-weight:800;cursor:pointer}
.selfo-quest-mode-btn:hover,.selfo-quest-mode-btn:focus-visible,.selfo-quest-mode-btn.is-active{border-color:#4a6ff2;background:#4a6ff2;color:#fff}
.selfo-quest-mode-btn:focus-visible{outline:2px solid rgba(74,111,242,.3);outline-offset:2px}
@media(max-width:700px){.selfo-quest-start-strip{align-items:stretch;flex-direction:column}.selfo-quest-start-strip__modes{justify-content:stretch}.selfo-quest-mode-btn{flex:1 1 0;min-width:0;padding-left:6px;padding-right:6px}}

/* Keep the long-form learning conversation inside its own workspace.
   Evaluation remains page-scrolling so its answer controls are unaffected. */
.selfo-chat-app--adventure .selfo-chat-box,
.selfo-chat-app--quest .selfo-chat-box {
    height: auto;
    min-height: 220px;
    max-height: clamp(360px, 62vh, 720px);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

@media (max-width: 700px) {
    .selfo-chat-app--adventure .selfo-chat-box,
    .selfo-chat-app--quest .selfo-chat-box {
        min-height: 220px;
        max-height: min(58vh, 560px);
    }
}

/* استایل مشترک حباب‌های پیام */
.msg-child, .msg-selfo {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 14px;
}

/* پیام کاربر (کودک) - سمت راست */
.msg-child {
    background-color: #E7B50E; /* رنگ پس‌زمینه سازمانی */
    color: #000; /* رنگ متن */
    align-self: flex-start; /* چسبیدن به سمت راست در چینش RTL */
    border-bottom-right-radius: 4px; /* گوشه تیز پیام‌رسان */
}

/* پیام آلفا (مدل/هوش مصنوعی) - سمت چپ */
.msg-selfo {
    background-color: #f0f2f5; /* خاکستری روشن */
    color: #1c1e21; /* متن تیره */
    align-self: flex-end; /* چسبیدن به سمت چپ در چینش RTL */
    border-bottom-left-radius: 4px; /* گوشه تیز پیام‌رسان */
}

/* استایل مدیا داخل حباب چت */
.selfo-chat-media {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 8px; /* فاصله بین مدیا و متن زیرش */
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15); /* یک سایه ملایم برای زیبایی */
}

/* برای اینکه چیدمان عکس و متن داخل حباب مرتب باشد */
.msg-selfo {
    display: flex;
    flex-direction: column;
}

.msg-text {
    line-height: 1.6;
    white-space: pre-line;
}

.quest-cta-wrapper {
    text-align: center;
    margin-top: 15px;
}

.quest-cta-button {
    display: inline-block;
    background: #ff9800; /* نارنجی جذاب */
    color: #fff !important;
    padding: 12px 25px;
    border-radius: 30px;
    text-decoration: none !important;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    transition: transform 0.2s;
}

.quest-cta-button:hover {
    transform: scale(1.05);
    background: #f57c00;
}

.selfo-chat-media-main {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
    display: block;
}

.selfo-chat-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	vertical-align: middle;
	margin-inline-end: 6px;
}

.msg-behruz .msg-text {
	border-inline-start: 3px solid #d6a84f;
}

.selfo-adventure-options {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 10px 0;
}

.selfo-adventure-option {
	cursor: pointer;
	border: 1px solid #e0a51a;
	border-radius: 6px;
	background: #fff;
	padding: 8px 12px;
	color: #3f3a2f;
	background: linear-gradient(135deg, #f6c453 0%, #f0a91f 100%);
}

.selfo-media-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 5px;
}

.selfo-media-icon {
    cursor: pointer;
    font-size: 1.2rem;
    background: #f0f0f0;
    padding: 5px 8px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.selfo-media-icon:hover {
    transform: scale(1.1);
    background: #e0e0e0;
}

/* =========================================================
   Media Player Modal — Layer 100001 (Above Session Modal)
   ========================================================= */
.selfo-media-player-modal[hidden] {
    display: none !important;
}

.selfo-media-player-modal {
    position: fixed;
    inset: 0;
    z-index: 100001; /* یک پله بالاتر از مودال پایان جلسه */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
}

.selfo-media-player-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
}

.selfo-media-player-modal__panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 32px 24px 20px;
}

.selfo-media-player-modal__close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selfo-media-player-modal__title {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
}

.selfo-media-player-modal__body {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    align-items: center;
}

.selfo-media-player-modal__body video,
.selfo-media-player-modal__body audio {
    width: 100%;
    display: block;
}

.selfo-media-player-modal__hint {
    width: 100%;
    margin: 0;
    padding: 20px;
    color: #0f172a;
    background: #f8fafc;
    font-size: 1rem;
    line-height: 1.7;
    text-align: left;
    white-space: pre-wrap;
}

/* Challenge mode is the English, LTR experience. */
.selfo-chat-app--challenge,
.selfo-chat-app--quest,
.selfo-chat-app--challenge .selfo-chat-input,
.selfo-chat-app--quest .selfo-chat-input,
.selfo-chat-app--challenge .selfo-chat-box,
.selfo-chat-app--quest .selfo-chat-box,
.selfo-chat-app--challenge .selfo-chat-form,
.selfo-chat-app--quest .selfo-chat-form,
.selfo-chat-app--challenge .msg-text,
.selfo-chat-app--quest .msg-text {
    direction: ltr;
    text-align: left;
}

.selfo-chat-app--challenge .selfo-chat-form,
.selfo-chat-app--quest .selfo-chat-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.selfo-chat-app--challenge .selfo-chat-input,
.selfo-chat-app--quest .selfo-chat-input {
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}

.selfo-chat-app--challenge .selfo-help-menu,
.selfo-chat-app--quest .selfo-help-menu {
    align-self: flex-start;
}

.selfo-chat-app--challenge .selfo-nano-lesson-trigger,
.selfo-chat-app--quest .selfo-nano-lesson-trigger {
    align-self: flex-start;
}

.selfo-chat-app--challenge .msg-child,
.selfo-chat-app--quest .msg-child {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 16px;
}

.selfo-chat-app--challenge .msg-selfo,
.selfo-chat-app--quest .msg-selfo {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

.selfo-chat-app--challenge .msg-text,
.selfo-chat-app--quest .msg-text {
    unicode-bidi: plaintext;
}

.selfo-challenge-resources {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.selfo-challenge-resource-inline-audio {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
}

.selfo-challenge-resource-inline-audio__label {
    flex: 0 0 auto;
    color: #0f172a;
    font-weight: 700;
}

.selfo-challenge-resource-inline-audio audio {
    width: min(520px, 100%);
    min-width: 220px;
}

.selfo-challenge-resource,
.selfo-finish-challenge {
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.selfo-challenge-resource:hover,
.selfo-challenge-resource:focus-visible {
    border-color: #2563eb;
    background: #eff6ff;
    outline: none;
}

.selfo-finish-challenge {
    margin-top: 12px;
}

.selfo-finish-challenge:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.selfo-finish-note {
    margin: 6px 0 0;
    color: #64748b;
    font-size: .85rem;
}

.selfo-challenge-writing-hint {
    margin: 10px 0 4px;
    color: #475569;
    font-size: .9rem;
    line-height: 1.5;
}

/* موبایل */
@media (max-width: 480px) {
    .selfo-challenge-resource-inline-audio {
        display: block;
    }

    .selfo-challenge-resource-inline-audio__label {
        display: block;
        margin-bottom: 6px;
    }

    .selfo-challenge-resource-inline-audio audio {
        width: 100%;
        min-width: 0;
    }

    .selfo-media-player-modal__panel {
        padding: 28px 16px 16px;
    }
}
.selfo-challenge-instruction {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid rgba(80, 110, 160, .22);
    border-radius: 12px;
    background: rgba(245, 248, 255, .9);
}

.selfo-challenge-instruction p {
    margin: 0;
}

.selfo-challenge-instruction__task {
    font-weight: 600;
}

.selfo-challenge-instruction__note {
    margin-top: 6px !important;
    font-size: .9em;
    opacity: .78;
}

.selfo-challenge-assessment {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid rgba(70, 90, 120, .18);
    border-radius: 14px;
    background: rgba(248, 250, 253, .96);
}

.selfo-challenge-passage {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 10px;
    background: #fff;
    line-height: 1.7;
    white-space: pre-wrap;
}

.selfo-challenge-item {
    margin: 0 0 .9rem;
    padding: .8rem;
    border: 1px solid rgba(70, 90, 120, .16);
    border-radius: 10px;
}

.selfo-challenge-item legend {
    padding: 0 .25rem;
    font-weight: 700;
}

.selfo-challenge-option {
    display: block;
    margin: .5rem 0;
    cursor: pointer;
}

.selfo-challenge-word-counter {
    margin: .5rem 0 0;
    font-size: .85rem;
    color: #5c6778;
}

.selfo-speaking-recorder {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid rgba(70, 90, 120, .18);
    border-radius: 12px;
    background: #fff;
}

.selfo-speaking-recorder__hint,
.selfo-speaking-recorder__status {
    margin: 0 0 .75rem;
    color: #5c6778;
}

.selfo-speaking-recorder__controls {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.selfo-speaking-recorder button {
    border: 0;
    border-radius: 8px;
    padding: .65rem 1rem;
    background: #a3a7ad;
    color: #fff;
    cursor: pointer;
}

.selfo-speaking-recorder button:hover:not(:disabled) {
    background: #4d72e8;
}

.selfo-speaking-recorder button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.selfo-speaking-recorder__preview {
    display: block;
    width: min(100%, 520px);
    margin-top: .8rem;
}

.selfo-help-menu {
    position: relative;
    align-self: flex-end;
}

/* Unified learning controls for the regular Adventure/Quest workspace. */
.selfo-chat-app--adventure .selfo-chat-form,
.selfo-chat-app--quest .selfo-chat-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.selfo-chat-app--adventure .selfo-help-menu,
.selfo-chat-app--quest .selfo-help-menu {
    order: 1;
    margin: 0;
}

.selfo-chat-app--adventure .selfo-nano-lesson-trigger,
.selfo-chat-app--quest .selfo-nano-lesson-trigger {
    order: 2;
}

.selfo-chat-app--adventure .selfo-teacher-tools,
.selfo-chat-app--quest .selfo-teacher-tools {
    order: 3;
    margin: 0;
}

/* Tools belong to the page/classroom, not to the message composer. */
.selfo-page-tools {
    position: relative;
    display: flex;
    justify-content: flex-end;
    margin: 8px 0 4px;
}

.selfo-page-tools .selfo-teacher-tools-panel {
    top: 42px;
    bottom: auto;
    left: auto;
    right: 0;
}

.selfo-page-tools .selfo-teacher-tools-toggle {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid #8f98a5;
    border-radius: 9px;
    background: #a3a5a8;
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .16s ease, box-shadow .16s ease;
}

.selfo-page-tools .selfo-teacher-tools-toggle:hover,
.selfo-page-tools .selfo-teacher-tools-toggle:focus-visible,
.selfo-page-tools .selfo-teacher-tools-toggle[aria-expanded="true"] {
    border-color: #4a6ff2;
    background: #4a6ff2;
    color: #fff;
    box-shadow: 0 4px 10px rgba(74, 111, 242, .18);
}

.selfo-quest-start-strip__help {
    align-self: center;
    margin-left: auto;
}

.selfo-quest-start-strip__nano {
    align-self: center;
}

.selfo-chat-app--adventure .selfo-help-toggle,
.selfo-chat-app--adventure .selfo-nano-lesson-trigger,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle,
.selfo-chat-app--quest .selfo-help-toggle,
.selfo-chat-app--quest .selfo-nano-lesson-trigger,
.selfo-chat-app--quest .selfo-teacher-tools-toggle,
.selfo-chat-app--adventure .selfo-topic-btn,
.selfo-chat-app--quest .selfo-topic-btn {
    min-height: 38px;
    box-sizing: border-box;
    border: 1px solid #8f98a5;
    border-radius: 9px;
    background: #a3a5a8;
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.selfo-chat-app--adventure .selfo-help-toggle,
.selfo-chat-app--quest .selfo-help-toggle {
    width: auto;
    min-width: 54px;
    height: 38px;
    padding: 0 13px;
    border-radius: 9px;
}

.selfo-chat-app--adventure .selfo-nano-lesson-trigger,
.selfo-chat-app--quest .selfo-nano-lesson-trigger,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle,
.selfo-chat-app--quest .selfo-teacher-tools-toggle {
    padding: 0 13px;
    background: #a3a5a8;
    color: #fff;
}

.selfo-chat-app--adventure .selfo-help-toggle:hover,
.selfo-chat-app--adventure .selfo-help-toggle:focus-visible,
.selfo-chat-app--adventure .selfo-nano-lesson-trigger:hover,
.selfo-chat-app--adventure .selfo-nano-lesson-trigger:focus-visible,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle:hover,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle:focus-visible,
.selfo-chat-app--quest .selfo-help-toggle:hover,
.selfo-chat-app--quest .selfo-help-toggle:focus-visible,
.selfo-chat-app--quest .selfo-nano-lesson-trigger:hover,
.selfo-chat-app--quest .selfo-nano-lesson-trigger:focus-visible,
.selfo-chat-app--quest .selfo-teacher-tools-toggle:hover,
.selfo-chat-app--quest .selfo-teacher-tools-toggle:focus-visible,
.selfo-chat-app--adventure .selfo-topic-btn:hover,
.selfo-chat-app--adventure .selfo-topic-btn:focus-visible,
.selfo-chat-app--quest .selfo-topic-btn:hover,
.selfo-chat-app--quest .selfo-topic-btn:focus-visible {
    background: #4a6ff2;
    border-color: #4a6ff2;
    color: #fff;
    box-shadow: 0 4px 10px rgba(74, 111, 242, .18);
}

.selfo-chat-app--adventure .selfo-help-toggle[aria-expanded="true"],
.selfo-chat-app--adventure .selfo-nano-lesson-trigger:active,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle[aria-expanded="true"],
.selfo-chat-app--quest .selfo-help-toggle[aria-expanded="true"],
.selfo-chat-app--quest .selfo-nano-lesson-trigger:active,
.selfo-chat-app--quest .selfo-teacher-tools-toggle[aria-expanded="true"] {
    background: #4a6ff2;
    border-color: #4a6ff2;
}

.selfo-chat-app--adventure .selfo-help-toggle:focus-visible,
.selfo-chat-app--adventure .selfo-nano-lesson-trigger:focus-visible,
.selfo-chat-app--adventure .selfo-teacher-tools-toggle:focus-visible,
.selfo-chat-app--quest .selfo-help-toggle:focus-visible,
.selfo-chat-app--quest .selfo-nano-lesson-trigger:focus-visible,
.selfo-chat-app--quest .selfo-teacher-tools-toggle:focus-visible,
.selfo-chat-app--adventure .selfo-topic-btn:focus-visible,
.selfo-chat-app--quest .selfo-topic-btn:focus-visible {
    outline: 2px solid rgba(74, 111, 242, .35);
    outline-offset: 2px;
}

.selfo-chat-app--adventure .selfo-chat-input,
.selfo-chat-app--quest .selfo-chat-input {
    order: 4;
    flex: 1 0 100%;
}

.selfo-chat-app--adventure .selfo-chat-send,
.selfo-chat-app--quest .selfo-chat-send {
    order: 5;
}

.selfo-topics-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.selfo-topics-inline .selfo-topic-btn {
    flex: 0 1 auto;
    padding: 0 13px;
}

@media (max-width: 560px) {
    .selfo-chat-app--adventure .selfo-chat-form,
    .selfo-chat-app--quest .selfo-chat-form {
        gap: 6px;
    }
    .selfo-chat-app--adventure .selfo-help-toggle,
    .selfo-chat-app--adventure .selfo-nano-lesson-trigger,
    .selfo-chat-app--adventure .selfo-teacher-tools-toggle,
    .selfo-chat-app--quest .selfo-help-toggle,
    .selfo-chat-app--quest .selfo-nano-lesson-trigger,
    .selfo-chat-app--quest .selfo-teacher-tools-toggle {
        flex: 1 1 auto;
        min-width: 0;
        padding-left: 9px;
        padding-right: 9px;
    }
}

.selfo-help-toggle {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(80, 110, 160, .35);
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    font-weight: 700;
}

.selfo-help-options {
    position: absolute;
    z-index: 5;
    right: 0;
    bottom: 40px;
    display: grid;
    gap: 6px;
    min-width: 132px;
    padding: 8px;
    border: 1px solid rgba(80, 110, 160, .22);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(20, 40, 80, .14);
}

.selfo-nano-lesson-trigger {
    border: 1px solid rgba(87, 124, 255, 0.45);
    background: rgba(87, 124, 255, 0.1);
    color: inherit;
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    white-space: nowrap;
}

.selfo-nano-lesson-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.selfo-nano-lesson-form {
    width: min(560px, 100%);
    margin: 0.6rem 0;
    padding: 0.9rem;
    border: 1px solid rgba(87, 124, 255, 0.3);
    border-radius: 12px;
    background: rgba(247, 249, 255, 0.98);
}

.selfo-nano-lesson-form[hidden] {
    display: none;
}

.selfo-nano-lesson-form label {
    display: block;
    margin-bottom: 0.65rem;
    color: inherit;
    font-size: 0.86rem;
}

.selfo-nano-lesson-form input,
.selfo-nano-lesson-form select,
.selfo-nano-lesson-form textarea {
    display: block;
    width: 100%;
    margin-top: 0.28rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #d9e0f0;
    border-radius: 7px;
    background: #fff;
    color: inherit;
    font: inherit;
}

.selfo-nano-personalization-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.selfo-nano-consent {
    display: flex !important;
    align-items: flex-start;
    gap: 0.45rem;
}

.selfo-nano-consent input {
    width: auto;
    margin-top: 0.2rem;
}

.selfo-nano-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.selfo-nano-form-actions button {
    padding: 0.45rem 0.8rem;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
}

#selfo-nano-generate {
    background: #577cff;
    color: #fff;
}

.selfo-help-option {
    border: 0;
    border-radius: 7px;
    padding: 7px 9px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.selfo-help-option:hover,
.selfo-help-option:focus-visible {
    background: rgba(80, 110, 160, .1);
}

.selfo-help-option[disabled] {
    opacity: .42;
    cursor: not-allowed;
}
.selfo-teacher-tools { position:relative; display:inline-block; margin-left:8px; }
.selfo-teacher-tools-toggle { border:0; background:transparent; color:#77859a; cursor:pointer; font:inherit; font-size:12px; }
.selfo-teacher-tools-toggle:hover { color:#287fa1; }
.selfo-teacher-tools-panel { position:absolute; bottom:calc(100% + 8px); left:0; z-index:20; min-width:240px; padding:14px; border:1px solid #dbe5f0; border-radius:12px; background:#fff; box-shadow:0 10px 28px rgba(35,65,100,.16); }
.selfo-teacher-tools-panel[hidden] { display:none; }
.selfo-teacher-tools-panel a { display:block; margin-top:8px; color:#287fa1; text-decoration:none; font-size:12px; }
.selfo-teacher-tools__teacher { margin:0 0 10px; color:#287fa1; font-size:12px; font-weight:800; }
.selfo-teacher-tools__timer { display:grid; grid-template-columns:1fr auto; gap:6px; align-items:center; color:#52657d; font-size:12px; }
.selfo-teacher-tools__timer span { grid-column:1/-1; color:#1f3048; font-size:22px; font-variant-numeric:tabular-nums; }
.selfo-teacher-tools__timer button { border:0; border-radius:6px; padding:5px 7px; background:#eef2f8; color:#52657d; cursor:pointer; font-size:11px; }
.selfo-return-to-lesson { margin:10px 0 4px; text-align:left; }
.selfo-return-to-lesson button { border:0; border-radius:9px; padding:8px 12px; background:#edf2ff; color:#345cd9; font:inherit; font-size:12px; font-weight:800; cursor:pointer; }
.selfo-return-to-lesson button:hover { background:#4a6ff2; color:#fff; }
