:root {
            --bg-body: #0F172A;
            --bg-container: #FFFFFF;
            --color-h1: #1E40AF;
            --color-h2: #2563EB;
            --accent: #059669;
            --warning: #D97706;
            --danger: #DC2626;
            --text-main: #1E293B;
            --text-muted: #475569;
            --border-color: #CBD5E1;
        }
        * { box-sizing: border-box; }
        body {
            font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
            background: radial-gradient(circle at top, #1E3A8A 0%, #0F172A 72%);
            color: var(--text-main);
            margin: 0;
            min-height: 100vh;
            line-height: 1.6;
        }
        .page-container {
            max-width: 960px;
            margin: 28px auto;
            padding: 0 16px 40px;
        }
        .card-box {
            background: var(--bg-container);
            border-radius: 18px;
            padding: 32px;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
            border-top: 7px solid var(--color-h1);
        }
        .banner-header {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 18px;
            margin-bottom: 18px;
            text-align: center;
            border-bottom: 2px solid #E2E8F0;
            padding-bottom: 16px;
        }
        .banner-logo {
            width: 72px;
            height: auto;
        }
        .school-info p {
            margin: 0;
            font-weight: 700;
            color: #64748B;
            font-size: 0.86rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .school-info h1 {
            margin: 4px 0 0 0;
            color: var(--color-h1);
            font-size: 1.45rem;
            font-weight: 800;
            text-transform: uppercase;
        }

        /* KHỐI 1: MÀN HÌNH ĐĂNG NHẬP BẮT BUỘC ĐẦU TIÊN */
        .login-gate-box {
            max-width: 540px;
            margin: 0 auto;
        }
        .role-tabs {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 8px;
            background: #F1F5F9;
            padding: 6px;
            border-radius: 10px;
            margin-bottom: 18px;
        }
        .role-tab {
            padding: 10px 8px;
            text-align: center;
            font-weight: 700;
            font-size: 0.9rem;
            border-radius: 8px;
            cursor: pointer;
            border: none;
            background: transparent;
            color: #475569;
            transition: all 0.2s;
        }
        .role-tab.active {
            background: var(--color-h1);
            color: #FFFFFF;
            box-shadow: 0 4px 10px rgba(30, 64, 175, 0.25);
        }
        .info-banner {
            background: #EFF6FF;
            border-left: 4px solid #2563EB;
            padding: 12px 14px;
            border-radius: 0 8px 8px 0;
            font-size: 0.88rem;
            color: #1E3A8A;
            margin-bottom: 16px;
        }
        .form-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 14px;
        }
        .form-group label {
            font-weight: 600;
            font-size: 0.92rem;
            color: #1E293B;
        }
        .form-group select,
        .form-group input {
            padding: 11px 14px;
            border: 1.5px solid var(--border-color);
            border-radius: 8px;
            font-size: 0.96rem;
            font-family: inherit;
            outline: none;
        }
        .form-group select:focus,
        .form-group input:focus {
            border-color: var(--color-h2);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
        }
        .btn-login {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, #059669 0%, #10B981 100%);
            color: #FFFFFF;
            border: none;
            border-radius: 10px;
            font-size: 1.02rem;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 6px 16px rgba(5, 150, 105, 0.28);
            transition: all 0.2s;
        }
        .btn-login:hover { transform: translateY(-1px); }
        .btn-login:disabled { background: #94A3B8; cursor: wait; }

        #loginAlert {
            display: none;
            padding: 11px 14px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 600;
            margin-bottom: 14px;
        }

        /* KHỐI 2: BẢNG ĐIỀU HƯỚNG SAU KHI ĐÃ ĐĂNG NHẬP (PHÂN TÁCH THEO KHỐI 10/11/12 & VAI TRÒ) */
        #authenticatedWorkspace {
            display: none;
        }
        .welcome-banner {
            background: #ECFDF5;
            border: 1.5px solid #A7F3D0;
            border-left: 6px solid #059669;
            padding: 16px 20px;
            border-radius: 12px;
            margin-bottom: 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 12px;
        }
        .grade-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 18px;
            margin-top: 16px;
        }
        .grade-card {
            background: #F8FAFC;
            border: 2px solid #E2E8F0;
            border-radius: 14px;
            padding: 20px;
            transition: all 0.2s;
            position: relative;
        }
        .grade-card.unlocked {
            background: #FFFFFF;
            border-color: #2563EB;
            box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
        }
        .grade-card.locked {
            opacity: 0.52;
            background: #F1F5F9;
            border-color: #CBD5E1;
            pointer-events: none;
            user-select: none;
        }
        .grade-card h3 {
            margin: 0 0 8px 0;
            color: var(--color-h1);
            font-size: 1.25rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .grade-card p {
            margin: 0 0 14px 0;
            font-size: 0.9rem;
            color: var(--text-muted);
        }
        .grade-links {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .grade-links a {
            display: block;
            text-decoration: none;
            padding: 10px 14px;
            border-radius: 8px;
            font-weight: 700;
            font-size: 0.9rem;
            background: #EFF6FF;
            color: #1D4ED8;
            border: 1px solid #BFDBFE;
            transition: all 0.15s;
        }
        .grade-links a:hover {
            background: #2563EB;
            color: #FFFFFF;
        }
        .staff-portal-box {
            display: none;
            background: #FEF3C7;
            border: 2px solid #F59E0B;
            border-radius: 14px;
            padding: 20px;
            margin-bottom: 24px;
        }
        footer {
            text-align: center;
            margin-top: 28px;
            padding-top: 16px;
            color: #64748B;
            font-size: 0.88rem;
            border-top: 1px solid #E2E8F0;
        }

        @media screen and (max-width: 600px) {
            .page-container { margin: 14px auto; padding: 0 10px 28px; }
            .card-box { padding: 20px 14px; border-radius: 14px; }
            .banner-header { flex-direction: column; gap: 10px; }
            .school-info h1 { font-size: 1.2rem; }
            .role-tabs { grid-template-columns: 1fr; }
        }

/* Co giãn tự động cỡ chữ tiêu đề trên mọi màn hình */
h1, .school-info h1, .top-banner h1 { font-size: clamp(1.12rem, 3.5vw, 1.55rem) !important; line-height: 1.35 !important; }
h2 { font-size: clamp(1rem, 2.8vw, 1.25rem) !important; }

/* ==========================================================================
   11. HỆ THỐNG NÚT LỆNH CO GIÃN THÔNG MINH THEO MÀN HÌNH THIẾT BỊ (FLUID BUTTONS)
   Tự động điều chỉnh kích thước từ Điện thoại nhỏ (320px) -> Tablet -> PC lớn
   ========================================================================== */
button,
.btn-start,
.btn-submit,
.btn-clear,
.btn-action,
.btn-login,
.btn-submit-practice,
.btn-paste,
.nav-tab-btn,
.topic-tab-btn,
.lab-tab-btn,
.tf-btn,
.option-btn,
.options-list label {
    font-size: clamp(0.78rem, 2.2vw, 0.96rem) !important;
    padding: clamp(7px, 1.5vw, 11px) clamp(11px, 2.4vw, 20px) !important;
    border-radius: clamp(6px, 1.2vw, 10px) !important;
    line-height: 1.3 !important;
}

.btn-start, .btn-submit, .btn-clear {
    min-width: clamp(140px, 42vw, 220px) !important;
    margin: clamp(12px, 2.5vw, 20px) auto !important;
}

.btn-mini, .score-chip, .tf-btn {
    font-size: clamp(0.72rem, 1.9vw, 0.84rem) !important;
    padding: clamp(4px, 1vw, 6px) clamp(8px, 1.8vw, 13px) !important;
}

.input-group input,
.input-group select,
.form-group input,
.form-group select,
.filter-bar input,
.filter-bar select,
.search-box input {
    height: clamp(36px, 8.5vw, 42px) !important;
    padding: 0 clamp(9px, 2vw, 13px) !important;
    font-size: clamp(0.8rem, 2.2vw, 0.94rem) !important;
}

/* Thu gọn Cụm nút điều hướng nổi (.ltk-floating-nav) tự động theo màn hình */
.ltk-floating-nav {
    bottom: clamp(8px, 2vw, 16px) !important;
    right: clamp(8px, 2vw, 16px) !important;
    padding: clamp(4px, 1vw, 6px) clamp(6px, 1.4vw, 10px) !important;
    gap: clamp(4px, 1vw, 7px) !important;
}

.ltk-float-btn {
    padding: clamp(5px, 1.1vw, 7px) clamp(8px, 1.8vw, 12px) !important;
    font-size: clamp(0.7rem, 1.9vw, 0.82rem) !important;
    gap: 4px !important;
}

@media screen and (max-width: 640px) {
    .btn-start, .btn-submit, .btn-clear {
        width: 100% !important;
    }
    .ltk-floating-nav {
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
        justify-content: space-between !important;
    }
    .ltk-float-btn {
        flex: 1 1 0 !important;
        padding: 6px 4px !important;
        font-size: clamp(0.68rem, 2.6vw, 0.75rem) !important;
    }
}


/* ==========================================================================
   V22: GIAO DIỆN QUẢN TRỊ & CỔNG ĐĂNG NHẬP 3D MẠNH MẼ (COMMAND CENTER 3D)
   ========================================================================== */
.portal-container,
.container {
    background: linear-gradient(180deg, #F8FAFC 0%, #EFF4FA 100%) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.35) !important;
    box-shadow: 0 24px 50px rgba(2, 6, 23, 0.55), 0 8px 18px rgba(15, 23, 42, 0.25), inset 0 1px 0 #FFFFFF !important;
}

/* 1. Thanh chào mừng Quản trị viên — Nền Dark Emerald/Teal 3D sang trọng */
#authenticatedWorkspace .welcome-banner {
    background: linear-gradient(135deg, #064E3B 0%, #047857 55%, #0F766E 100%) !important;
    border: 1px solid rgba(52, 211, 153, 0.55) !important;
    border-bottom: 4px solid #022C22 !important;
    border-radius: 14px !important;
    padding: 16px 20px !important;
    box-shadow: 0 12px 26px rgba(6, 78, 59, 0.35), inset 0 1.5px 0 rgba(255, 255, 255, 0.25) !important;
    margin-bottom: 18px !important;
}
#authenticatedWorkspace #wsUserTitle {
    color: #FFFFFF !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35) !important;
    font-size: 1.12rem !important;
}
#authenticatedWorkspace #wsUserSub {
    color: #A7F3D0 !important;
    margin-top: 3px !important;
}
#wsAuthActions button,
#wsGuestActions button {
    padding: 7px 14px !important;
    font-size: 0.8rem !important;
    border-radius: 9px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.4), 0 4px 0 rgba(0, 0, 0, 0.35), 0 8px 14px rgba(0, 0, 0, 0.25) !important;
    transition: transform 0.1s ease, box-shadow 0.12s ease, filter 0.12s ease !important;
}
#wsAuthActions button:hover,
#wsGuestActions button:hover {
    transform: translateY(-1.5px) !important;
    filter: brightness(1.08) !important;
}
#wsAuthActions button:active,
#wsGuestActions button:active {
    transform: translateY(2.5px) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(0, 0, 0, 0.35) !important;
}

/* 2. Trung tâm Điều hành Quản trị viên — Nền Dark Navy / Cyber Indigo 3D nổi khối */
#wsStaffPortalBox,
.staff-portal-box {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 55%, #172554 100%) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    border-bottom: 4px solid #020617 !important;
    border-radius: 16px !important;
    padding: 18px 20px !important;
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.42), inset 0 1.5px 0 rgba(148, 163, 184, 0.25) !important;
    margin-bottom: 22px !important;
}
#wsStaffHeading {
    color: #FCD34D !important;
    text-shadow: 0 2px 6px rgba(245, 158, 11, 0.35) !important;
    letter-spacing: 0.02em !important;
    font-size: 1.08rem !important;
}
#wsStaffDesc {
    color: #CBD5E1 !important;
    font-size: 0.86rem !important;
}
#wsStaffPortalBox a {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 15px !important;
    font-size: 0.82rem !important;
    border-radius: 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35) !important;
    transition: transform 0.1s ease, box-shadow 0.14s ease, filter 0.14s ease !important;
}
#wsStaffPortalBox a:nth-of-type(1) {
    background: linear-gradient(180deg, #F59E0B 0%, #B45309 100%) !important;
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 4px 0 #78350F, 0 8px 16px rgba(180, 83, 9, 0.4) !important;
}
#wsStaffPortalBox a:nth-of-type(2) {
    background: linear-gradient(180deg, #38BDF8 0%, #1D4ED8 100%) !important;
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 4px 0 #1E3A8A, 0 8px 16px rgba(29, 78, 216, 0.42) !important;
}
#wsStaffPortalBox a:nth-of-type(3) {
    background: linear-gradient(180deg, #A855F7 0%, #6D28D9 100%) !important;
    box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.45), 0 4px 0 #4C1D95, 0 8px 16px rgba(109, 40, 217, 0.42) !important;
}
#wsStaffPortalBox a:hover {
    transform: translateY(-2px) !important;
    filter: brightness(1.1) !important;
}
#wsStaffPortalBox a:active {
    transform: translateY(2.5px) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 0, 0, 0.4) !important;
}

/* 3. Thẻ 3 Khối học (Khối 10 / 11 / 12) — Nổi khối 3D phân tách màu sắc rõ nét */
.grade-card {
    background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 100%) !important;
    border-radius: 16px !important;
    border: 1.5px solid #CBD5E1 !important;
    border-top: 5px solid #2563EB !important;
    border-bottom: 4px solid #94A3B8 !important;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12), inset 0 1px 0 #FFFFFF !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}
#cardGrade10 {
    border-top-color: #2563EB !important;
    border-bottom-color: #1D4ED8 !important;
}
#cardGrade11 {
    border-top-color: #059669 !important;
    border-bottom-color: #047857 !important;
}
#cardGrade12 {
    border-top-color: #7C3AED !important;
    border-bottom-color: #5B21B6 !important;
}
.grade-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 20px 36px rgba(15, 23, 42, 0.2) !important;
}

/* Sửa lỗi nhãn "🔓 Quyền GV/Admin" bị gãy 2 dòng -> hiển thị 1 dòng gọn gàng */
#badgeGrade10, #badgeGrade11, #badgeGrade12,
#badgeGrade10 span, #badgeGrade11 span, #badgeGrade12 span {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-size: 0.7rem !important;
    padding: 3px 8px !important;
    border-radius: 999px !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* Nút liên kết bài học bên trong mỗi thẻ Khối — Nổi 3D thanh lịch */
.grade-card a {
    background: linear-gradient(180deg, #FFFFFF 0%, #EBF3FE 100%) !important;
    border: 1px solid #BFDBFE !important;
    border-bottom: 3px solid #93C5FD !important;
    border-radius: 10px !important;
    box-shadow: inset 0 1px 0 #FFFFFF, 0 3px 6px rgba(30, 64, 175, 0.08) !important;
    transition: transform 0.1s ease, box-shadow 0.14s ease, background 0.14s ease !important;
}
#cardGrade11 a {
    background: linear-gradient(180deg, #FFFFFF 0%, #ECFDF5 100%) !important;
    border-color: #A7F3D0 !important;
    border-bottom-color: #6EE7B7 !important;
}
#cardGrade12 a {
    background: linear-gradient(180deg, #FFFFFF 0%, #F5F3FF 100%) !important;
    border-color: #DDD6FE !important;
    border-bottom-color: #C4B5FD !important;
}
/* Hiệu ứng Hover 3D rõ nét theo màu từng Khối (nền đậm + chữ trắng tương phản cao, không bị mất chữ) */
.grade-card a:hover,
.grade-links a:hover {
    background: linear-gradient(180deg, #3B82F6 0%, #1D4ED8 100%) !important;
    color: #FFFFFF !important;
    border-color: #60A5FA !important;
    border-bottom-color: #1E3A8A !important;
    transform: translateY(-2px) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 16px rgba(29, 78, 216, 0.35) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
}
#cardGrade11 a:hover {
    background: linear-gradient(180deg, #10B981 0%, #059669 100%) !important;
    color: #FFFFFF !important;
    border-color: #34D399 !important;
    border-bottom-color: #065F46 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 16px rgba(5, 150, 105, 0.35) !important;
}
#cardGrade12 a:hover {
    background: linear-gradient(180deg, #8B5CF6 0%, #6D28D9 100%) !important;
    color: #FFFFFF !important;
    border-color: #A78BFA !important;
    border-bottom-color: #4C1D95 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 16px rgba(109, 40, 217, 0.35) !important;
}
.grade-card a:active {
    transform: translateY(1.5px) !important;
    border-bottom-width: 1px !important;
}

/* V29.0: Căn giữa tuyệt đối nút Xác thực & Vào hệ thống trên trang Đăng nhập */
#btnSubmitLogin,
.btn-login {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 360px !important;
    margin: 14px auto 0 auto !important;
    text-align: center !important;
}

/* ==========================================================================
   V55: ĐỒNG BỘ TƯƠNG PHẢN CAO, CHỐNG TRÀN CODE & ẨN NÚT TRANG CHỦ NỔI
   ========================================================================== */
code:not(pre code) {
    color: #C2410C !important;
    background: #FFEDD5 !important;
    border: 1px solid #FDBA74 !important;
    padding: 1px 5px !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.ltk-floating-nav .home-btn,
.ltk-floating-nav a[href="index.html"] {
    display: none !important;
}


/* ==========================================================================
   V58.2: ĐỔI MÀU MÃ LỆNH INLINE `code` SANG XANH NAVY IN ĐẬM (#1E3A8A)
   - Thay thế nền đỏ/chữ đỏ gây rối mắt bằng Xanh Navy đậm trên nền xanh dịu nhẹ
   ========================================================================== */
code:not(pre code) {
    background: #EFF6FF !important;
    color: #1E3A8A !important;
    border: 1px solid #DBEAFE !important;
    padding: 1px 6px !important;
    border-radius: 4px !important;
    font-weight: 700 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    display: inline !important;
}


/* ==========================================================================
   V62.1: TỰ ĐỘNG ĐIỀU CHỈNH PHÔNG CHỮ, CỠ CHỮ ĐỘNG (FLUID TYPOGRAPHY)
          & CHỐNG RỚT DÒNG CHO NHÃN TRẠNG THÁI, NÚT LỆNH, TIÊU ĐỀ / Ô NGẮN
   ========================================================================== */
body {
    font-family: 'Plus Jakarta Sans', 'Be Vietnam Pro', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: clamp(0.88rem, 1.1vw + 0.65rem, 1rem);
    text-rendering: optimizeLegibility;
}

h1, .top-banner h1 {
    font-size: clamp(1.15rem, 2.6vw, 1.7rem) !important;
    line-height: 1.3 !important;
    text-wrap: balance;
}

h2, .card-title, .panel-card h2 {
    font-size: clamp(0.96rem, 2vw, 1.24rem) !important;
    line-height: 1.35 !important;
    text-wrap: balance;
}

h3 {
    font-size: clamp(0.9rem, 1.7vw, 1.08rem) !important;
    line-height: 1.38 !important;
}

/* Giữ các nhãn trạng thái, huy hiệu, thẻ định hướng, nút điều hướng luôn gọn trên 1 dòng */
.badge,
.ltk-track-pill,
.ltk-track-tag,
.ltk-status-badge,
.status-badge,
.nav-tab-btn,
.ltk-ts-btn,
.ltk-tb-zoom-btn,
.ltk-float-btn,
.score-chip {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    line-height: 1.25 !important;
    font-size: clamp(0.72rem, 1.6vw, 0.84rem) !important;
}

/* Chống rớt dòng cho tiêu đề cột ngắn & ô dữ liệu ngắn trong bảng */
table th {
    font-size: clamp(0.76rem, 1.4vw, 0.9rem) !important;
    white-space: nowrap;
}

table td.ltk-nowrap,
table th.ltk-nowrap,
.ltk-nowrap {
    white-space: nowrap !important;
    word-break: keep-all !important;
}

/* Tự động co cỡ chữ nút bấm để không bị rớt chữ trên màn hình nhỏ */
button:not(.ltk-mm-toggle-btn):not(.btn-start):not(.btn-submit):not(.btn-clear),
.btn-action,
.btn-mini {
    white-space: nowrap;
    font-size: clamp(0.74rem, 1.7vw, 0.88rem) !important;
}


/* ==========================================================================
   V64.3: CHỐNG TRÀN LỀ TOÀN HỆ THỐNG (ĐẶC BIỆT THẺ NĂNG LỰC AI, KHUNG BÀI HỌC)
   ========================================================================== */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

.container,
.main-wrapper,
.card,
.panel-card,
.note-box,
.question-card,
.ltk-khbd-box,
.ltk-khbd-item,
.ltk-ai-activity {
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ltk-khbd-grid > *,
.ltk-ai-steps > *,
.card > * {
    min-width: 0;
}

/* Cho phép mã Năng lực số / Năng lực AI tự động xuống dòng gọn trong khung thẻ */
.ltk-comp-code,
.ltk-comp-code.ltk-ai-code {
    display: inline-block !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
    vertical-align: top !important;
}

pre,
.quiz-code-block,
.code-block {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

img, svg, iframe {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .ltk-khbd-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   V66.1: PHÂN BIỆT RÕ RÀNG GIAO DIỆN PHÒNG ÔN TẬP (XANH NGỌC) vs PHÒNG KIỂM TRA (XANH NAVY)
          & SỬA LỖI CẮT CHỮ .hero-badge TRÊN ĐIỆN THOẠI
   ========================================================================== */
.hero-badge {
    display: inline-block !important;
    max-width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: center !important;
    line-height: 1.38 !important;
    padding: 5px 14px !important;
    box-sizing: border-box !important;
}

/* --- CHẾ ĐỘ 1: PHÒNG ÔN TẬP TRỰC TUYẾN (XANH NGỌC LỤC BẢO - EMERALD) --- */
body.ltk-mode-practice .hero {
    background: linear-gradient(135deg, #ECFDF5 0%, #F0FDF4 65%, #E6FFFA 100%) !important;
    border: 1.5px solid #A7F3D0 !important;
    border-top: 5px solid #059669 !important;
    border-bottom: 2.5px solid #10B981 !important;
}
body.ltk-mode-practice .hero-badge {
    background: #047857 !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 8px rgba(4, 120, 87, 0.25);
}
body.ltk-mode-practice .hero h1,
body.ltk-mode-practice #exam-header-title {
    color: #065F46 !important;
}
body.ltk-mode-practice .hero p {
    color: #047857 !important;
    font-weight: 600;
}
body.ltk-mode-practice .card-title {
    background: linear-gradient(90deg, #DCFCE7 0%, #F0FDF4 100%) !important;
    border-left: 5px solid #059669 !important;
    color: #065F46 !important;
}
body.ltk-mode-practice .note-box {
    border-left-color: #059669 !important;
}
body.ltk-mode-practice .btn-start {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.32) !important;
}
body.ltk-mode-practice .btn-start:hover {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
}
body.ltk-mode-practice #exam-status-bar {
    background: #064E3B !important;
    border-bottom: 2.5px solid #10B981 !important;
}

/* --- CHẾ ĐỘ 2: PHÒNG KIỂM TRA CHÍNH THỨC (XANH NAVY - OFFICIAL EXAM) --- */
body.ltk-mode-exam .hero {
    background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 65%, #DBEAFE 100%) !important;
    border: 1.5px solid #93C5FD !important;
    border-top: 5px solid #1E3A8A !important;
    border-bottom: 2.5px solid #1E40AF !important;
}
body.ltk-mode-exam .hero-badge {
    background: #1E3A8A !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.28);
}
body.ltk-mode-exam .hero h1,
body.ltk-mode-exam #exam-header-title {
    color: #1E3A8A !important;
}
body.ltk-mode-exam .hero p {
    color: #1E40AF !important;
    font-weight: 600;
}
body.ltk-mode-exam .card-title {
    background: linear-gradient(90deg, #DBEAFE 0%, #EFF6FF 100%) !important;
    border-left: 5px solid #1E3A8A !important;
    color: #1E3A8A !important;
}
body.ltk-mode-exam .note-box {
    border-left-color: #1E3A8A !important;
}
body.ltk-mode-exam .btn-start {
    background: linear-gradient(135deg, #1E3A8A 0%, #172554 100%) !important;
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.34) !important;
}
body.ltk-mode-exam .btn-start:hover {
    background: linear-gradient(135deg, #1D4ED8 0%, #1E3A8A 100%) !important;
}
body.ltk-mode-exam #exam-status-bar {
    background: #0F172A !important;
    border-bottom: 2.5px solid #3B82F6 !important;
}


/* ==========================================================================
   V67.3: KHẮC PHỤC TRIỆT ĐỂ LỖI HIỂN THỊ TRÊN DI ĐỘNG TOÀN HỆ THỐNG
   1. Danh mục Ôn tập / Kiểm tra (.lesson-item) chuyển Thẻ 2 tầng gọn đẹp (<= 720px)
      -> Không bao giờ bị bóp tên bài thành từng chữ xếp dọc!
   2. Thanh điều hướng nổi (.ltk-floating-nav) căn giữa khi ít nút & vuốt ngang mượt khi nhiều nút
      -> Không bao giờ bị cắt nút ở 2 mép trái/phải!
   3. Lưới biểu mẫu nhiều cột (.ltk-mob-stack) tự xếp 1 cột trên điện thoại (<= 680px)
   ========================================================================== */
.ltk-floating-nav {
    max-width: calc(100vw - 16px) !important;
    box-sizing: border-box !important;
}

@media (max-width: 720px) {
    /* 1. Thẻ Ôn tập & Kiểm tra trên Mục lục 10/11/12: Bố cục 2 tầng (Tầng 1: Tiêu đề 100%, Tầng 2: Kỳ + Trạng thái + Thời lượng + Mũi tên) */
    #ltk-review-list-core .lesson-item,
    #ltk-exam-list-core .lesson-item,
    #ltk-dynamic-exams-list .lesson-item,
    .lesson-item:has(.ltk-exam-state-slot) {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        row-gap: 8px !important;
        column-gap: 8px !important;
        padding: 12px 12px !important;
    }

    #ltk-review-list-core .lesson-item .lesson-name,
    #ltk-exam-list-core .lesson-item .lesson-name,
    #ltk-dynamic-exams-list .lesson-item .lesson-name,
    .lesson-item:has(.ltk-exam-state-slot) .lesson-name {
        order: 1 !important;
        flex: 1 0 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.94rem !important;
        font-weight: 700 !important;
        line-height: 1.45 !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    #ltk-review-list-core .lesson-item .lesson-num,
    #ltk-exam-list-core .lesson-item .lesson-num,
    #ltk-dynamic-exams-list .lesson-item .lesson-num,
    .lesson-item:has(.ltk-exam-state-slot) .lesson-num {
        order: 2 !important;
        min-width: auto !important;
        flex-shrink: 0 !important;
        font-size: 0.78rem !important;
        padding: 3px 8px !important;
        border-radius: 6px !important;
        background: #EFF6FF !important;
        border: 1px solid #BFDBFE !important;
        color: #1E3A8A !important;
    }

    #ltk-review-list-core .lesson-item .ltk-exam-state-slot,
    #ltk-exam-list-core .lesson-item .ltk-exam-state-slot,
    #ltk-dynamic-exams-list .lesson-item .ltk-exam-state-slot,
    .lesson-item:has(.ltk-exam-state-slot) .ltk-exam-state-slot {
        order: 3 !important;
        flex-shrink: 0 !important;
        max-width: 100% !important;
    }

    #ltk-review-list-core .lesson-item .ltk-exam-state-slot .ltk-status-badge,
    #ltk-exam-list-core .lesson-item .ltk-exam-state-slot .ltk-status-badge,
    #ltk-dynamic-exams-list .lesson-item .ltk-exam-state-slot .ltk-status-badge {
        font-size: 0.73rem !important;
        padding: 3px 8px !important;
        white-space: nowrap !important;
    }

    #ltk-review-list-core .lesson-item .page-num,
    #ltk-exam-list-core .lesson-item .page-num,
    #ltk-dynamic-exams-list .lesson-item .page-num,
    .lesson-item:has(.ltk-exam-state-slot) .page-num {
        order: 4 !important;
        margin-right: 0 !important;
        font-size: 0.78rem !important;
        color: #475569 !important;
        white-space: nowrap !important;
    }

    #ltk-review-list-core .lesson-item .icon-link,
    #ltk-exam-list-core .lesson-item .icon-link,
    #ltk-dynamic-exams-list .lesson-item .icon-link,
    .lesson-item:has(.ltk-exam-state-slot) .icon-link {
        order: 5 !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }

    /* Bảo vệ các dòng bài học thông thường (Bài 1–34) trên màn hình nhỏ không bao giờ bị bóp chữ */
    .lesson-item {
        flex-wrap: wrap !important;
        row-gap: 4px !important;
    }
    .lesson-item .lesson-name {
        flex: 1 1 160px !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    /* 2. Thanh điều hướng nổi (.ltk-floating-nav): căn giữa khi ít nút, vuốt ngang mượt từ nút đầu tiên khi nhiều nút */
    .ltk-floating-nav {
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
        width: auto !important;
        max-width: calc(100vw - 16px) !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding: 6px 8px !important;
        gap: 6px !important;
    }
    .ltk-floating-nav::-webkit-scrollbar {
        display: none !important;
    }
    .ltk-floating-nav::before,
    .ltk-floating-nav::after {
        content: "";
        margin: auto;
        flex: 0 0 0px;
    }
    .ltk-floating-nav .ltk-float-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }
}

/* 3. Lưới biểu mẫu nhiều cột trên các trang Quản trị & Đăng nhập tự động xếp 1 cột gọn trên điện thoại */
@media (max-width: 680px) {
    .ltk-mob-stack {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .ltk-mob-stack > * {
        min-width: 0 !important;
    }
}
