/* ============================================================================
   منصّة الدروس — مكوّنات خاصة بالموقع فوق ورقة الأنماط الأساسية (app.css)
   ----------------------------------------------------------------------------
   الألوان والأحجام والظلال من متغيّرات app.css نفسها، فيبقى الموقع على هوية
   نظام الرواتب. ترتيب الأقسام:
     A. مكوّنات مشتركة        E. محرّر الأسئلة         I. قشرة تطبيق الطالب
     B. لوحة المعلومات        F. النتائج والتصحيح     J. بطاقات الدروس
     C. السنوات والطلاب       G. العلامات             K. صفحة الدرس والأسئلة
     D. الدروس والملفات       H. المحادثة             L. العلامات والمحفوظة
     M. التسجيل الذاتي وطلبات الموافقة    N. كلمة المرور ورابط الأسئلة العام
     O. مجموعة الدعم      P. روابط الأسئلة      Q. الشاشات الصغيرة
   ============================================================================ */

/* ══ A. مكوّنات مشتركة ══════════════════════════════════════════════════════ */

.min-w-0 { min-width: 0; }

.sidebar-badge {
    margin-inline-start: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.u-add-btn-ghost {
    background: rgba(255, 255, 255, .12) !important;
    border: 1px solid rgba(255, 255, 255, .25) !important;
    margin-inline-end: .5rem;
}

.uf-back-btn-accent {
    background: var(--primary-light) !important;
    color: var(--primary-dark) !important;
    margin-inline-end: .5rem;
}

.uf-hint {
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--text-muted);
}

.subject-chip {
    --sc: #6366f1;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: 2px 10px 2px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    color: var(--sc);
    background: color-mix(in srgb, var(--sc) 13%, white);
    border: 1px solid color-mix(in srgb, var(--sc) 28%, white);
    white-space: nowrap;
}

.subject-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sc);
}

.score-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: .78rem;
    white-space: nowrap;
}

.score-high { background: #d1fae5; color: #047857; }
.score-mid { background: #fef3c7; color: #b45309; }
.score-low { background: #fee2e2; color: #b91c1c; }

.mini-meter {
    display: inline-block;
    width: 64px;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    vertical-align: middle;
}

.mini-meter > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: inherit;
}

.row-muted td { opacity: .55; }

.weights-bar {
    display: flex;
    gap: 3px;
    margin: .85rem 0;
    border-radius: 10px;
    overflow: hidden;
    font-size: .68rem;
    font-weight: 700;
}

.weights-bar span {
    min-width: max-content;
    padding: 5px 6px;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.w-rec { background: #6366f1; }
.w-oral { background: #0ea5e9; }
.w-exam { background: #f59e0b; }

.weights-sum {
    padding: .6rem .9rem;
    border-radius: var(--radius-sm);
    background: #ecfdf5;
    color: #047857;
    font-weight: 700;
    font-size: .85rem;
}

.weights-sum.is-bad {
    background: #fef2f2;
    color: #b91c1c;
}

.weights-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1rem;
}

.weights-legend span {
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
}

.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.seg-btn {
    padding: .35rem .85rem;
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
}

.seg-btn:hover { background: var(--primary-light); color: var(--primary-dark); }

.seg-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(99, 102, 241, .3);
}

.login-help {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin-top: 1.25rem;
    padding: .8rem .9rem;
    border-radius: var(--radius);
    background: #eff6ff;
    color: #1e3a8a;
    font-size: .84rem;
    line-height: 1.7;
}

.login-help > i { color: #229ed9; font-size: 1.25rem; }

.otp-input {
    text-align: center;
    font-size: 1.6rem !important;
    font-weight: 800;
    letter-spacing: .5em;
    padding-block: .65rem !important;
}

.otp-resend {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: .85rem;
}

/* ══ B. لوحة المعلومات ══════════════════════════════════════════════════════ */

.dash-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.1rem;
    border-bottom: 1px solid var(--border-light);
    color: inherit;
    text-decoration: none;
    transition: background var(--transition);
}

a.dash-row:hover { background: var(--surface-2); }

.dash-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-title { font-weight: 700; font-size: .9rem; }
.dash-sub { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-meta { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--text-muted); }

.dash-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
}

/* ══ C. السنوات والطلاب ═════════════════════════════════════════════════════ */

.year-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), box-shadow var(--transition);
}

.year-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.year-card.is-closed { opacity: .75; background: var(--surface-2); }

.year-card-top { display: flex; align-items: flex-start; gap: .75rem; }

.year-card-ico {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(99, 102, 241, .3);
}

.year-card-name { font-weight: 800; font-size: 1.05rem; }
.year-card-desc { font-size: .8rem; color: var(--text-muted); }

.year-card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .4rem;
    margin-top: 1rem;
}

.year-card-stats > * {
    padding: .5rem .3rem;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    text-align: center;
    font-size: .74rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.year-card-stats b { display: block; font-size: 1.05rem; color: var(--text-primary); }
.year-card-stats a:hover { border-color: var(--primary); color: var(--primary); }

.year-card-actions {
    display: flex;
    gap: .4rem;
    align-items: center;
    margin-top: auto;
    padding-top: .25rem;
}

.inline-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
    margin-bottom: .45rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.inline-row .form-control:not(.form-control-color) { flex: 1; min-width: 0; }
.inline-row input[type="date"] { max-width: 160px; }

.inline-date {
    display: flex;
    align-items: center;
    gap: .35rem;
    min-width: 0;
    margin: 0;
}

.inline-date-lbl {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.inline-row .form-control-color { width: 44px; height: 38px; padding: 4px; flex-shrink: 0; }

.inline-row-meta {
    font-size: .75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.inline-row-add {
    background: #f0fdf4;
    border: 1px dashed #86efac;
    margin-top: .75rem;
}

.tg-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: 2px 9px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-size: .75rem;
    font-weight: 700;
}

.tg-badge.is-blocked { background: #fee2e2; color: #b91c1c; }

.tg-account {
    display: flex;
    align-items: center;
    gap: .85rem;
    flex-wrap: wrap;
}

.tg-account-ico {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #229ed9;
    color: #fff;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tg-account.is-empty .tg-account-ico { background: var(--warning-light); color: #b45309; }

/* المعلومات بجانب الأيقونة دائماً، والزرّان («إرسال شهادة التهنئة» و«فكّ الربط») بعدها */
.tg-account > .flex-grow-1 { flex: 1 1 220px; min-width: 0; }
.tg-account .btn-light { border: 1px solid var(--border); }

@media (max-width: 575.98px) {
    .tg-account > .flex-grow-1 { flex-basis: calc(100% - 60px); }
    .tg-account > form { flex: 1 1 0; display: flex; margin: 0; }
    .tg-account > form .btn { width: 100%; min-height: 42px; justify-content: center; }
}

/* ══ D. الدروس والملفات ═════════════════════════════════════════════════════ */

.lesson-cell { display: flex; align-items: center; gap: .7rem; text-align: start; }

.lesson-thumb {
    width: 74px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--surface-2) center / cover no-repeat;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.lesson-cell-title { display: block; font-weight: 700; }
.lesson-cell-sub { display: block; font-size: .75rem; color: var(--text-muted); }

.yt-preview {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #0f172a;
}

.yt-preview iframe { width: 100%; height: 100%; border: 0; display: block; }

.yt-preview-empty {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    color: #94a3b8;
    font-size: .9rem;
}

.media-current {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border-radius: var(--radius);
    background: #f0f9ff;
    border: 1px solid #bae6fd;
}

.media-ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #0ea5e9;
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.media-player audio,
.media-player video { width: 100%; border-radius: var(--radius); max-height: 360px; background: #000; }
.media-player audio { background: transparent; }

.media-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: 1.5rem 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}

.media-drop > i { font-size: 2rem; color: var(--primary); }
.media-drop:hover, .media-drop.is-over { border-color: var(--primary); background: var(--primary-light); }

/* ══ E. محرّر الأسئلة ═══════════════════════════════════════════════════════ */

.qb { padding-bottom: 5.5rem; }

.qb-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-inline-start: 5px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.qb-card:focus-within { box-shadow: var(--shadow-md); border-inline-start-color: var(--secondary); }
.qb-card.has-error { border-color: var(--danger); border-inline-start-color: var(--danger); }
.qb-ghost { opacity: .4; }

.qb-card-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.qb-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.15rem;
    padding: 0 .1rem;
}

.qb-num {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 800;
    font-size: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qb-type-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-weight: 700;
    font-size: .82rem;
    color: var(--text-primary);
}

.qb-type-btn:hover { border-color: var(--primary); }
.qb-type .dropdown-item.active, .qb-type .dropdown-item:active { background: var(--primary); }

.qb-points {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .8rem;
    color: var(--text-muted);
    margin: 0;
}

.qb-points input {
    width: 54px;
    border: 0;
    outline: 0;
    font-weight: 800;
    text-align: center;
    background: transparent;
}

.qb-actions { margin-inline-start: auto; display: flex; gap: 2px; }

.qb-actions button {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
}

.qb-actions button:hover { background: var(--surface-2); color: var(--text-primary); }
.qb-actions button.is-danger:hover { background: var(--danger-light); color: var(--danger); }

.qb-prompt,
.qb-desc,
.qb-expl textarea {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--border);
    background: var(--surface-2);
    border-radius: 10px 10px 0 0;
    padding: .6rem .8rem;
    resize: none;
    outline: none;
    transition: border-color var(--transition);
}

.qb-prompt { font-size: 1.02rem; font-weight: 700; }
.qb-desc { margin-top: .5rem; font-size: .86rem; }
.qb-prompt:focus, .qb-desc:focus, .qb-expl textarea:focus { border-bottom-color: var(--primary); }

.qb-body { margin-top: .85rem; }

.qb-opt {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .4rem;
    padding: .15rem .25rem;
    border-radius: 10px;
}

.qb-opt.is-correct { background: #ecfdf5; }

.qb-correct {
    border: 0;
    background: transparent;
    font-size: 1.2rem;
    color: var(--text-muted);
    line-height: 1;
    padding: .25rem;
}

.qb-opt.is-correct .qb-correct { color: var(--success); }

.qb-opt-input {
    flex: 1;
    min-width: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    padding: .35rem .2rem;
    outline: none;
}

.qb-opt-input:hover { border-bottom-color: var(--border); }
.qb-opt-input:focus { border-bottom-color: var(--primary); }
.qb-opt-input[readonly] { font-weight: 700; }

.qb-opt-del {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    width: 30px;
    height: 30px;
}

.qb-opt-del:hover { background: var(--danger-light); color: var(--danger); }

.qb-add-opt {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    font-size: .86rem;
    padding: .35rem .25rem;
}

.qb-hint { font-size: .78rem; color: var(--text-muted); margin-top: .4rem; }

.qb-fake {
    border-bottom: 1px dotted var(--border);
    color: var(--text-muted);
    font-size: .86rem;
    padding: .4rem .2rem;
    max-width: 60%;
}

.qb-fake-lg { max-width: 100%; padding-bottom: 2rem; }

.qb-label {
    display: block;
    margin: .9rem 0 .35rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.qb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .4rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.qb-chip {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
    padding: 2px 4px 2px 10px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: .82rem;
    font-weight: 700;
}

.qb-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    line-height: 1;
    padding: 0 2px;
}

.qb-chip-input {
    flex: 1;
    min-width: 140px;
    border: 0;
    outline: 0;
    font-size: .85rem;
}

.qb-expl { margin-top: .75rem; }
.qb-expl .qb-label { margin-top: 0; }

.qb-error {
    margin-top: .6rem;
    padding: .45rem .7rem;
    border-radius: 8px;
    background: var(--danger-light);
    color: #b91c1c;
    font-size: .82rem;
    font-weight: 700;
}

.qb-card-foot {
    display: flex;
    align-items: center;
    gap: .9rem;
    flex-wrap: wrap;
    margin-top: .9rem;
    padding-top: .7rem;
    border-top: 1px solid var(--border-light);
    font-size: .84rem;
}

.qb-toggle { display: inline-flex; align-items: center; gap: .35rem; margin: 0; cursor: pointer; }
.qb-toggle input { accent-color: var(--primary); width: 16px; height: 16px; }
.qb-foot-sep { flex: 1; }

.qb-link {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: .82rem;
    padding: .2rem .4rem;
    border-radius: 8px;
}

.qb-link:hover { background: var(--surface-2); }
.qb-link.is-on { color: var(--primary); background: var(--primary-light); }

.qb-empty { text-align: center; padding: 2rem 1rem; }
.qb-empty .empty-icon { font-size: 2.4rem; color: var(--primary); }

.qb-add {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
}

.qb-add-title { font-weight: 800; font-size: .9rem; margin-bottom: .6rem; color: var(--text-secondary); }

.qb-add-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: .5rem;
}

.qb-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: .75rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-weight: 700;
    font-size: .82rem;
    color: var(--text-primary);
    transition: all var(--transition);
}

.qb-add-btn i { font-size: 1.35rem; color: var(--primary); }
.qb-add-btn:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }

.qb-bar {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .7rem max(var(--content-gutter), calc((100% - var(--content-max)) / 2));
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(15, 23, 42, .06);
}

.qb-bar-info { display: flex; gap: 1rem; font-size: .85rem; color: var(--text-secondary); flex: 1; flex-wrap: wrap; }
.qb-dirty { color: #b45309; font-weight: 700; }

/* ══ F. النتائج والتصحيح ════════════════════════════════════════════════════ */

.qs-row { padding: .85rem 0; border-bottom: 1px solid var(--border-light); }
.qs-row:last-child { border-bottom: 0; }
.qs-head { display: flex; align-items: flex-start; gap: .6rem; }
.qs-prompt { flex: 1; font-weight: 700; }

.qs-type {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.qs-meter {
    position: relative;
    margin: .55rem 0 .3rem;
    height: 26px;
    border-radius: 8px;
    background: var(--surface-2);
    overflow: hidden;
    font-size: .76rem;
}

.qs-meter-bar { position: absolute; inset-block: 0; inset-inline-start: 0; background: #d1fae5; }
.qs-meter > span { position: relative; display: block; line-height: 26px; padding-inline: .6rem; }

.qs-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 30px;
    align-items: center;
    gap: .6rem;
    font-size: .82rem;
    padding: .15rem 0;
}

.qs-option.is-correct .qs-option-label { color: #047857; font-weight: 700; }
.qs-option-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.qs-option-bar > span { display: block; height: 100%; background: var(--primary); }
.qs-option.is-correct .qs-option-bar > span { background: var(--success); }

.grade-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.grade-card-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .75rem; }
.grade-q { font-weight: 800; margin-bottom: .5rem; }

.grade-a {
    padding: .75rem .9rem;
    border-radius: var(--radius);
    background: #f8fafc;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    line-height: 1.8;
}

.grade-a.is-empty { color: var(--text-muted); font-style: italic; }

.grade-form {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) auto;
    gap: .9rem;
    align-items: end;
    margin-top: .9rem;
}

.grade-form label { font-size: .8rem; font-weight: 700; margin-bottom: .3rem; display: block; }
.grade-quick { display: flex; gap: .3rem; margin-top: .4rem; }

@media (max-width: 767.98px) {
    .grade-form { grid-template-columns: 1fr; }
}

/* ══ G. العلامات ════════════════════════════════════════════════════════════ */

.marks-tbl .mark-input {
    width: 84px;
    margin-inline: auto;
    text-align: center;
    font-weight: 700;
}

.marks-tbl td { vertical-align: middle; }
.marks-tbl input[name$="[extra_note]"] { min-width: 150px; }

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: rgba(241, 245, 249, .94);
    backdrop-filter: blur(6px);
    padding-block: .75rem;
    align-items: center;
}

/* ══ H. المحادثة ════════════════════════════════════════════════════════════ */

.convo-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--border-light);
    color: inherit;
    text-decoration: none;
    transition: background var(--transition);
}

.convo-row:hover { background: var(--surface-2); }
.convo-row.is-unread { background: #f5f3ff; }
.convo-avatar { width: 44px; height: 44px; border-radius: 14px; font-size: .95rem; flex-shrink: 0; }
.convo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.convo-top { display: flex; gap: .5rem; align-items: baseline; }
.convo-name { font-weight: 800; }
.convo-year { font-size: .72rem; color: var(--text-muted); }
.convo-last { font-size: .84rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-row.is-unread .convo-last { color: var(--text-primary); font-weight: 700; }
.convo-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; font-size: .74rem; color: var(--text-muted); }

.convo-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    font-size: .72rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.start-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .8rem .3rem .35rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: .85rem;
}

.start-chip:hover { border-color: var(--primary); color: var(--primary); }
.start-chip .u-avatar { width: 28px; height: 28px; border-radius: 50%; }

.chat {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--navbar-h) - 3rem);
    min-height: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.chat-back {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--surface-2);
    text-decoration: none;
}

.chat-avatar { width: 42px; height: 42px; border-radius: 50%; font-size: .95rem; flex-shrink: 0; }
.chat-avatar-admin { background: linear-gradient(135deg, var(--primary), var(--secondary)) !important; color: #fff !important; font-size: 1.1rem; }
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-name { font-weight: 800; }
.chat-head-sub { font-size: .76rem; color: var(--text-muted); }

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 1rem 1rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, .05), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, .05), transparent 40%),
        var(--bg);
    overscroll-behavior: contain;
}

.chat-more-wrap { text-align: center; }

.chat-more {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: .25rem .9rem;
    font-size: .78rem;
    color: var(--text-secondary);
    margin-bottom: .5rem;
}

.chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: .9rem;
    max-width: 380px;
    margin: auto;
}

.chat-empty .empty-icon { font-size: 2.6rem; color: var(--primary); margin-bottom: .5rem; }

.chat-day { text-align: center; margin: .9rem 0 .5rem; }

.chat-day span {
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .07);
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.msg {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
    margin-bottom: .35rem;
    transition: background .4s;
}

/* كتطبيقات المراسلة العربية: رسائل الطرف الآخر على اليمين (البداية)، ورسائلي
   على اليسار؛ row-reverse في RTL يبدأ من اليسار، فتأتي الأزرار إلى جهة الداخل */
.msg.theirs { justify-content: flex-start; }
.msg.mine { flex-direction: row-reverse; justify-content: flex-start; }

.msg-bubble {
    position: relative;
    max-width: min(78%, 560px);
    padding: .5rem .75rem .35rem;
    border-radius: 16px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, .08);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.msg.mine .msg-bubble {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border-start-end-radius: 4px;
}

.msg.theirs .msg-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-start-start-radius: 4px;
}

.msg-author { font-size: .72rem; font-weight: 800; opacity: .85; margin-bottom: 2px; }
.msg.theirs .msg-author { color: var(--primary); }
.msg-body { line-height: 1.75; font-size: .92rem; }
.msg-body a { color: inherit; text-decoration: underline; }
.msg-deleted { font-style: italic; opacity: .75; font-size: .85rem; }

.msg-reply {
    display: block;
    width: 100%;
    text-align: start;
    border: 0;
    border-inline-start: 3px solid currentColor;
    border-radius: 8px;
    padding: .3rem .55rem;
    margin-bottom: .35rem;
    background: rgba(255, 255, 255, .16);
    color: inherit;
    font-size: .78rem;
}

.msg.theirs .msg-reply { background: var(--surface-2); border-inline-start-color: var(--primary); }
.msg-reply b { display: block; font-size: .72rem; }
.msg-reply span { display: block; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .3rem;
    margin-top: 1px;
    font-size: .66rem;
    opacity: .75;
}

.msg-edited { font-style: italic; }
.msg-read { color: #a5f3fc; }
.msg.theirs .msg-read { color: var(--info); }
.msg-warn { color: #fde68a; }

.msg-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.msg:hover .msg-actions,
.msg.show-actions .msg-actions { opacity: 1; }

.msg-actions button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    font-size: .78rem;
}

.msg-actions button:hover { color: var(--primary); }
.msg-actions button.is-danger:hover { color: var(--danger); }
.msg.is-flash .msg-bubble { box-shadow: 0 0 0 3px rgba(245, 158, 11, .65); }

.chat-new-pill {
    position: absolute;
    bottom: 84px;
    inset-inline-start: 50%;
    transform: translateX(50%);
    border: 0;
    border-radius: 999px;
    padding: .35rem .9rem;
    background: var(--primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.chat-compose {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: .55rem .75rem;
}

.chat-context {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem .6rem;
    margin-bottom: .45rem;
    border-radius: 10px;
    background: var(--primary-light);
    border-inline-start: 3px solid var(--primary);
    font-size: .8rem;
}

.chat-context > .bi { color: var(--primary); }
.chat-context-text { flex: 1; min-width: 0; }
.chat-context-text b { display: block; font-size: .74rem; color: var(--primary-dark); }
.chat-context-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.chat-context-x { border: 0; background: transparent; color: var(--text-muted); }

.chat-compose-row { display: flex; align-items: flex-end; gap: .5rem; }

.chat-compose textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .55rem .95rem;
    max-height: 160px;
    background: var(--surface-2);
    outline: none;
    font-size: 16px;
    line-height: 1.5;
}

.chat-compose textarea:focus { border-color: var(--primary); background: var(--surface); }

.chat-send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 6px 14px rgba(99, 102, 241, .35);
}

.chat-send:disabled { opacity: .6; }

/* السهم يشير إلى جهة الإرسال في RTL */
.chat-send .bi-send-fill { display: inline-block; transform: scaleX(-1); }

/* ══ I. قشرة تطبيق الطالب ═══════════════════════════════════════════════════ */

.student-body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.st-navbar { gap: .6rem; }

.st-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary);
    text-decoration: none;
    min-width: 0;
}

.st-brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.st-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.st-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.st-pill-offline { background: #fee2e2; color: #b91c1c; }
.st-pill-sync { background: #fef3c7; color: #92400e; }
.st-pill-sync.is-busy .bi { animation: st-spin 1s linear infinite; }

@keyframes st-spin { to { transform: rotate(360deg); } }

.st-avatar {
    border: 0;
    cursor: pointer;
}

.st-menu { min-width: 230px; padding: 0; overflow: hidden; border-radius: var(--radius); }
.st-menu-head { padding: .8rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.st-menu-name { font-weight: 800; }
.st-menu-sub { font-size: .78rem; color: var(--text-muted); }
.st-menu .dropdown-item { padding: .65rem 1rem; }

main.st-main {
    max-width: 960px;
    padding: 1.1rem 1rem 1.5rem !important;
}

.st-tabbar {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, .06);
}

.st-tab {
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: .25rem 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}

.st-tab-ico {
    position: relative;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background var(--transition);
}

.st-tab.active { color: var(--primary-dark); }
.st-tab.active .st-tab-ico { background: var(--primary-light); }

.st-tab-badge {
    position: absolute;
    top: -3px;
    inset-inline-end: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .64rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.st-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .9rem;
}

.st-title { font-size: 1.35rem; font-weight: 800; margin: 0; }

.st-filter-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: .35rem .9rem;
    font-weight: 700;
    font-size: .84rem;
    color: var(--text-secondary);
}

.st-filter-btn.is-on { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.chips-scroll {
    display: flex;
    gap: .45rem;
    overflow-x: auto;
    padding: .15rem .1rem .6rem;
    margin-bottom: .4rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.chips-scroll::-webkit-scrollbar { display: none; }

.chip {
    --sc: var(--primary);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .95rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: .84rem;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition);
}

.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.chip.active { background: var(--sc); border-color: var(--sc); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--sc) 35%, transparent); }
.chip.active .chip-dot { background: #fff; }

.st-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: .65rem;
    padding: .85rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.st-filter label { display: block; font-size: .76rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .25rem; }
.st-filter .form-control, .st-filter .form-select { font-size: 16px; }
.st-filter-actions { display: flex; gap: .4rem; align-items: flex-end; }

.st-month {
    margin: 1.1rem 0 .55rem;
    font-weight: 800;
    font-size: .9rem;
    color: var(--text-secondary);
}

.st-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.st-empty > i { font-size: 2.8rem; color: var(--primary); display: block; margin-bottom: .5rem; }
.st-empty h2 { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.st-empty-sm { padding: 1.25rem 1rem; }
.st-empty-sm > i { font-size: 2rem; }

.st-note {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .8rem 1rem;
    margin: 1rem 0;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: .9rem;
}

.st-note.is-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

/* الرئيسية */
.st-hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
    color: #fff;
    overflow: hidden;
    box-shadow: 0 14px 30px rgba(79, 70, 229, .3);
    margin-bottom: 1rem;
}

.st-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    inset-inline-end: -60px;
    top: -90px;
}

.st-hero-text { flex: 1; position: relative; z-index: 1; }
.st-hero-hello { font-size: 1.35rem; font-weight: 800; }
.st-hero-sub { opacity: .85; font-size: .9rem; }

.st-hero-ring,
.result-ring,
.final-ring {
    --p: 0;
    position: relative;
    z-index: 1;
    width: 86px;
    height: 86px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, .22) 0);
}

.st-hero-ring::before,
.result-ring::before,
.final-ring::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: #5b4be8;
}

.st-hero-ring > *, .result-ring > *, .final-ring > * { position: relative; }
.st-hero-ring .num { font-weight: 800; font-size: 1.1rem; line-height: 1; }
.st-hero-ring small { font-size: .62rem; opacity: .85; }

.st-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .6rem;
    margin-bottom: 1rem;
}

.st-stat {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .8rem .75rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.st-stat > i {
    --c: var(--primary);
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--c) 14%, white);
    color: var(--c);
    font-size: 1.1rem;
}

.st-stat b { display: block; font-size: 1.05rem; }
.st-stat span { display: block; font-size: .72rem; color: var(--text-muted); line-height: 1.3; }

/* على الهاتف: ثلاث بطاقات صغيرة في صفّ واحد، الأيقونة فوق الرقم */
@media (max-width: 575.98px) {
    .st-stats { gap: .45rem; }
    .st-stat { flex-direction: column; text-align: center; gap: .35rem; padding: .7rem .4rem; }
    .st-stat b { font-size: .98rem; }
    .st-stat span { font-size: .66rem; }
}

.st-alert {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    text-decoration: none;
    font-weight: 700;
}

.st-alert > .bi:first-child { font-size: 1.3rem; }

.st-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1.2rem 0 .6rem;
}

.st-section-head h2 { font-size: 1.05rem; font-weight: 800; margin: 0; }
.st-section-head a { font-size: .84rem; font-weight: 700; text-decoration: none; }

.st-install {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: 1.25rem;
    padding: .9rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px dashed var(--primary);
}

.st-install > i { font-size: 1.6rem; color: var(--primary); }
.st-install div { flex: 1; }
.st-install b { display: block; }
.st-install span { font-size: .8rem; color: var(--text-muted); }

/* ══ J. بطاقات الدروس ═══════════════════════════════════════════════════════ */

.ls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: .85rem;
}

.ls-card {
    --sc: var(--primary);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.ls-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.ls-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--sc) 85%, black), var(--sc)) center / cover no-repeat;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .9);
    font-size: 2.2rem;
}

.ls-thumb[style*="background-image"] { background-color: #0f172a; }

.ls-play {
    position: absolute;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .9;
    transition: transform var(--transition);
}

.ls-card:hover .ls-play { transform: scale(1.1); }

.ls-progress {
    position: absolute;
    bottom: 0;
    inset-inline: 0;
    height: 4px;
    background: rgba(255, 255, 255, .35);
}

.ls-progress > span { display: block; height: 100%; background: #ef4444; }

.ls-saved {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(16, 185, 129, .92);
    color: #fff;
    font-size: .8rem;
}

.ls-body { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .85rem .85rem; }
.ls-subject { font-size: .72rem; font-weight: 800; color: var(--sc); }
.ls-title { font-weight: 800; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ls-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .55rem; font-size: .74rem; color: var(--text-muted); margin-top: .2rem; }

.ls-tag {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-weight: 700;
}

.ls-tag-ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.ls-tag-wait { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.ls-tag-todo { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }

/* ══ K. صفحة الدرس والأسئلة ═════════════════════════════════════════════════ */

.st-back {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .7rem;
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: .88rem;
    text-decoration: none;
}

.player-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #0f172a;
    box-shadow: var(--shadow-md);
}

.player-tabs {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: #111827;
}

.player-tabs button {
    flex: 1;
    border: 0;
    border-radius: 9px;
    padding: .45rem;
    background: transparent;
    color: #cbd5e1;
    font-weight: 700;
    font-size: .84rem;
}

.player-tabs button.active { background: rgba(255, 255, 255, .12); color: #fff; }

.player-frame {
    position: relative;
    aspect-ratio: 16 / 9;
}

.player-frame iframe,
.player-frame #yt-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.player-offline {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1rem;
    text-align: center;
    color: #e2e8f0;
    background: #0f172a;
}

.player-offline > i { font-size: 2rem; }

.player-media.is-video video { display: block; width: 100%; max-height: 70vh; background: #000; }

.player-media.is-audio {
    padding: 1.5rem 1rem 1rem;
    background: linear-gradient(160deg, #1e1b4b, #312e81);
}

.player-media.is-audio audio { width: 100%; }

.audio-art {
    --sc: var(--primary);
    width: 110px;
    height: 110px;
    margin: 0 auto 1rem;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--sc), color-mix(in srgb, var(--sc) 55%, #1e1b4b));
    color: #fff;
    font-size: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 30px rgba(0, 0, 0, .35);
}

.player-none {
    padding: 2rem 1rem;
    text-align: center;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    align-items: center;
}

.player-none > i { font-size: 2rem; }

.lesson-head { margin: 1rem 0 .75rem; }
.lesson-tags { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.lesson-title { font-size: 1.3rem; font-weight: 800; margin: .45rem 0 .6rem; line-height: 1.5; }

.lesson-progress { display: flex; align-items: center; gap: .65rem; }

.lesson-progress-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.lesson-progress-bar > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width .6s ease;
}

.lesson-progress-text { font-size: .8rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.lesson-progress.is-done .lesson-progress-bar > span { background: var(--success); }
.lesson-progress.is-done .lesson-progress-text { color: #047857; }

/* «أنهيت الدرس»: سمعه من مصدر آخر أو قرأه */
.lesson-done {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .45rem .8rem;
    margin-top: .75rem;
}

.lesson-done-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .45rem 1.15rem;
    border: 1.5px solid #6ee7b7;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}

.lesson-done-btn i { font-size: 1.1rem; line-height: 1; }
.lesson-done-btn:hover { background: #d1fae5; border-color: #34d399; }
.lesson-done-btn:active { transform: scale(.98); }
.lesson-done-btn:focus-visible { outline: 3px solid rgba(16, 185, 129, .35); outline-offset: 2px; }
.lesson-done-btn:disabled { opacity: .6; cursor: default; transform: none; }
.lesson-done-hint { font-size: .78rem; color: var(--text-secondary); }

@media (max-width: 575.98px) {
    .lesson-done { flex-direction: column; align-items: stretch; text-align: center; }
    .lesson-done-btn { width: 100%; }
}

.offline-card {
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
}

.offline-card.is-saved { background: #ecfdf5; border-color: #a7f3d0; }
.offline-card-main { display: flex; align-items: center; gap: .75rem; }

.offline-ico {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    background: #e0f2fe;
    color: #0369a1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.offline-card.is-saved .offline-ico { background: #d1fae5; color: #047857; }
.offline-title { font-weight: 800; font-size: .92rem; }
.offline-sub { font-size: .78rem; color: var(--text-muted); }
.offline-progress { margin-top: .6rem; display: flex; align-items: center; gap: .6rem; }
.offline-progress .progress { flex: 1; height: 8px; }

.lesson-desc {
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    line-height: 1.9;
}

.q-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: .9rem 1rem 1rem;
    margin-bottom: .75rem;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.q-card:focus-within { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); }
.q-card.is-missing { border-color: var(--danger); background: #fffafa; }

/* legend يبقى عائماً كما يضبطه Bootstrap، فيدخل البطاقة بدل أن يجلس على حدّها */
.q-prompt {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.7;
    margin-bottom: .55rem;
}

.q-prompt > span:nth-child(2) { flex: 1; }

.q-num {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.q-req { color: var(--danger); }
.q-points { font-size: .72rem; color: var(--text-muted); font-weight: 700; white-space: nowrap; margin-top: 4px; }
.q-desc { font-size: .84rem; color: var(--text-muted); margin: -.25rem 0 .6rem; padding-inline-start: 2.2rem; }
.q-options { display: flex; flex-direction: column; gap: .45rem; }

.q-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.q-opt:hover { border-color: #a5b4fc; background: #fafaff; }
.q-opt input { position: absolute; opacity: 0; pointer-events: none; }

.q-opt-mark {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.q-opt input[type="checkbox"] + .q-opt-mark { border-radius: 7px; }

.q-opt input:checked + .q-opt-mark {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: inset 0 0 0 3px #fff;
}

.q-opt input[type="checkbox"]:checked + .q-opt-mark { box-shadow: none; }

.q-opt input[type="checkbox"]:checked + .q-opt-mark::after {
    content: "\F26E";
    font-family: "bootstrap-icons";
    color: #fff;
    font-size: .95rem;
}

.q-opt:has(input:checked) { border-color: var(--primary); background: #eef2ff; }
.q-opt input:focus-visible + .q-opt-mark { outline: 3px solid rgba(99, 102, 241, .35); outline-offset: 2px; }
.q-opt-label { line-height: 1.6; }
.q-hint { font-size: .74rem; color: var(--text-muted); margin-top: .35rem; }
.q-text { font-size: 16px; border-radius: var(--radius); }
.q-error { margin-top: .45rem; font-size: .8rem; color: var(--danger); font-weight: 700; }

.result-card {
    margin: 1rem 0;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    scroll-margin-top: calc(var(--navbar-h) + 1rem);
}

.result-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.15rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
}

.result-ring { width: 76px; height: 76px; }
.result-ring .num { font-weight: 800; font-size: 1.15rem; line-height: 1; }
.result-ring small { font-size: .6rem; }
.result-ring.is-wait { background: rgba(255, 255, 255, .2); font-size: 1.6rem; }
.result-ring.is-wait::before { display: none; }
.result-title { font-weight: 800; font-size: 1.05rem; }
.result-sub { font-size: .8rem; opacity: .9; }

.review { padding: .5rem .85rem .85rem; }

.review-item {
    padding: .75rem .85rem;
    margin-top: .55rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--border);
}

.review-item.is-ok { border-inline-start-color: var(--success); }
.review-item.is-bad { border-inline-start-color: var(--danger); }
.review-item.is-part { border-inline-start-color: var(--warning); }
.review-item.is-wait { border-inline-start-color: #94a3b8; }

.review-q { display: flex; align-items: flex-start; gap: .55rem; font-weight: 700; line-height: 1.7; }

.review-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    color: #fff;
    background: #94a3b8;
    margin-top: 3px;
}

.is-ok .review-icon { background: var(--success); }
.is-bad .review-icon { background: var(--danger); }
.is-part .review-icon { background: var(--warning); }
.review-pts { font-size: .76rem; color: var(--text-muted); white-space: nowrap; margin-top: 4px; }

.review-options { list-style: none; padding: 0; margin: .45rem 0 0; padding-inline-start: 2rem; }
.review-options li { font-size: .88rem; padding: .15rem 0; display: flex; gap: .35rem; align-items: center; }
.review-options li small { color: var(--text-muted); }
.review-options li.is-right { color: #047857; font-weight: 700; }
.review-options li.is-picked:not(.is-right) { color: #b91c1c; }
.review-options li.is-empty { color: var(--text-muted); font-style: italic; }

.review-text {
    margin: .45rem 0 0 0;
    margin-inline-start: 2rem;
    padding: .5rem .7rem;
    border-radius: 8px;
    background: var(--surface-2);
    white-space: pre-wrap;
    font-size: .88rem;
}

.review-accepted, .review-feedback, .review-expl {
    margin-top: .45rem;
    margin-inline-start: 2rem;
    padding: .45rem .7rem;
    border-radius: 8px;
    font-size: .84rem;
    line-height: 1.7;
}

.review-accepted { background: #ecfdf5; color: #065f46; }
.review-feedback { background: #eff6ff; color: #1e40af; }
.review-expl { background: #fffbeb; color: #92400e; }

.lesson-nav {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    margin-top: 1.25rem;
}

.lesson-nav-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    max-width: 48%;
    padding: .65rem .85rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: .85rem;
}

.lesson-nav-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-nav-btn small { display: block; font-size: .7rem; color: var(--text-muted); font-weight: 600; }
.lesson-nav-btn.is-next { margin-inline-start: auto; text-align: end; }

/* ══ L. العلامات والمحفوظة ══════════════════════════════════════════════════ */

.final-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    margin-bottom: .9rem;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    box-shadow: 0 14px 28px rgba(5, 150, 105, .28);
}

.final-card.is-pending { background: linear-gradient(135deg, #475569, #64748b); box-shadow: var(--shadow-md); }
.final-ring::before { background: #0c9d72; }
.final-card.is-pending .final-ring::before { background: #56657a; }
.final-ring .num { font-weight: 800; font-size: 1.25rem; line-height: 1; }
.final-ring small { font-size: .62rem; }
.final-title { font-weight: 800; font-size: 1.1rem; }
.final-sub { font-size: .82rem; opacity: .9; }

.term-card {
    margin-bottom: .85rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.term-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.term-card-head h2 { font-size: 1rem; font-weight: 800; margin: 0; }

.term-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: .9rem;
}

.term-row:last-child { border-bottom: 0; }
.term-row > span:first-child { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.term-row > span:first-child .bi { color: var(--primary); }
.term-row small { font-size: .72rem; color: var(--text-muted); }
.term-row > .num { font-weight: 800; font-size: 1rem; }
.term-row.is-extra { background: #fffbeb; }
.term-row.is-extra .bi { color: var(--warning) !important; }

.storage-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
}

.storage-card > i { font-size: 1.4rem; color: var(--primary); }
.storage-text { font-size: .8rem; color: var(--text-secondary); margin-bottom: .3rem; }
.storage-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.storage-bar > span { display: block; height: 100%; background: var(--primary); }

/* شاشات واسعة: الدرس بعمود قراءة مريح */
@media (min-width: 992px) {
    .lesson-page, .saved-viewer { max-width: 860px; margin-inline: auto; }
}

/* على الهاتف: بطاقة الدرس أفقية مدمجة، الصورة إلى جانب العنوان، فتتّسع الشاشة لدروس أكثر */
@media (max-width: 575.98px) {
    .ls-grid { gap: .6rem; }
    .ls-card { flex-direction: row; align-items: stretch; }
    .ls-thumb { width: 132px; flex-shrink: 0; aspect-ratio: auto; min-height: 88px; font-size: 1.6rem; }
    .ls-play { width: 34px; height: 34px; font-size: 1.1rem; }
    .ls-body { padding: .55rem .7rem; min-width: 0; justify-content: center; }
    .ls-title { font-size: .9rem; }
    .ls-meta { font-size: .7rem; }
}

/* المحادثة في تطبيق الطالب: يُطرح شريط التنقّل السفلي من الارتفاع كي لا يغطّي حقل الكتابة */
.student-body .chat {
    height: calc(100dvh - var(--navbar-h) - 70px - 2.6rem - env(safe-area-inset-bottom));
    min-height: 360px;
}

/* ══ M. التسجيل الذاتي وطلبات الموافقة ═════════════════════════════════════ */

.pending-banner,
.pending-card {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    text-decoration: none;
    font-weight: 700;
}

.pending-banner > .bi:first-child,
.pending-card > .bi:first-child { font-size: 1.4rem; }
.pending-banner:hover { background: #fef3c7; color: #78350f; }
.pending-card { font-weight: 500; flex-wrap: wrap; }
.pending-card b { font-weight: 800; }
.pending-actions { display: flex; gap: .5rem; margin-inline-start: auto; }
.row-pending td { background: #fffdf5; }

.btn-register {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    margin-top: .85rem;
    padding: .7rem 1rem;
    border-radius: var(--radius);
    border: 1.5px solid rgba(255, 255, 255, .25);
    color: #e0e7ff;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-register:hover { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .45); }

.login-switch {
    margin-top: 1.1rem;
    text-align: center;
    font-size: .88rem;
    color: #cbd5e1;
}

.login-switch a { color: #a5b4fc; font-weight: 700; }

.register-year {
    padding: .65rem .85rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #e2e8f0;
    font-size: .9rem;
}

.link-summary {
    display: grid;
    gap: .35rem;
    margin: 0 0 1rem;
    padding: .75rem .9rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #e2e8f0;
    font-size: .88rem;
}

.link-summary div { display: flex; justify-content: space-between; gap: 1rem; }
.link-summary span { color: #94a3b8; }

.link-btn { background: linear-gradient(135deg, #229ed9, #0088cc) !important; text-decoration: none; }

.link-done {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: .85rem .95rem;
    border-radius: var(--radius);
    background: rgba(16, 185, 129, .14);
    border: 1px solid rgba(16, 185, 129, .35);
    color: #d1fae5;
    line-height: 1.8;
}

.link-done > .bi { font-size: 1.5rem; color: #34d399; }
.link-done > div > b { display: block; color: #fff; }

/* ══ N. كلمة المرور ورابط الأسئلة العام ════════════════════════════════════ */

.uf-hint { margin-top: .35rem; font-size: .76rem; color: var(--text-muted); }

.login-card .form-text { color: #94a3b8; font-size: .76rem; }

/* «أُنشئ حسابك»: ربط تيليجرام خطوةً تالية بارزة، ثم الموافقة */
.reg-logo { background: linear-gradient(135deg, #10b981, #059669) !important; }

.reg-state {
    display: flex;
    gap: .65rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: .8rem .95rem;
    border-radius: var(--radius);
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .35);
    color: #fde68a;
    line-height: 1.7;
    font-size: .88rem;
}

.reg-state b { color: #fff; }

.reg-telegram {
    margin: 0 0 1rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(34, 158, 217, .2), rgba(34, 158, 217, .07));
    border: 1px solid rgba(56, 189, 248, .45);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, .07), 0 10px 30px rgba(14, 165, 233, .12);
}

.reg-telegram-ico {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2aabee, #229ed9);
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 6px 16px rgba(34, 158, 217, .4);
}

.reg-step {
    display: inline-block;
    margin-bottom: .2rem;
    padding: 1px 9px;
    border-radius: 999px;
    background: rgba(56, 189, 248, .18);
    color: #7dd3fc;
    font-size: .7rem;
    font-weight: 800;
}

.reg-telegram-head b { display: block; font-size: 1rem; }

.reg-telegram-perks {
    display: grid;
    gap: .45rem;
    margin: 0 0 .95rem;
    padding: .75rem .85rem;
    list-style: none;
    border-radius: var(--radius);
    background: rgba(15, 23, 42, .35);
    color: #e2e8f0;
    font-size: .82rem;
}

.reg-telegram-perks li { display: flex; align-items: center; gap: .55rem; }
.reg-telegram-perks .bi { color: #38bdf8; }

.reg-telegram-head {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    margin-bottom: .75rem;
    color: #cbd5e1;
    font-size: .84rem;
    line-height: 1.7;
}

.reg-telegram-head > .bi { font-size: 1.5rem; color: #38bdf8; }
.reg-telegram-head b { color: #fff; }

.reg-linked {
    margin: 0 0 1rem;
    padding: .75rem .9rem;
    border-radius: var(--radius);
    background: rgba(16, 185, 129, .14);
    border: 1px solid rgba(16, 185, 129, .35);
    color: #6ee7b7;
    font-weight: 700;
    font-size: .86rem;
}

/* الطالب: «اربط حسابك بتيليجرام» في أعلى صفحاته حتى يربط */
.st-alert-tg {
    gap: .75rem;
    padding: .8rem .9rem;
    background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
    border-color: #7dd3fc;
    color: #075985;
    box-shadow: 0 6px 18px rgba(14, 165, 233, .12);
    transition: opacity .4s ease, transform .4s ease;
}

.st-tg-ico {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2aabee, #229ed9);
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(34, 158, 217, .35);
}

.st-tg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.55; }
.st-tg-text b { font-size: .92rem; color: #0c4a6e; }
.st-tg-text small { font-size: .76rem; font-weight: 600; color: #0369a1; }

.st-tg-btn {
    flex: none;
    padding: .5rem 1.1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #2aabee, #229ed9);
    color: #fff;
    font-size: .84rem;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(34, 158, 217, .3);
}

.st-alert-tg:hover { color: #075985; }
.st-alert-tg:hover .st-tg-btn { filter: brightness(1.07); }

.st-alert-tg.is-linked { background: #ecfdf5; border-color: #6ee7b7; box-shadow: none; cursor: default; }
.st-alert-tg.is-linked .st-tg-ico { background: linear-gradient(135deg, #10b981, #059669); box-shadow: none; }
.st-alert-tg.is-linked .st-tg-text b { color: #065f46; }
.st-alert-tg.is-linked .st-tg-text small { color: #047857; }

.chat-tg-link {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .85rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #2aabee, #229ed9);
    color: #fff;
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    transition: opacity .4s ease;
}

.chat-tg-link:hover { color: #fff; filter: brightness(1.07); }
.chat-tg-link.is-linked { background: #10b981; }

[data-tg-banner].is-leaving { opacity: 0; transform: translateY(-6px); }

/* الطالب: تغيير كلمة المرور، والتنبيه إلى الكلمة التي عيّنتها الإدارة */
.st-alert-key { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.st-form-card {
    max-width: 520px;
    margin: 0 auto;
    padding: 1.25rem;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.st-form-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.st-form-head h1 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.st-form-head p { margin: .15rem 0 0; font-size: .82rem; color: var(--text-muted); }

.st-form-ico {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.st-form-card .st-note { margin-bottom: 1rem; }

/* صفحة الدرس والمحفوظة: الأسئلة تُفتح من رابطها */
.quiz-cta {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    margin: 1rem 0;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    border: 1px solid #e0e7ff;
}

.quiz-cta-ico {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.quiz-cta-title { font-weight: 800; color: #3730a3; }
.quiz-cta-sub { font-size: .8rem; color: var(--text-secondary); }

.quiz-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.1rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.quiz-cta-btn:hover { color: #fff; filter: brightness(1.05); }
.quiz-cta-done { font-size: .85rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 575.98px) {
    .quiz-cta-btn { width: 100%; justify-content: center; }
}

/* الإدارة: رابط الأسئلة فوق المحرّر */
.quiz-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: .9rem 1rem;
    border-radius: var(--radius-lg);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}

.quiz-link-ico {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    color: #fff;
    background: var(--primary);
}

.quiz-link-title { font-weight: 800; color: #3730a3; font-size: .9rem; }
.quiz-link-url { display: block; font-weight: 700; color: var(--primary-dark); word-break: break-all; text-align: left; }
.quiz-link-sub { font-size: .78rem; color: var(--text-secondary); line-height: 1.7; }

/* رابط الأسئلة العام: صفحة مستقلة كنماذج Google، بلون مادة الدرس (--qc) */
.qf-body {
    min-height: 100vh;
    background: var(--bg);
}

.qf-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

.qf-head,
.qf-card {
    position: relative;
    margin-bottom: .9rem;
    padding: 1.15rem 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.qf-head { border-top: 8px solid var(--qc); padding-top: 1.05rem; }

.qf-head-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .75rem;
    font-size: .8rem;
    color: var(--text-muted);
}

.qf-title { margin: .55rem 0 0; font-size: 1.45rem; font-weight: 800; line-height: 1.5; }

.qf-head-note {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    margin-top: .7rem;
    padding-top: .7rem;
    border-top: 1px solid var(--border-light);
    font-size: .82rem;
    color: var(--text-secondary);
}

.qf-head-note .bi { color: var(--qc); }

.qf-card-title { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; }
.qf-card-title .bi { color: var(--qc); }
.qf-card-sub { margin: .25rem 0 1rem; font-size: .84rem; color: var(--text-muted); }

.qf-input { font-size: 16px; }
.qf-identify .form-label { display: block; font-weight: 700; font-size: .88rem; }

.qf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }

.qf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .7rem 1.4rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--qc);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.qf-btn:hover { color: #fff; filter: brightness(1.06); }
.qf-btn:disabled { opacity: .75; }

.qf-btn-ghost {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.qf-btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); }

.qf-register { margin-top: 1rem; font-size: .86rem; color: var(--text-secondary); }
.qf-register a { font-weight: 800; color: var(--qc); }

.qf-who {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: .9rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
}

.qf-who form { margin: 0; }

.qf-who-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fff;
    background: var(--qc);
}

.qf-who-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.qf-who-name span { font-size: .78rem; color: var(--text-muted); }

.qf-not-me {
    border: 0;
    background: none;
    padding: .3rem .5rem;
    font-size: .8rem;
    font-weight: 700;
    color: var(--qc);
    white-space: nowrap;
}

.qf-alert {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .9rem;
    padding: .75rem .95rem;
    border-radius: var(--radius);
    background: #fee2e2;
    color: #b91c1c;
    font-weight: 700;
    font-size: .88rem;
}

/* بطاقات الأسئلة نفسها من K، هنا على خلفية الصفحة لا داخل إطار */
.qf-form .q-card { padding: 1.1rem 1.25rem 1.2rem; box-shadow: var(--shadow-sm); }

.qf-submit-row { margin-top: 1rem; }
.qf-draft-note { font-size: .78rem; color: var(--text-muted); }

.qf-done,
.qf-closed { display: flex; gap: .9rem; align-items: center; }
.qf-done h2, .qf-closed h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.qf-done p, .qf-closed p { margin: .25rem 0 0; font-size: .86rem; color: var(--text-secondary); }

.qf-done-ico {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    color: #fff;
    background: var(--qc);
}

.qf-done-actions { margin-top: 1rem; }
.qf-done-actions form { margin: 0; }

.qf-foot { margin-top: 1.5rem; text-align: center; font-size: .78rem; color: var(--text-muted); }

@media (max-width: 575.98px) {
    /* app.css يفرض على main حشوة ضيّقة بـ !important على الهاتف، فتلتصق البطاقات بالحافّة */
    main.qf-main { padding: 1rem .75rem calc(2rem + env(safe-area-inset-bottom)) !important; }
    .qf-head, .qf-card { padding-inline: 1rem; }
    .qf-title { font-size: 1.25rem; }
    .qf-actions > .qf-btn,
    .qf-actions > form { flex: 1 1 100%; }
    .qf-actions .qf-btn { width: 100%; min-height: 48px; justify-content: center; }
}

.reg-draft {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: .7rem .85rem;
    border-radius: var(--radius);
    background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(129, 140, 248, .35);
    color: #c7d2fe;
    font-size: .84rem;
    line-height: 1.7;
}

.reg-draft b { color: #fff; }
.reg-draft a { color: #a5b4fc; font-weight: 800; }

/* ══ O. مجموعة الدعم ═══════════════════════════════════════════════════════ */

.sg-connected { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }

.sg-group-ico {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, #229ed9, #0088cc);
}

.sg-steps { margin: 0 0 1rem; padding-inline-start: 1.2rem; line-height: 2; }
.sg-steps li + li { margin-top: .5rem; }

.sg-command {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin: .35rem 0;
    padding: .6rem .8rem;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px dashed var(--border);
}

.sg-command code { min-width: 0; overflow-wrap: anywhere; font-size: 1.05rem; font-weight: 700; color: var(--primary-dark); }

.sg-help { margin: 0; padding-inline-start: 1.2rem; line-height: 2; color: var(--text-secondary); }

/* ══ P. روابط الأسئلة ══════════════════════════════════════════════════════
   بطاقة لكل رابط: المادة والتاريخ، والعنوان، والرابط بزرّ نسخه، ونسبة من أجاب،
   وزرّا «لم يجب» و«أجاب». وفي صفحة المتابعة تبويبات الطلاب ونسخ أسماء من لم يجب.
   ========================================================================== */

.ql-card {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1.1rem 1.15rem 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* شريط بلون المادة على حافّة البطاقة */
.ql-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background: var(--sc, var(--primary));
}

.ql-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    font-size: .78rem;
    color: var(--text-muted);
}

.ql-card-meta > span:not(.subject-chip) { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

.ql-card-title {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.5;
    color: var(--text-primary);
    text-decoration: none;
}

.ql-card-title:hover { color: var(--primary-dark); }

.ql-card-closed {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: .74rem;
    font-weight: 700;
}

.ql-url {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem;
    padding-inline-start: .75rem;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
}

.ql-url a {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-size: .84rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.ql-url .btn { flex: none; }

.ql-progress-text {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 6px;
    font-size: .82rem;
    color: var(--text-secondary);
}

.ql-progress-text b { color: var(--text-primary); }
.ql-progress-text > .num:last-child { margin-inline-start: auto; font-weight: 800; color: var(--text-primary); }

.ql-bar { height: 8px; border-radius: 999px; background: #fef3c7; overflow: hidden; }
.ql-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #059669, #10b981); }

.ql-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: auto; }

.ql-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: .4rem .7rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
}

.ql-chip b { font-weight: 800; }
.ql-chip.is-pending { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.ql-chip.is-pending:hover { background: #fef3c7; color: #78350f; }
.ql-chip.is-answered { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.ql-chip.is-answered:hover { background: #d1fae5; color: #064e3b; }

/* صفحة المتابعة */
.ql-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.seg-btn .bi { font-size: .85em; }

.seg-count {
    display: inline-block;
    min-width: 20px;
    margin-inline-start: 2px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .06);
    font-size: .72rem;
    text-align: center;
}

.seg-btn.active .seg-count { background: rgba(255, 255, 255, .25); }

.ql-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
    white-space: nowrap;
}

.ql-status.is-pending { background: #fffbeb; color: #92400e; }
.ql-status.is-answered { background: #ecfdf5; color: #065f46; }

/* في بطاقة الرابط (صفحة الأسئلة): إلى من أجاب ومن لم يجب */
.quiz-link-follow {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: .45rem;
    font-size: .8rem;
    font-weight: 800;
    color: var(--primary-dark);
    text-decoration: none;
}

.quiz-link-follow:hover { text-decoration: underline; }

@media (max-width: 575.98px) {
    .ql-card { padding: 1rem; }
    .ql-toolbar { padding: .75rem; }
    .ql-copy-names { width: 100%; min-height: 42px; }
}

/* ══ الطالب: «الأسئلة» — روابط أسئلة دروسه، ما أجاب عنه وما لم يجب ═══════════ */

.st-lead { margin: -.4rem 0 1rem; font-size: .86rem; color: var(--text-secondary); line-height: 1.8; }

.st-seg { display: flex; width: 100%; margin-bottom: 1rem; }
.st-seg .seg-btn { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; }

.qz-list { display: grid; gap: .75rem; }

.qz-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* شريط بلون المادة */
.qz-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background: var(--sc, var(--primary));
}

.qz-card.is-todo { border-color: #fde68a; }

.qz-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: .78rem; color: var(--text-muted); }

.qz-subject { display: inline-flex; align-items: center; gap: .35rem; font-weight: 800; color: var(--sc, var(--primary)); }
.qz-subject .chip-dot { background: var(--sc, var(--primary)); }
.qz-date { display: inline-flex; align-items: center; gap: 5px; }

.qz-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-inline-start: auto;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 800;
    white-space: nowrap;
}

.qz-status.is-todo { background: #fffbeb; color: #92400e; }
.qz-status.is-done { background: #ecfdf5; color: #065f46; }

.qz-title { font-size: 1.02rem; font-weight: 800; line-height: 1.55; color: var(--text-primary); text-decoration: none; }
.qz-title:hover { color: var(--primary-dark); }

.qz-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--text-secondary); }
.qz-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.qz-meta .bi { color: var(--text-muted); }

.qz-result {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .7rem;
    border-radius: 10px;
    background: var(--surface-2);
    font-size: .8rem;
    color: var(--text-secondary);
}

.qz-actions { display: flex; align-items: center; gap: .6rem; margin-top: .15rem; }

.qz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 42px;
    padding: .55rem 1.1rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 800;
    font-size: .86rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .25);
}

.qz-btn:hover { color: #fff; filter: brightness(1.05); }
.qz-btn.is-again { background: var(--primary-light); color: var(--primary-dark); box-shadow: none; }
.qz-btn.is-again:hover { color: var(--primary-dark); filter: brightness(.98); }

.qz-locked { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 700; color: var(--text-muted); }

.qz-more {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-inline-start: auto;
    font-size: .82rem;
    font-weight: 800;
    color: var(--primary-dark);
    text-decoration: none;
}

/* بعد قائمة الدروس في الرئيسية، فبينهما مسافة كما بين أقسام الصفحة */
.st-alert-saved { margin-top: 1.5rem; background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.st-alert-saved > .bi:first-child { color: var(--primary); }
.st-alert-saved small { display: block; font-size: .74rem; font-weight: 600; color: var(--text-muted); }

/* شارة «دون اتصال» رابط إلى المحفوظة */
a.st-pill-offline { text-decoration: none; }

@media (max-width: 575.98px) {
    .qz-card { padding: .95rem 1rem; }
    .qz-btn { flex: 1 1 auto; }
}

/* ══ Q. الشاشات الصغيرة ═════════════════════════════════════════════════════
   على الهاتف: رأس الصفحة سطران (العنوان، ثم الأزرار بعرض كامل)، والفلاتر مطويّة
   خلف زرّ ويبقى البحث ظاهراً، والجداول بطاقات لكل خلية فيها عنوانها
   (data-label)، والحقول والأزرار بارتفاع 44px تُلمس براحة، وخطّ الحقول 16px كي
   لا يكبّر iOS الصفحة عند الكتابة.
   ========================================================================== */

.hdr-info { flex: 1; min-width: 0; position: relative; }
.u-hero-aside { margin-inline-start: auto; position: relative; }

/* app.css يمحو حدود .btn ثم يعيدها لثلاثة أنواع outline فقط، فبقي زرّ «كاملة» في التصحيح بلا إطار */
.btn-outline-success { border: 1.5px solid var(--success); color: #047857; background: transparent; }
.btn-outline-success:hover { background: var(--success-light); color: #065f46; }

/* زرّ إظهار كلمة المرور في صفحات الدخول الداكنة: بلون حقولها لا بإطار فاتح */
.login-body .input-group .btn-outline-secondary {
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .6);
}

.login-body .input-group .btn-outline-secondary:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.uf-page-meta { flex-wrap: wrap; gap: 6px 14px; }
.uf-page-meta > span:not(.subject-chip) { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.uf-page-meta .bi { opacity: .75; }

/* ما يظهر على الهاتف وحده */
.u-fbar-more-btn,
.m-lbl { display: none; }

/* حقل تاريخ فارغ: Chrome يرسم «يوم/شهر/سنة» بحروف معكوسة في الصفحات العربية،
   فيُخفى حتى يُختار تاريخ (العنوان فوق الحقل يكفي، وأيقونة التقويم ظاهرة) */
input[type="date"].date-empty:not(:focus)::-webkit-datetime-edit { color: transparent; }

@media (max-width: 768px) {
    .d-flex.gap-2:not(.flex-wrap),
    .d-flex.gap-3:not(.flex-wrap) { flex-wrap: nowrap; }
}

@media (max-width: 767.98px) {

    /* ── الفلاتر ── */
    .u-fbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 10px;
        padding: 14px;
        margin-bottom: 14px;
    }

    .u-fbar-search,
    .u-fbar-wide,
    .u-fbar-m-wide,
    .u-fbar-buttons,
    .u-fbar-actions { grid-column: 1 / -1; }

    .u-fbar.has-more .u-fbar-more:not(:checked) ~ .u-fbar-group:not(.u-fbar-search),
    .u-fbar.has-more .u-fbar-more:not(:checked) ~ .u-fbar-buttons { display: none; }

    .u-fbar-more-btn {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 8px;
        height: 44px;
        margin: 0;
        padding: 0 14px;
        border: 1.5px dashed var(--border);
        border-radius: 10px;
        background: var(--surface-2);
        color: var(--text-secondary);
        font-size: .84rem;
        font-weight: 700;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .u-fbar-more-chevron { margin-inline-start: auto; transition: transform var(--transition); }

    .u-fbar-more:checked ~ .u-fbar-more-btn {
        border-style: solid;
        border-color: var(--primary);
        background: var(--primary-light);
        color: var(--primary-dark);
    }

    .u-fbar-more:checked ~ .u-fbar-more-btn .u-fbar-more-chevron { transform: rotate(180deg); }

    .u-fbar-select,
    .u-search { min-height: 44px; font-size: 16px; }
    .u-fbar-btn { height: 44px; }

    .seg { display: flex; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .seg::-webkit-scrollbar { display: none; }
    .seg-btn {
        flex: 1 1 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-height: 40px;
        padding: 8px 10px;
        font-size: .8rem;
        white-space: nowrap;
    }

    /* ── الجداول بطاقات: الخلية الرئيسة عنوان البطاقة، والبقية أزواج «عنوان: قيمة» ── */
    .u-tbl-scroll:has(> .u-tbl-cards) { max-height: none; overflow: visible; }

    .u-tbl-cards,
    .u-tbl-cards tbody { display: block; width: 100%; }
    .u-tbl-cards thead { display: none; }

    .u-tbl-cards tbody tr {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 12px 10px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-light);
    }

    .u-tbl-cards tbody td { grid-column: span 2; }
    .u-tbl-cards-2 tbody td,
    .u-tbl-cards tbody td.u-td-half { grid-column: span 3; }

    .u-tbl-cards tbody tr:last-child { border-bottom: 0; }
    .u-tbl-cards tbody tr:hover { background: transparent; }

    .u-tbl-cards tbody td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        min-width: 0;
        height: auto;
        padding: 0;
        border: 0 !important;
        font-size: .86rem;
        text-align: start;
        overflow-wrap: anywhere;
    }

    .u-tbl-cards tbody td[data-label]::before {
        content: attr(data-label);
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .7rem;
        font-weight: 700;
        color: var(--text-muted);
    }

    .u-tbl-cards tbody td.u-td-main {
        grid-column: 1 / -1;
        order: -1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 8px;
        font-size: .95rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    .u-tbl-cards tbody td.u-td-wide { grid-column: span 4; }

    /* خلية لا قيمة فيها لهذا الصفّ (طالب لم يجب: لا علامة ولا محاولات): تُطوى في البطاقة */
    .u-tbl-cards tbody td.u-td-empty { display: none; }

    .u-tbl-cards tbody td.u-td-actions {
        grid-column: 1 / -1;
        padding-top: 12px;
        border-top: 1px dashed var(--border) !important;
    }

    .u-tbl-cards tbody td.u-td-actions > .d-flex {
        width: 100%;
        flex-wrap: wrap;
        justify-content: stretch !important;
        gap: 8px !important;
    }

    .u-tbl-cards tbody td.u-td-actions > .d-flex > *,
    .u-tbl-cards tbody td.u-td-actions > .btn { flex: 1 1 56px; }
    .u-tbl-cards tbody td.u-td-actions form { display: flex; margin: 0; }

    /* الأيقونة وتحتها اسمها: اللمس لا يُظهر التلميح (title) */
    .u-tbl-cards tbody td.u-td-actions .btn {
        width: 100%;
        min-height: 50px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 6px 4px;
        border-radius: 10px;
        font-size: .7rem;
        font-weight: 600;
        line-height: 1.3;
        white-space: nowrap;
    }

    .u-tbl-cards tbody td.u-td-actions .btn .bi { font-size: 1rem; line-height: 1; }

    .m-lbl { display: inline; }

    .u-tbl-cards .tg-badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* بطاقة الطالب في إدخال العلامات: حقول بعرض الخلية، والمحصلة سطر أخير */
    .marks-tbl.u-tbl-cards .form-control,
    .marks-tbl.u-tbl-cards .mark-input {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        margin: 0;
        font-size: 16px;
    }

    .marks-tbl.u-tbl-cards tbody td[data-total] {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding-top: 10px;
        border-top: 1px dashed var(--border) !important;
    }

    .marks-tbl.u-tbl-cards tbody td[data-total]::before { font-size: .8rem; color: var(--text-secondary); }

    /* ── صفوف المواد والفصول: الاسم سطراً، والتاريخان معاً، ثم العدد والأزرار ── */
    .inline-row { flex-wrap: wrap; gap: 8px; padding: 10px; }
    .inline-row .form-control:not(.form-control-color):not([type="date"]) { flex: 1 1 calc(100% - 60px); }
    .inline-row .inline-date { flex: 1 1 calc(50% - 4px); flex-direction: column; align-items: stretch; gap: 3px; }
    .inline-row .inline-date input { max-width: none; }
    .inline-row .inline-row-meta { margin-inline-end: auto; }
    .inline-row .btn { min-width: 44px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
    .inline-row .btn-light { background: var(--surface); border: 1px solid var(--border); }
    .inline-row-add .btn { flex: 1 1 100%; }

    /* ── الحقول ── */
    .uf-field .form-control,
    .uf-field .form-select,
    .form-control:not(.form-control-sm):not(.form-control-color),
    .form-select:not(.form-select-sm) { min-height: 44px; font-size: 16px; }
}

@media (max-width: 575.98px) {

    main:not([class]) { padding: .85rem .75rem 1.25rem !important; }

    /* ── رأس الصفحة: العنوان سطراً كاملاً، والأزرار تحته متساوية ── */
    .u-hero,
    .uf-page-hdr {
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 16px;
        margin-bottom: 14px;
        border-radius: 14px;
    }

    .u-hero-ico,
    .uf-page-hdr-icon {
        flex: none;
        width: 40px;
        height: 40px;
        border-radius: 11px;
        font-size: 1.15rem;
    }

    .u-hero > .hdr-info,
    .uf-page-hdr > .hdr-info { flex: 1 1 calc(100% - 64px); }

    .u-hero > .u-hero-aside { flex: 1 1 100%; margin: 0; padding-inline-start: 52px; }

    .u-hero-title,
    .uf-page-title { font-size: 1.02rem; line-height: 1.5; }

    .u-hero-sub,
    .uf-page-sub { font-size: .76rem; line-height: 1.7; }

    .uf-page-sub:not(.uf-page-meta) { align-items: flex-start; }
    .uf-page-sub:not(.uf-page-meta) > .bi { flex: none; margin-top: .32em; }

    .u-hero > .u-add-btn,
    .uf-page-hdr > .uf-back-btn,
    .uf-page-hdr > form,
    .uf-page-hdr > .btn {
        flex: 1 1 0;
        min-height: 42px;
        margin: 0;
        justify-content: center;
    }

    .u-hero .u-add-btn {
        width: auto;
        height: auto;
        padding: 9px 12px;
        border-radius: 10px;
        font-size: .82rem;
    }

    .u-hero .u-add-btn-lbl { display: inline; }
    .uf-page-hdr > form .btn { width: 100%; min-height: 42px; }

    /* ── أرقام الإحصاء: عمودان متساويان ── */
    .u-chips {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding-bottom: 0;
        margin-bottom: 14px;
    }

    .u-chip { min-width: 0; }

    /* ── رابط الأسئلة في الإدارة: الأيقونة والعنوان سطراً، وزرّ النسخ تحتهما ── */
    .quiz-link { align-items: flex-start; }
    .quiz-link > .flex-grow-1 { flex: 1 1 0; min-width: 0; }
    .quiz-link > [data-copy] { flex: 1 1 100%; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

    /* ── شريط حفظ الأسئلة: العدد والدرجات مختصرين، والزرّ يملأ الباقي ── */
    .qb-bar { gap: .75rem; padding: .6rem .85rem calc(.6rem + env(safe-area-inset-bottom)); }

    .qb-bar-info {
        flex: 0 0 auto;
        flex-direction: column;
        gap: 0;
        font-size: .76rem;
        line-height: 1.55;
        white-space: nowrap;
    }

    .qb-bar .uf-btn-primary { flex: 1 1 auto; width: auto; min-height: 46px; justify-content: center; }
    .qb-card { padding: .9rem; }
    .qb-points { min-height: 38px; }
    .qb-actions button { min-width: 38px; min-height: 38px; }

    /* ── بطاقة السنة: أزرار بعرض البطاقة ── */
    .year-card-actions { gap: 8px; }
    .year-card-actions > .btn { flex: 1 1 0; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
    .year-card-actions > form .btn { width: 44px; min-height: 42px; }

    /* ── إضافة سؤال: عمودان، والنوع الأخير وحده بعرض الصفّ ── */
    .qb-add-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qb-add-btn:last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: .5rem; }

    /* ── التصحيح: أزرار الدرجة السريعة متساوية ── */
    .grade-quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .grade-quick .btn { min-height: 40px; }

    /* ── مجموعة الدعم ── */
    .sg-command code { flex: 1 1 100%; font-size: .92rem; }
    .sg-command .btn,
    .sg-actions > *,
    .sg-actions > form .btn { flex: 1 1 0; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
    .sg-actions > form { display: flex; }

    /* ── تصفية دروس الطالب: التاريخان متجاوران، والأزرار بعرض اللوحة ── */
    .st-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .st-filter-wide,
    .st-filter-actions { grid-column: 1 / -1; }
    .st-filter-actions .btn { flex: 1 1 0; min-height: 44px; }

    /* ── أزرار الحفظ أسفل النماذج ── */
    .uf-actions { gap: 8px; }
    .uf-actions .uf-btn-primary,
    .uf-actions .uf-btn-cancel { min-height: 46px; justify-content: center; }
}

/* ══ R. المذهب الفقهي ═══════════════════════════════════════════════════════
   يختاره الطالب، وتُخصّ به مادة أو درس: شارة في الإدارة، وزرّان في التسجيل.
   ═══════════════════════════════════════════════════════════════════════════ */

.mz-tag {
    display: inline-flex;
    align-items: center;
    padding: .1rem .55rem;
    margin-inline-start: .25rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
    vertical-align: middle;
}

.mz-tag.is-shafii { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.mz-tag.is-hanafi { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.mz-tag.is-hanbali { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.mz-tag.is-maliki { background: #fffbeb; border-color: #fde68a; color: #b45309; }

.inline-row .inline-row-select { flex: 0 0 auto; width: auto; min-width: 150px; }

/* لم يختر مذهبه: صفحة الاختيار وحدها، دون شريط التبويبات ومساحته */
.student-body.is-choosing { padding-bottom: 0; }

/* ══ S. حساب الطالب وتفصيل علامته ════════════════════════════════════════════
   كلمة مرور خاصة بدل 0000، ولمن تُسجَّل الإجابة، وكل درس يدخل في التسميع.
   ═══════════════════════════════════════════════════════════════════════════ */

.pw-forced { align-items: flex-start; background: #fffbeb; border-color: #fde68a; color: #92400e; }
.pw-forced > i { color: #d97706; margin-top: .2rem; }
.pw-not-mine { max-width: 520px; margin: .9rem auto 0; text-align: center; font-size: .88rem; color: var(--text-muted); }
.pw-not-mine .btn-link { font-size: inherit; font-weight: 700; }

.qf-owner { flex: 1 1 100%; font-size: .85rem; color: var(--text-secondary); }
.qf-owner .bi { color: var(--primary); }

.rec-details { margin: .25rem 0 .5rem; border-top: 1px dashed var(--border); padding-top: .5rem; }
.rec-details summary { cursor: pointer; font-size: .82rem; font-weight: 700; color: var(--primary); list-style-position: inside; }
.rec-details summary .bi { margin-inline-end: .25rem; }
.rec-missing { display: inline-block; margin-inline-start: .35rem; font-weight: 600; color: #b45309; }
.rec-list { list-style: none; margin: .5rem 0 0; padding: 0; }

.rec-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .84rem;
}

.rec-list li:last-child { border-bottom: 0; }
.rec-title { min-width: 0; display: flex; flex-direction: column; }
.rec-title a { color: inherit; font-weight: 600; }
.rec-title small { font-size: .72rem; color: var(--text-muted); }
.rec-score { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; white-space: nowrap; }
.rec-score small { font-size: .7rem; color: var(--text-muted); }
.rec-list li.is-zero .rec-score { color: #b45309; }
.rec-term { display: flex; justify-content: space-between; gap: .75rem; margin-top: .5rem; font-size: .9rem; }

.mz-note { color: var(--text-secondary); }
.mz-note > i { color: var(--primary); }
.mz-opt .q-opt-label { font-weight: 700; }

/* «إنشاء حساب»: زرّا المذهب على الخلفية الداكنة */
.reg-madhhab { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.reg-madhhab-opt { position: relative; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.reg-madhhab-opt input { position: absolute; opacity: 0; pointer-events: none; }

.reg-madhhab-opt span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 48px;
    padding: .6rem .75rem;
    border-radius: var(--radius);
    border: 1.5px solid rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .06);
    color: #e2e8f0;
    font-weight: 700;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.reg-madhhab-opt span i { color: #94a3b8; transition: color .15s ease; }
.reg-madhhab-opt:hover span { border-color: rgba(165, 180, 252, .6); }
.reg-madhhab-opt input:checked + span { background: rgba(99, 102, 241, .28); border-color: #818cf8; color: #fff; }
.reg-madhhab-opt input:checked + span i { color: #c7d2fe; }
.reg-madhhab-opt input:focus-visible + span { outline: 3px solid rgba(129, 140, 248, .55); outline-offset: 2px; }

@media (max-width: 768px) {
    .inline-row .inline-row-select { flex: 1 1 100%; min-width: 0; }
}
