    :root {
        --color-locked: #95a5a6;
        --color-unlocked: #f1c40f;
        --color-passed: #2ecc71;
        --color-failed: #e74c3c;
        --color-bg: #eaf6ff;
        --color-primary: #2d7dd2;
        --color-accent: #ff8c42;
        --radius: 18px;
    }
    * { box-sizing: border-box; }
    body {
        margin: 0;
        /* Font Times New Roman (Tinos/Liberation Serif là bản thay thế cùng số đo
           trên Android/Linux, có đủ dấu tiếng Việt) — dùng chung cho cả trang
           học sinh (index.php) và trang giáo viên (giaovien.php, đặt thêm
           class="teacher-app" trên <body> nhưng không cần override font vì
           đã dùng chung font này). Vì hầu hết input/button/textarea trong
           style.css đã khai báo font-family: inherit nên toàn bộ giao diện
           (kể cả .feedback-box) tự động dùng đúng font này. */
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        background: linear-gradient(180deg, #cdeffd 0%, #eaf6ff 45%, #fff8e7 100%);
        color: #24324a;
        min-height: 100vh;
    }
    header {
        background: linear-gradient(90deg, var(--color-primary), #57b0ff);
        color: #fff;
        padding: 18px 24px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    }
    header h1 {
        margin: 0;
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .student-box {
        display: flex;
        align-items: center;
        gap: 8px;
        background: rgba(255,255,255,0.18);
        padding: 8px 14px;
        border-radius: 999px;
    }
    .student-box input {
        border: none;
        border-radius: 999px;
        padding: 8px 14px;
        font-size: 1rem;
        font-family: inherit;
        outline: none;
        width: 160px;
    }
    nav.tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 10px 24px 0;
        max-width: 1200px;
        margin: 0 auto;
        border-bottom: 1px solid rgba(45,125,210,0.15);
    }
    nav.tabs button,
    nav.tabs .tab-link-btn {
        border: none;
        background: transparent;
        color: #5a6c85;
        padding: 12px 20px;
        border-radius: 10px 10px 0 0;
        font-weight: 700;
        font-size: 0.95rem;
        cursor: pointer;
        font-family: inherit;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        line-height: 1;
        border-bottom: 3px solid transparent;
        transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    nav.tabs button:hover {
        background: rgba(45,125,210,0.08);
        color: var(--color-primary);
    }
    nav.tabs button.active {
        background: #ffffffee;
        color: var(--color-primary);
        border-bottom-color: var(--color-primary);
    }
    nav.tabs .tab-link-btn {
        text-decoration: none;
    }
    main {
        padding: 20px 24px 60px;
        max-width: 1200px;
        margin: 0 auto;
    }
    .panel {
        background: #ffffffee;
        border-radius: var(--radius);
        box-shadow: 0 8px 24px rgba(30,80,150,0.12);
        padding: 20px;
    }
    .hidden { display: none !important; }

    /* ---------------------------------------------------------------
       LỘ TRÌNH HỌC TẬP (roadmap) — thay cho bản đồ vẽ trên canvas với
       các mũi tên cong. Bố cục dạng danh sách theo học kỳ, chuyên
       nghiệp và có tổ chức: mỗi thẻ chủ đề tự nêu rõ "cần hoàn thành
       trước" bằng chữ/nhãn thay vì vẽ đường nối, nên không cần mũi tên
       mà vẫn thể hiện đầy đủ thứ tự tiên quyết.
       ------------------------------------------------------------- */
    .map-intro { margin-bottom: 18px; }
    .map-title-row {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 4px;
    }
    .map-title {
        margin: 0;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        font-size: 1.3rem;
        font-weight: 700;
        color: #0f172a;
        letter-spacing: -0.01em;
    }
    .map-info-btn {
        flex-shrink: 0;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        border: 1.5px solid #cbd5e1;
        background: #f8fafc;
        color: #64748b;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        font-size: 0.72rem;
        font-weight: 700;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    .map-info-btn:hover {
        background: #2563eb;
        border-color: #2563eb;
        color: #ffffff;
    }
    .map-subtitle {
        margin: 0;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        font-size: 0.9rem;
        color: #64748b;
    }
    .map-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 18px;
        margin-bottom: 24px;
        padding-bottom: 18px;
        border-bottom: 1px solid #e2e8f0;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
    }
    .map-legend-item {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        font-size: 0.83rem;
        font-weight: 600;
        color: #475569;
    }
    .map-legend-dot {
        width: 9px;
        height: 9px;
        border-radius: 3px;
        display: inline-block;
    }
    .map-error-box {
        margin: 0 0 20px;
        padding: 14px 18px;
        background: #fef2f2;
        border: 1px solid #fecaca;
        border-radius: 10px;
        color: #b91c1c;
        font-weight: 600;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        text-align: left;
    }

    .roadmap {
        display: flex;
        flex-direction: column;
        gap: 36px;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
    }
    .roadmap-term-header {
        display: flex;
        align-items: baseline;
        gap: 10px;
        margin-bottom: 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid #e2e8f0;
    }
    .roadmap-term-title {
        margin: 0;
        font-size: 1.02rem;
        font-weight: 700;
        color: #0f172a;
    }
    .roadmap-term-caption {
        font-size: 0.82rem;
        font-weight: 600;
        color: #64748b;
    }
    .roadmap-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .topic-card {
        display: flex;
        align-items: center;
        gap: 14px;
        width: 100%;
        text-align: left;
        padding: 14px 16px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: #ffffff;
        cursor: pointer;
        font-family: inherit;
        transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    }
    .topic-card:hover {
        border-color: #94a3b8;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
        transform: translateY(-1px);
    }
    .topic-card.status-locked {
        cursor: not-allowed;
        background: #f8fafc;
    }
    .topic-card.status-locked:hover {
        border-color: #e2e8f0;
        box-shadow: none;
        transform: none;
    }
    .topic-card-status {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.05rem;
        font-weight: 700;
        color: #ffffff;
    }
    .topic-card.status-locked .topic-card-status { background: #94a3b8; }
    .topic-card.status-unlocked .topic-card-status { background: #2563eb; }
    .topic-card.status-passed .topic-card-status { background: #16a34a; }
    .topic-card-body {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .topic-card-name {
        font-size: 0.94rem;
        font-weight: 700;
        color: #0f172a;
        line-height: 1.4;
    }
    .topic-card.status-locked .topic-card-name { color: #64748b; }
    .topic-card-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        font-size: 0.78rem;
        color: #64748b;
        font-weight: 600;
    }
    .topic-card-req-label { color: #94a3b8; font-weight: 600; }
    .topic-card-plain-meta { color: #64748b; }
    .topic-card-level-badge {
        display: inline-flex;
        align-items: center;
        padding: 2px 10px;
        border-radius: 999px;
        color: #ffffff;
        font-weight: 700;
        font-size: 0.72rem;
    }
    .topic-card-chevron {
        flex-shrink: 0;
        font-size: 1.15rem;
        color: #cbd5e1;
    }
    @media (max-width: 640px) {
        .topic-card { padding: 12px; gap: 10px; }
        .topic-card-status { width: 32px; height: 32px; font-size: 0.95rem; }
    }

    /* Popup giải thích "vì sao chủ đề không mở toàn bộ" — style chuyên
       nghiệp, trung tính, tách biệt hoàn toàn với các modal viền vàng
       kiểu trẻ em còn lại trong ứng dụng. */
    .info-modal {
        position: relative;
        max-width: 520px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
        padding: 32px 28px 24px;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
    }
    .info-modal-close {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 30px;
        height: 30px;
        border: none;
        background: #f1f5f9;
        color: #64748b;
        border-radius: 50%;
        font-size: 1.1rem;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .info-modal-close:hover { background: #e2e8f0; color: #0f172a; }
    .info-modal-header {
        display: flex;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 22px;
        padding-right: 24px;
    }
    .info-modal-icon {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: #eff6ff;
        color: #2563eb;
        font-weight: 700;
        font-style: italic;
        font-size: 1.15rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .info-modal-title {
        margin: 0 0 4px;
        font-size: 1.1rem;
        font-weight: 700;
        color: #0f172a;
        letter-spacing: -0.01em;
    }
    .info-modal-subtitle {
        margin: 0;
        font-size: 0.85rem;
        color: #64748b;
    }
    .info-modal-list {
        list-style: none;
        margin: 0 0 24px;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 18px;
    }
    .info-modal-item {
        display: flex;
        gap: 14px;
    }
    .info-modal-item-icon {
        flex-shrink: 0;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: #f1f5f9;
        color: #2563eb;
        font-weight: 700;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .info-modal-item-body h3 {
        margin: 0 0 4px;
        font-size: 0.92rem;
        font-weight: 700;
        color: #0f172a;
    }
    .info-modal-item-body p {
        margin: 0;
        font-size: 0.85rem;
        line-height: 1.55;
        color: #475569;
    }
    .info-modal .modal-actions {
        justify-content: flex-end;
        border-top: 1px solid #e2e8f0;
        padding-top: 18px;
        margin: 0;
    }
    @media (max-width: 480px) {
        .info-modal { padding: 24px 18px 18px; }
        .info-modal-header { padding-right: 18px; }
    }

    .toast {
        position: fixed;
        top: 20px;
        right: 20px;
        background: var(--color-primary);
        color: #fff;
        padding: 14px 20px;
        border-radius: 12px;
        box-shadow: 0 6px 18px rgba(0,0,0,0.2);
        font-weight: 700;
        z-index: 999;
        max-width: 320px;
        animation: fadein 0.25s ease-out;
    }
    @keyframes fadein { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

    /* Modal */
    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(20, 40, 70, 0.55);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 500;
        padding: 16px;
    }
    .modal {
        background: #fffef6;
        border-radius: 24px;
        max-width: 850px;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 26px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.3);
        border: 6px solid var(--color-accent);
    }
    .modal h2 {
        margin-top: 0;
        color: var(--color-primary);
        font-size: 1.3rem;
    }
    .progress-pill {
        display: inline-block;
        background: var(--color-primary);
        color: #fff;
        font-weight: 700;
        border-radius: 999px;
        padding: 4px 14px;
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
    .question-text {
        font-size: 1.25rem;
        font-weight: 700;
        margin: 12px 0 18px;
        line-height: 1.4;
    }
    .exercise-area.locked { pointer-events: none; opacity: 0.85; }
    .options-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    @media (max-width: 480px) {
        .options-grid { grid-template-columns: 1fr; }
    }
    .option-btn {
        font-family: inherit;
        font-size: 1.05rem;
        font-weight: 600;
        padding: 14px 12px;
        border: 3px solid #cfe3f7;
        background: #f4faff;
        border-radius: 14px;
        cursor: pointer;
        transition: transform 0.1s, background 0.2s, border-color 0.2s;
        text-align: center;
    }
    .option-btn:hover:not(:disabled) {
        transform: translateY(-2px);
        border-color: var(--color-primary);
    }
    .option-btn:disabled { cursor: default; opacity: 0.85; }
    .option-btn.correct { background: #d7f7e1; border-color: var(--color-passed); }
    .option-btn.wrong { background: #fde0de; border-color: var(--color-failed); }

    /* Canvas-based exercises (visual comparison / click-the-shape) */
    .exercise-canvas {
        display: block;
        margin: 10px auto 0;
        max-width: 100%;
        height: auto;
        border-radius: 14px;
        border: 3px solid #cfe3f7;
        background: #fff;
        cursor: pointer;
    }
    /* Khung bọc canvas hình học — KHÔNG cuộn ngang: modal tự nới rộng cho vừa
       canvas (xem setQuizModalFitWidth() ở index.php); trên màn hình hẹp,
       canvas co lại đúng tỉ lệ nhờ max-width:100% + height:auto. */
    .exercise-canvas-frame {
        overflow: hidden;
        margin: 10px auto 0;
        border-radius: 14px;
    }
    .exercise-canvas-frame .exercise-canvas { margin: 0 auto; }
    #quizOverlay .modal { transition: max-width 0.2s ease; }
    .exercise-hint { text-align: center; color: #5a6c85; font-weight: 600; font-size: 0.9rem; margin-top: 8px; }

    .feedback-box {
        margin-top: 16px;
        padding: 14px 16px;
        border-radius: 14px;
        font-weight: 600;
        line-height: 1.4;
        display: none;
        /* Lời giải thích AI chi tiết trả về nhiều dòng (từng bước một dòng);
           pre-line giữ nguyên các dòng đó mà vẫn tự xuống dòng khi quá dài. */
        white-space: pre-line;
        /* font-family kế thừa từ body (đã là font hệ thống chuẩn chỉnh). */
    }
    .feedback-box.show { display: block; }
    .feedback-box.ok { background: #d7f7e1; color: #1c7a41; }
    .feedback-box.bad { background: #fde0de; color: #a3251b; }
    .feedback-box.loading { background: #f4faff; color: #24324a; }

    /* Nút "Vẫn khó hiểu? Nhờ AI giải thích chi tiết hơn" — chỉ xuất hiện khi
       giáo viên đã bật AI cho đúng node/lớp/học sinh/loại lượt làm bài này
       (xem submitAnswer()/askAiExplainMore() ở index.php). Đặt trong chính
       feedback-box (dưới dòng giải thích rule-based) nên kế thừa white-space:
       pre-line của nó, cần display:block để tự xuống dòng riêng. */
    .ai-explain-btn {
        display: block;
        margin-top: 12px;
        font-family: inherit;
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--color-primary);
        background: #fff;
        border: 2px solid var(--color-primary);
        border-radius: 999px;
        padding: 8px 16px;
        cursor: pointer;
        white-space: normal;
        transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    }
    .ai-explain-btn:hover:not(:disabled) {
        background: var(--color-primary);
        color: #fff;
        transform: translateY(-1px);
    }
    .ai-explain-btn:disabled { opacity: 0.6; cursor: default; }

    /* Thanh tiến trình hiển thị khi đang chờ AI soạn lời giải thích chi tiết */
    .ai-loading { display: flex; flex-direction: column; gap: 10px; }
    .ai-loading-text {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 700;
        color: var(--color-primary);
    }
    .ai-loading-emoji { animation: ai-loading-bounce 1s ease-in-out infinite; display: inline-block; }
    @keyframes ai-loading-bounce {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-4px); }
    }
    .ai-progress-track {
        width: 100%;
        height: 10px;
        border-radius: 999px;
        background: #e3edf7;
        overflow: hidden;
        position: relative;
    }
    .ai-progress-fill {
        position: absolute;
        top: 0;
        left: -40%;
        height: 100%;
        width: 40%;
        border-radius: 999px;
        background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
        animation: ai-progress-slide 1.1s ease-in-out infinite;
    }
    @keyframes ai-progress-slide {
        0% { left: -40%; }
        100% { left: 100%; }
    }
    .modal-actions {
        display: flex;
        justify-content: space-between;
        margin-top: 20px;
        gap: 10px;
    }
    .btn {
        font-family: inherit;
        border: none;
        border-radius: 999px;
        padding: 12px 22px;
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
    }
    .btn-primary { background: var(--color-primary); color: #fff; }
    .btn-primary:disabled { background: #b7cee6; cursor: not-allowed; }
    .btn-ghost { background: #eee; color: #555; }
    .summary-box {
        text-align: center;
        padding: 10px 0;
    }

    /* Sub-node popup: shows a node's small parts as a grid of gently
       rotating badges instead of cluttering the canvas. */
    .subnode-modal { border-color: var(--color-primary); max-width: 620px; }
    .subnode-modal-desc {
        margin: 0 0 6px;
        color: #5a6c85;
        font-weight: 600;
        font-size: 0.95rem;
    }
    .subnode-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
        gap: 14px;
        margin: 14px 0 6px;
    }
    .subnode-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-align: center;
        padding: 12px 8px 14px;
        border-radius: 18px;
        cursor: pointer;
        background: #f4faff;
        border: 2px solid transparent;
        transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
    }
    .subnode-card:hover {
        transform: translateY(-3px);
        background: #eaf4ff;
        border-color: rgba(45,125,210,0.35);
    }
    .subnode-card.done { background: #eafcf1; }
    .subnode-card.done:hover { border-color: rgba(46,204,113,0.4); }
    .subnode-card.synth-card { background: #fff7e0; }
    .subnode-card.synth-card:hover { border-color: rgba(241,196,15,0.5); }
    .subnode-card.synth-card.done { background: #eafcf1; }
    .subnode-card.locked { cursor: not-allowed; opacity: 0.55; }
    .subnode-card.locked:hover { transform: none; background: #f4faff; border-color: transparent; }
    .subnode-icon-wrap {
        position: relative;
        width: 58px;
        height: 58px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .subnode-icon-wrap::before {
        content: '';
        position: absolute;
        inset: -7px;
        border-radius: 50%;
        border: 3px dashed rgba(241,196,15,0.55);
        animation: subnode-spin 8s linear infinite;
    }
    .subnode-card.done .subnode-icon-wrap::before {
        border-color: rgba(46,204,113,0.55);
        animation-duration: 18s;
    }
    @keyframes subnode-spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    .subnode-icon {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        font-weight: 800;
        color: #fff;
        background: linear-gradient(145deg, #ffe27a, var(--color-unlocked));
        box-shadow: 0 6px 14px rgba(241,196,15,0.45);
    }
    .subnode-card.done .subnode-icon {
        background: linear-gradient(145deg, #8cefb2, var(--color-passed));
        box-shadow: 0 6px 14px rgba(46,204,113,0.45);
    }
    .subnode-name {
        font-size: 0.86rem;
        font-weight: 800;
        color: #24324a;
    }
    .subnode-status {
        font-size: 0.74rem;
        font-weight: 700;
        color: var(--color-primary);
        line-height: 1.3;
    }
    .subnode-card.done .subnode-status { color: #1c7a41; }
    .summary-box .big-emoji { font-size: 3rem; margin-bottom: 6px; }

    /* Practice-vs-challenge choice popup, shown when a sub-node card is clicked */
    .choice-modal { max-width: 440px; }
    .choice-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 16px 0 4px;
    }
    .choice-option {
        display: flex;
        align-items: center;
        gap: 14px;
        width: 100%;
        padding: 14px 16px;
        border-radius: 16px;
        border: 2px solid transparent;
        background: #f4faff;
        cursor: pointer;
        text-align: left;
        transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
        font-family: inherit;
    }
    .choice-option:hover { transform: translateY(-2px); }
    .choice-option--challenge:hover { background: #fff8e1; border-color: rgba(241,196,15,0.55); }
    .choice-option--practice:hover { background: #eafcf1; border-color: rgba(46,204,113,0.45); }
    .choice-option--relaxed:hover { background: #eafcf1; border-color: rgba(46,204,113,0.45); }
    .choice-option--timed:hover { background: #fdeee9; border-color: rgba(231,76,60,0.45); }
    .quiz-timer {
        display: inline-block;
        margin-left: 8px;
        padding: 2px 10px;
        border-radius: 999px;
        background: #fdeee9;
        color: #c0392b;
        font-size: 0.75rem;
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .quiz-timer.danger { background: #e74c3c; color: #fff; }

    /* Thẻ chọn bậc luyện tập (Nhận biết → Thông hiểu → Vận dụng → Vận dụng cao) */
    .choice-option--level {
        border-left: 6px solid var(--level-color, #f1c40f);
        justify-content: space-between;
    }
    .choice-option--level.is-locked {
        background: #f3f4f6;
        border-left-color: #cbd5e1;
        cursor: not-allowed;
        opacity: 0.75;
    }
    .choice-option--level.is-locked:hover { transform: none; }
    .choice-option--level.is-locked .choice-option-title { color: #64748b; }
    .level-achieved-tag,
    .level-current-tag {
        margin-left: auto;
        font-weight: 800;
        font-size: 0.75rem;
        padding: 3px 10px;
        border-radius: 999px;
        white-space: nowrap;
    }
    .level-achieved-tag {
        background: #eafcf1;
        color: #1c7a41;
    }
    .level-current-tag {
        background: #e8f0fe;
        color: #1e40af;
    }
    .summary-next-tier {
        margin: 6px auto 10px;
        padding: 8px 14px;
        max-width: 460px;
        border-radius: 12px;
        background: #eafcf1;
        color: #1c7a41;
        font-weight: 700;
    }

    /* Teacher: pass-level configuration editor */
    .level-config-panel {
        margin: 26px 0;
        padding: 18px;
        border-radius: 16px;
        background: #f4faff;
        border: 2px solid #dceafc;
    }
    .level-config-panel h3 { margin: 0 0 6px; color: var(--color-primary); }
    .level-config-toolbar { display: flex; align-items: center; gap: 10px; margin: 10px 0 16px; }
    .level-config-toolbar select {
        font-family: inherit;
        font-size: 0.95rem;
        padding: 8px 12px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
        min-width: 260px;
    }
    .level-config-row {
        display: grid;
        grid-template-columns: 90px 1.4fr 1fr 1fr 1fr 40px;
        gap: 10px;
        align-items: center;
        background: #fff;
        border-radius: 12px;
        padding: 10px 12px;
        margin-bottom: 8px;
        border: 2px solid #e3edf7;
    }
    .level-config-row input[type="text"],
    .level-config-row input[type="number"] {
        font-family: inherit;
        font-size: 0.9rem;
        padding: 7px 9px;
        border-radius: 8px;
        border: 2px solid #cfe3f7;
        width: 100%;
        box-sizing: border-box;
    }
    .level-config-row input[type="color"] { width: 46px; height: 34px; border-radius: 8px; border: 2px solid #cfe3f7; padding: 2px; cursor: pointer; }
    .level-config-row .lc-field { display: flex; flex-direction: column; gap: 3px; }
    .level-config-row .lc-field label { font-size: 0.68rem; font-weight: 700; color: #5a6c85; }
    .level-config-row .lc-remove { background: #fde0de; color: #a3251b; border: none; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-weight: 800; }
    @media (max-width: 760px) {
        .level-config-row { grid-template-columns: 1fr 1fr; }
    }
    .practice-tally {
        display: flex;
        gap: 14px;
        justify-content: center;
        margin: 4px 0 10px;
        font-weight: 700;
        font-size: 0.9rem;
    }
    .practice-tally .tally-ok { color: #1c7a41; }
    .practice-tally .tally-bad { color: #c0392b; }
    .choice-option-icon { font-size: 1.9rem; flex: 0 0 auto; }
    .choice-option-text { display: flex; flex-direction: column; gap: 2px; }
    .choice-option-title { font-size: 1rem; font-weight: 800; color: #24324a; }
    .choice-option-desc { font-size: 0.8rem; font-weight: 600; color: #5a6c85; }
    .practice-pill {
        display: inline-block;
        margin-left: 8px;
        padding: 2px 10px;
        border-radius: 999px;
        background: #eafcf1;
        color: #1c7a41;
        font-size: 0.75rem;
        font-weight: 800;
    }

    /* Dashboard */
    table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 26px;
        font-size: 0.95rem;
    }
    table caption {
        text-align: left;
        font-weight: 700;
        color: var(--color-primary);
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    th, td {
        text-align: left;
        padding: 10px 12px;
        border-bottom: 1px solid #e3edf7;
    }
    th { background: #f0f7ff; color: var(--color-primary); }
    tbody tr:hover { background: #f7fbff; }
    td code {
        font-family: "SFMono-Regular", Consolas, monospace;
        font-size: 0.82rem;
        font-weight: 700;
        background: #eef3fa;
        color: #3d5a80;
        padding: 2px 8px;
        border-radius: 6px;
    }
    .col-switch { width: 110px; text-align: center; }
    .status-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 10px 20px;
        margin: -6px 0 18px;
    }
    .status-legend .legend-item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 0.82rem;
        font-weight: 700;
        color: #5a6c85;
    }
    .status-legend .status-dot { width: 8px; height: 8px; border-radius: 50%; }
    .bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
    .bar-label { width: 190px; font-weight: 700; flex-shrink: 0; font-size: 0.9rem; }
    .bar-track { flex: 1; background: #eef3fa; border-radius: 999px; height: 18px; overflow: hidden; }
    .bar-fill { height: 100%; border-radius: 999px; background: var(--color-accent); transition: width 0.4s; }
    .bar-count { width: 34px; text-align: right; font-weight: 700; }
    .status-tag {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 5px 12px 5px 10px;
        border-radius: 999px;
        font-size: 0.8rem;
        font-weight: 700;
        line-height: 1.4;
        white-space: nowrap;
    }
    .status-tag .status-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    .status-tag.status-locked { background: #eef1f6; color: #64748b; }
    .status-tag.status-locked .status-dot { background: #94a3b8; }
    .status-tag.status-unlocked { background: #fff6e0; color: #a06c00; }
    .status-tag.status-unlocked .status-dot { background: #f1c40f; }
    .status-tag.status-passed { background: #eafcf1; color: #1c7a41; }
    .status-tag.status-passed .status-dot { background: #2ecc71; }
    .status-tag.status-failed { background: #fde0de; color: #a3251b; }
    .status-tag.status-failed .status-dot { background: #e74c3c; }

    /* ---- Lịch sử của em (student history) ---- */
    .history-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 14px;
        margin-bottom: 22px;
    }
    .history-stat-card {
        flex: 1 1 120px;
        background: linear-gradient(160deg, #f0f7ff 0%, #eaf6ff 100%);
        border: 2px solid #d8ecfb;
        border-radius: 16px;
        padding: 14px 10px;
        text-align: center;
    }
    .history-stat-num { font-size: 1.6rem; font-weight: 800; color: var(--color-primary); }
    .history-stat-label { font-size: 0.8rem; font-weight: 700; color: #5a6c85; margin-top: 2px; }
    .history-error-stats {
        background: #fffdf5;
        border: 2px solid #ffe6b3;
        border-radius: 16px;
        padding: 16px 18px;
    }
    .history-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
    .history-pagination {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        margin-top: 16px;
    }
    .history-page-btn {
        border: 2px solid #e3ecf7;
        background: #fff;
        color: var(--color-primary);
        font-weight: 800;
        font-size: 0.85rem;
        padding: 7px 16px;
        border-radius: 999px;
        cursor: pointer;
        transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    }
    .history-page-btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 6px 14px rgba(30,80,150,0.12);
        border-color: var(--color-primary);
    }
    .history-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
    .history-page-info { font-size: 0.85rem; font-weight: 700; color: #5a6c85; white-space: nowrap; }
    .history-card {
        background: #fff;
        border: 2px solid #e3ecf7;
        border-radius: 16px;
        padding: 14px 16px;
        cursor: pointer;
        transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    }
    .history-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 18px rgba(30,80,150,0.12);
        border-color: var(--color-primary);
    }
    .history-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 6px;
    }
    .history-mode { font-weight: 800; color: #24324a; }
    .history-badge {
        padding: 3px 12px;
        border-radius: 999px;
        font-size: 0.78rem;
        font-weight: 800;
        white-space: nowrap;
    }
    .history-badge--pass { background: #eafcf1; color: #1c7a41; }
    .history-badge--fail { background: #fdeee9; color: #b3401f; }
    .history-badge--practice { background: #eef3fa; color: #3d5a80; }
    .history-node-name { font-weight: 700; color: var(--color-primary); margin-bottom: 8px; }
    .history-card-bottom {
        display: flex;
        gap: 16px;
        flex-wrap: wrap;
        font-size: 0.85rem;
        font-weight: 600;
        color: #5a6c85;
    }
    .history-detail-modal { max-width: 640px; }
    .history-detail-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
    .history-answer-row {
        border-radius: 14px;
        border: 2px solid #e3ecf7;
        padding: 12px 14px;
    }
    .history-answer--ok { border-color: #bbe8cc; background: #f3fdf6; }
    .history-answer--bad { border-color: #f6c9bb; background: #fff6f3; }
    .history-answer-head {
        display: flex;
        justify-content: space-between;
        font-weight: 800;
        margin-bottom: 6px;
        font-size: 0.85rem;
        color: #5a6c85;
    }
    .history-answer-prompt { font-weight: 700; color: #24324a; margin-bottom: 6px; }
    .history-answer-line { font-size: 0.9rem; margin-bottom: 3px; }
    .history-answer-tag {
        display: inline-block;
        margin-top: 4px;
        font-size: 0.8rem;
        font-weight: 700;
        color: #b3401f;
        background: #fdeee9;
        padding: 2px 10px;
        border-radius: 999px;
    }
    .history-answer-feedback { margin-top: 6px; font-size: 0.85rem; color: #3d5a80; font-style: italic; }

    /* ---- Footer: khối thông tin đề tài, tách bạch với nội dung chính bằng
       viền gradient trên + nền kính mờ, thay vì 1 dòng chữ đơn điệu. ---- */
    .site-footer {
        position: relative;
        z-index: 1;
        margin-top: 48px;
        padding: 34px 24px 28px;
        text-align: center;
        background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.85));
        border-top: 3px solid transparent;
        border-image: linear-gradient(90deg, var(--color-primary), var(--color-accent)) 1;
        backdrop-filter: blur(6px);
    }
    .site-footer-inner { max-width: 720px; margin: 0 auto; }
    .site-footer-badge {
        display: inline-block;
        margin-bottom: 12px;
        padding: 5px 16px;
        border-radius: 999px;
        background: rgba(45,125,210,0.12);
        color: var(--color-primary);
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }
    .site-footer-desc {
        margin: 0;
        color: #4a5b74;
        font-size: 0.92rem;
        line-height: 1.7;
    }
    .site-footer-desc strong { color: #24324a; font-weight: 700; }
    .site-footer-divider {
        width: 52px;
        height: 3px;
        margin: 18px auto;
        border-radius: 999px;
        background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    }
    .site-footer-meta {
        margin: 0;
        color: #8a9bb3;
        font-size: 0.78rem;
        font-weight: 500;
    }
    @media (max-width: 600px) {
        .site-footer { padding: 28px 18px 22px; }
        .site-footer-desc { font-size: 0.86rem; }
    }

    /* ---- Teacher dashboard: one tab per function ---- */
    .tab-panel { margin-bottom: 24px; }
    .panel-desc { margin: -6px 0 16px; color: #5a6c85; font-weight: 600; font-size: 0.92rem; }

    /* ---- Class & student management ---- */
    .classes-layout {
        display: grid;
        grid-template-columns: 260px 1fr;
        gap: 20px;
        align-items: start;
    }
    @media (max-width: 760px) {
        .classes-layout { grid-template-columns: 1fr; }
    }
    .classes-sidebar h3 { margin: 0 0 10px; color: var(--color-primary); font-size: 1rem; }
    .class-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 480px; overflow-y: auto; }
    .class-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 14px;
        border-radius: 12px;
        border: 2px solid #e3edf7;
        background: #f4faff;
        cursor: pointer;
        font-family: inherit;
        font-weight: 700;
        text-align: left;
        transition: transform 0.1s, border-color 0.15s, background 0.15s;
    }
    .class-item:hover { transform: translateY(-1px); border-color: var(--color-primary); }
    .class-item.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
    .class-item .class-item-count {
        font-size: 0.75rem;
        font-weight: 800;
        padding: 2px 9px;
        border-radius: 999px;
        background: rgba(45,125,210,0.12);
        color: var(--color-primary);
        flex-shrink: 0;
    }
    .class-item.active .class-item-count { background: rgba(255,255,255,0.25); color: #fff; }
    .inline-form { display: flex; gap: 8px; }
    .inline-form input[type="text"] {
        flex: 1;
        min-width: 0;
        font-family: inherit;
        font-size: 0.9rem;
        padding: 9px 12px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
    }
    .classes-main-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 16px;
    }
    .classes-main-header h3 { margin: 0; color: var(--color-primary); }
    .classes-main-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .username-chip {
        display: inline-block;
        font-family: "SFMono-Regular", Consolas, monospace;
        font-weight: 700;
        background: #eef3fa;
        color: #3d5a80;
        padding: 3px 10px;
        border-radius: 8px;
        font-size: 0.88rem;
    }
    .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
    .row-actions button {
        font-family: inherit;
        border: none;
        border-radius: 8px;
        padding: 6px 10px;
        font-size: 0.8rem;
        font-weight: 700;
        cursor: pointer;
        background: #eef3fa;
        color: var(--color-primary);
    }
    .row-actions button.danger { background: #fde0de; color: #a3251b; }
    .row-actions button:hover { transform: translateY(-1px); }
    /* Nút icon con mắt "Chi tiết" trong bảng quản lý học sinh */
    .btn-icon-eye {
        font-family: inherit;
        border: none;
        border-radius: 8px;
        padding: 6px 10px;
        font-size: 1rem;
        cursor: pointer;
        background: #eef3fa;
        color: var(--color-primary);
        line-height: 1;
    }
    .btn-icon-eye:hover { transform: translateY(-1px); background: #dceafc; }
    .form-field { margin-bottom: 14px; }
    .form-field label { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 6px; color: #24324a; }
    .form-field input[type="text"],
    .form-field input[type="password"],
    .form-field textarea,
    .form-field select {
        width: 100%;
        box-sizing: border-box;
        font-family: inherit;
        font-size: 0.95rem;
        padding: 10px 12px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
    }
    .form-field textarea { resize: vertical; line-height: 1.5; min-height: 120px; }
  .form-field { width: 100%; }
  #bulkStudentNames { width: 100%; display: block; min-height: 200px; }
    .form-field-hint { display: block; margin-top: 5px; font-size: 0.78rem; font-weight: 600; color: #5a6c85; }
    .username-edit-row { display: flex; gap: 8px; align-items: center; }
    .username-edit-row input { flex: 1; }
    .password-note {
        margin-top: 10px;
        padding: 10px 12px;
        border-radius: 10px;
        background: #fffdf5;
        border: 2px solid #ffe6b3;
        font-size: 0.85rem;
        font-weight: 700;
        color: #7a5a00;
    }

    /* ---- Teacher login page ---- */
    .login-wrap {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
    }
    .login-card {
        width: 100%;
        max-width: 380px;
        background: #ffffffee;
        border-radius: var(--radius);
        box-shadow: 0 12px 32px rgba(30,80,150,0.18);
        padding: 32px 28px;
        text-align: center;
    }
    .login-card .login-icon { font-size: 2.4rem; margin-bottom: 6px; }
    .login-card h1 { margin: 0 0 6px; font-size: 1.3rem; color: var(--color-primary); }
    .login-card p.login-sub { margin: 0 0 22px; color: #5a6c85; font-size: 0.9rem; font-weight: 600; }
    .login-card .form-field { text-align: left; }
    .login-card .btn-primary { width: 100%; padding: 12px; font-size: 1rem; margin-top: 6px; }
    .login-error {
        background: #fde0de;
        color: #a3251b;
        border-radius: 10px;
        padding: 10px 14px;
        font-weight: 700;
        font-size: 0.88rem;
        margin-bottom: 16px;
        text-align: left;
    }

    /* ---- Student login modal (index.php: "Đăng nhập" popup) ---- */
    #welcomeText {
        font-weight: 700;
        color: #fff;
    }
    .login-modal { max-width: 380px; }
    .login-field { margin-bottom: 14px; }
    .login-field label {
        display: block;
        font-weight: 700;
        margin-bottom: 6px;
        font-size: 0.9rem;
    }
    .login-field input {
        width: 100%;
        box-sizing: border-box;
        padding: 10px 12px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
        font-family: inherit;
        font-size: 1rem;
    }
    .login-field input:focus { outline: none; border-color: var(--color-primary); }

    /* ---- Toggle switch (dùng cho công tắc mở/khóa node) ---- */
    .switch {
        position: relative;
        display: inline-flex;
        align-items: center;
        cursor: pointer;
    }
    .switch input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }
    .switch-track {
        width: 44px;
        height: 24px;
        border-radius: 999px;
        background: #cbd5e1;
        display: inline-block;
        position: relative;
        transition: background 0.2s;
        flex-shrink: 0;
    }
    .switch-thumb {
        position: absolute;
        top: 3px;
        left: 3px;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.25);
        transition: transform 0.2s;
    }
    .switch input:checked + .switch-track {
        background: var(--color-primary);
    }
    .switch input:checked + .switch-track .switch-thumb {
        transform: translateX(20px);
    }
    .switch input:disabled + .switch-track {
        opacity: 0.55;
        cursor: not-allowed;
    }
    .switch input:focus-visible + .switch-track {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    /* ---- Pagination ---- */
    .pagination {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin: 14px 0 18px;
    }
    .pagination:empty { margin: 0; }
    .pagination-info {
        font-size: 0.82rem;
        font-weight: 700;
        color: #5a6c85;
    }
    .pagination-controls {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-wrap: wrap;
    }
    .page-btn {
        font-family: inherit;
        border: 1px solid #d9e6f5;
        background: #fff;
        color: #3d5a80;
        font-weight: 700;
        font-size: 0.85rem;
        min-width: 34px;
        height: 34px;
        padding: 0 10px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    .page-btn:hover:not(:disabled) {
        background: rgba(45,125,210,0.08);
        border-color: var(--color-primary);
    }
    .page-btn.active {
        background: var(--color-primary);
        border-color: var(--color-primary);
        color: #fff;
    }
    .page-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
    .page-btn.page-nav { padding: 0 14px; }
    .page-ellipsis {
        color: #94a5bc;
        font-weight: 700;
        padding: 0 4px;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }
    .header-link,
    .logout-link {
        color: #fff;
        text-decoration: none;
        font-weight: 700;
        font-size: 0.9rem;
        background: rgba(255,255,255,0.18);
        padding: 8px 16px;
        border-radius: 999px;
        white-space: nowrap;
        border: none;
        font-family: inherit;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
    }
    .header-link:hover,
    .logout-link:hover { background: rgba(255,255,255,0.3); }

    /* ---- Tab "Lỗi thường gặp": bộ lọc theo lớp / học sinh ---- */
    .error-filter-bar {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 18px;
        background: #f4faff;
        border: 2px solid #dceafc;
        border-radius: 16px;
        padding: 14px 16px;
        margin-bottom: 16px;
    }
    .error-filter-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-width: 220px;
        flex: 1 1 260px;
    }
    .error-filter-label {
        font-weight: 800;
        font-size: 0.85rem;
        color: var(--color-primary);
    }
    .filter-chip-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .filter-chip {
        font-family: inherit;
        font-size: 0.85rem;
        font-weight: 700;
        color: #24324a;
        background: #fff;
        border: 2px solid #cfe3f7;
        border-radius: 999px;
        padding: 6px 14px;
        cursor: pointer;
        transition: transform 0.1s, background 0.15s, border-color 0.15s, color 0.15s;
    }
    .filter-chip:hover { transform: translateY(-1px); border-color: var(--color-primary); }
    .filter-chip.active {
        background: var(--color-primary);
        border-color: var(--color-primary);
        color: #fff;
    }
    .filter-chip-count {
        display: inline-block;
        margin-left: 4px;
        font-size: 0.72rem;
        font-weight: 800;
        opacity: 0.8;
    }
    /* Khung chọn nhiều Node/Lớp/Học sinh trong "Tùy chỉnh nâng cao theo Node
       -> Lớp -> Học sinh" (giaovien.php) — giới hạn chiều cao + cho cuộn dọc
       vì danh sách node/học sinh có thể rất dài. */
    .ai-rule-chip-list {
        max-height: 160px;
        overflow-y: auto;
        padding: 10px;
        background: #f7fafd;
        border: 1px solid #e1ecf7;
        border-radius: 12px;
    }
    .filter-select {
        font-family: inherit;
        font-size: 0.85rem;
        font-weight: 700;
        color: #24324a;
        background: #fff;
        border: 2px solid #cfe3f7;
        border-radius: 999px;
        padding: 6px 14px;
        cursor: pointer;
    }
    .filter-select:hover { border-color: var(--color-primary); }


    /* Thanh lỗi giờ có thể bấm được để xem chi tiết theo học sinh. */
    .bar-track { cursor: pointer; transition: box-shadow 0.15s; }
    .bar-track:hover, .bar-track:focus-visible {
        box-shadow: 0 0 0 3px rgba(45,125,210,0.25);
        outline: none;
    }

    /* ---- Chi tiết % số câu mỗi học sinh làm sai vì 1 dạng lỗi (popup) ---- */
    /* Hiển thị dạng popup (overlay + modal) thay vì bảng nằm cố định trong
       trang, để giáo viên xem được ngay mà không cần kéo trang xuống dù
       danh sách lỗi phía trên dài bao nhiêu. */
    .error-breakdown-modal {
        max-width: 900px;
        width: 96vw;
    }
    .error-breakdown-modal .subnode-modal-desc { margin-bottom: 14px; }
    .error-chart-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 10px;
    }
    .error-chart-row {
        /* Căn các cột theo MÉP TRÊN (không phải flex-end/mép dưới): mỗi cột
           có chiều cao khác nhau tùy tên học sinh xuống 1 hay 2 dòng, nên nếu
           căn theo mép dưới thì cột có tên ngắn (1 dòng) s����� bị đẩy tụt xuống
           để bằng mép dưới với cột tên dài (2 dòng), kéo theo cả khung cột
           (.error-chart-track) của nó lệch xuống thấp hơn — khiến các cột
           trông như có "gốc" (đáy cột) không thẳng hàng. Căn theo mép trên +
           .error-chart-value có min-height cố định giúp mọi khung cột luôn
           bắt đầu ở cùng 1 vị trí, nhờ đó đáy cột (gốc biểu đồ) luôn bằng
           nhau bất kể tên học sinh dài ngắn ra sao. */
        display: inline-flex;
        align-items: flex-start;
        gap: 18px;
        min-width: 100%;
        padding: 0 4px;
    }
    .error-chart-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        width: 74px;
        flex-shrink: 0;
    }
    .error-chart-value {
        font-size: 0.78rem;
        font-weight: 800;
        color: #a3251b;
        min-height: 1.2em;
        display: flex;
        align-items: flex-end;
    }
    .error-chart-track {
        width: 36px;
        height: 160px;
        background: #eef3fa;
        border-radius: 8px 8px 3px 3px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        overflow: hidden;
    }
    .error-chart-bar {
        width: 100%;
        background: linear-gradient(180deg, #ff8c78, var(--color-failed));
        border-radius: 6px 6px 0 0;
        transition: height 0.35s ease;
    }
    .error-chart-count {
        font-size: 0.72rem;
        font-weight: 700;
        color: #5a6c85;
        white-space: nowrap;
    }
    .error-chart-name {
        font-size: 0.78rem;
        font-weight: 800;
        color: #24324a;
        text-align: center;
        line-height: 1.25;
        word-break: break-word;
    }

    /* ---- Tab "Thử thách" (challenges) ---- */
    .challenge-modal { max-width: 720px; }
    .challenge-grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }
    .challenge-grid-3 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 14px;
        margin: 4px 0 14px;
    }
    @media (max-width: 620px) {
        .challenge-grid-2, .challenge-grid-3 { grid-template-columns: 1fr; }
    }
    .challenge-type-options {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 6px;
    }
    .challenge-type-options .choice-option { width: 100%; }
    .choice-option input[type="radio"] {
        width: 18px;
        height: 18px;
        accent-color: var(--color-primary);
        flex-shrink: 0;
        margin: 0;
    }
    .choice-option.selected {
        border-color: var(--color-primary);
        background: #eaf4ff;
    }

    /* ---- Tab "🤖 AI (Grok)" + nút "Phân tích bằng AI" ---- */
    .ai-settings-form .lc-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .ai-settings-form .lc-field label {
        font-size: 0.85rem;
        font-weight: 700;
        color: #5a6c85;
    }
    .ai-settings-form .lc-field input[type="text"],
    .ai-settings-form .lc-field input[type="password"] {
        font-family: inherit;
        font-size: 0.98rem;
        padding: 12px 14px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
        width: 100%;
        box-sizing: border-box;
        background: #fff;
    }
    .ai-settings-form .lc-field input[type="text"]:focus,
    .ai-settings-form .lc-field input[type="password"]:focus {
        outline: none;
        border-color: var(--color-primary);
    }
    .ai-toggle-row {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 8px 0;
        cursor: pointer;
        font-weight: 600;
        font-size: 0.92rem;
        line-height: 1.4;
    }
    .ai-toggle-row input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin-top: 1px;
        accent-color: var(--color-primary);
        flex-shrink: 0;
        cursor: pointer;
    }
    .ai-insight-box {
        margin-top: 16px;
        padding-top: 14px;
        border-top: 2px dashed #dceafc;
    }
    .ai-insight-meta {
        margin: 12px 0 0;
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--color-primary);
        line-height: 1.6;
    }
    .ai-insight-text {
        margin-top: 8px;
        padding: 16px 18px;
        border-radius: 14px;
        background: #f4faff;
        border: 2px solid #cfe3f7;
        font-weight: 400;
        line-height: 1.6;
        color: #24324a;
        max-height: 75vh;
        overflow-y: auto;
    }
    .ai-insight-text > :first-child { margin-top: 0; }
    .ai-insight-text > :last-child { margin-bottom: 0; }
    .ai-insight-text p {
        margin: 0 0 12px;
    }
    /* Chữ in đậm giữ NGUYÊN TRÊN DÒNG (inline). Trước đây đặt display:block
       khiến mỗi tên học sinh AI in đậm bị tách thành 1 dòng riêng, dấu phẩy
       giữa các tên cũng rơi xuống dòng riêng -> rất khó đọc. */
    .ai-insight-text strong {
        font-weight: 700;
        color: #1e3a5f;
    }

    /* Tiêu đề mục (## 1. Tổng quan ...) */
    .ai-insight-text .ai-md-h {
        margin: 22px 0 10px;
        padding: 8px 12px;
        font-size: 1.08rem;
        font-weight: 700;
        color: var(--color-primary);
        background: #ffffff;
        border-left: 4px solid var(--color-primary);
        border-radius: 8px;
    }
    .ai-insight-text .ai-md-sub {
        margin: 14px 0 6px;
        font-size: 0.98rem;
        font-weight: 700;
        color: #1e3a5f;
    }

    /* Danh sách gạch đầu dòng / đánh số */
    .ai-insight-text .ai-md-list {
        margin: 0 0 12px;
        padding-left: 22px;
    }
    .ai-insight-text .ai-md-list li {
        margin: 4px 0;
        padding-left: 2px;
    }
    .ai-insight-text ol.ai-md-list li::marker {
        font-weight: 700;
        color: var(--color-primary);
    }

    /* Bảng phân tích (theo dạng lỗi / theo từng học sinh) */
    .ai-md-table-wrap {
        margin: 0 0 14px;
        overflow-x: auto;
        border: 1px solid #cfe3f7;
        border-radius: 10px;
        background: #ffffff;
    }
    .ai-md-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.95rem;
        line-height: 1.45;
    }
    .ai-md-table th,
    .ai-md-table td {
        padding: 9px 12px;
        text-align: left;
        vertical-align: top;
        border-bottom: 1px solid #e3edf7;
    }
    .ai-md-table th {
        background: #e8f2fc;
        color: #1e3a5f;
        font-weight: 700;
        white-space: nowrap;
    }
    .ai-md-table tbody tr:nth-child(even) td { background: #f8fbff; }
    .ai-md-table tbody tr:hover td { background: #eef6ff; }
    .ai-md-table tbody tr:last-child td { border-bottom: none; }
    .ai-md-table .num {
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    /* Nhãn "Mức độ" trong bảng từng học sinh */
    .ai-tier-badge {
        display: inline-block;
        padding: 2px 10px;
        border-radius: 999px;
        font-size: 0.82rem;
        font-weight: 700;
        white-space: nowrap;
        border: 1px solid transparent;
    }
    .ai-tier-danger { background: #fde0de; color: #a3251b; border-color: #f5b5af; }
    .ai-tier-warn { background: #fff1d6; color: #8a5300; border-color: #f6d28e; }
    .ai-tier-ok { background: #e3eefc; color: #1f5fa8; border-color: #b9d3f3; }
    .ai-tier-good { background: #d7f7e1; color: #1c7a41; border-color: #a6e3bb; }

    @media (max-width: 640px) {
        .ai-insight-text { padding: 12px; }
        .ai-md-table { font-size: 0.88rem; }
        .ai-md-table th, .ai-md-table td { padding: 7px 9px; }
    }

    /* Popup "👨‍👩‍👧 Hướng dẫn dành cho phụ huynh" — dựa trên .info-modal (chuyên
       nghiệp, trung tính) nhưng rộng hơn và tông ấm hơn (hồng cam) để phân biệt
       với các popup thông tin/kỹ thuật khác, phù hợp nội dung gửi phụ huynh. */
    .parent-guidance-modal {
        max-width: 680px;
    }
    .parent-guidance-modal .info-modal-icon {
        background: #fff1f2;
        color: #e11d48;
    }
    .parent-guidance-modal .info-modal-title {
        color: #be123c;
    }
    .parent-guidance-text {
        max-height: 60vh;
    }
    .parent-guidance-text strong {
        color: #be123c;
    }

    /* "Mức áp dụng mặc định" — 3 lựa chọn dạng thẻ giống choice-option, chọn
       bằng radio ẩn để vẫn submit được như 1 form field bình thường. */
    .ai-level-options {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .ai-level-option {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 14px;
        border: 2px solid #e3edf7;
        background: #f9fcff;
        cursor: pointer;
        transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
    }
    .ai-level-option:hover { transform: translateY(-1px); border-color: #cfe3f7; }
    .ai-level-option input[type="radio"] {
        margin-top: 3px;
        width: 18px;
        height: 18px;
        accent-color: var(--color-primary);
        cursor: pointer;
        flex-shrink: 0;
    }
    .ai-level-option-icon { font-size: 1.3rem; flex-shrink: 0; }
    .ai-level-option-text { display: flex; flex-direction: column; gap: 2px; }
    .ai-level-option-title { font-weight: 800; color: #24324a; font-size: 0.95rem; }
    .ai-level-option-desc { font-size: 0.8rem; font-weight: 600; color: #5a6c85; }
    .ai-level-option.active { border-color: var(--color-primary); background: #eaf4ff; }
    .ai-level-option[data-level="detailed"].active { border-color: #2ecc71; background: #eafcf1; }
    .ai-level-option[data-level="off"].active { border-color: #95a5a6; background: #f1f3f5; }

    /* Form thêm 1 quy tắc tùy chỉnh nâng cao (Node -> Lớp -> Học sinh -> Loại ->
       Mức độ). 4 ô chọn Node/Lớp/Học sinh/Loại đều cao ~140px (chip list/
       checkbox list) nên xếp hàng riêng (align-items: start); với đúng 3 cột,
       hàng 1 chứa Node/Lớp/Học sinh, hàng 2 chứa Loại/Mức độ/nút "Thêm quy
       tắc" theo grid auto-flow. */
    .ai-rule-form {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 14px 10px;
        align-items: start;
    }
    .ai-rule-form select {
        font-family: inherit;
        font-size: 0.9rem;
        padding: 9px 10px;
        border-radius: 10px;
        border: 2px solid #cfe3f7;
        width: 100%;
        box-sizing: border-box;
        background: #fff;
    }
    .ai-rule-form button { white-space: nowrap; }
    @media (max-width: 900px) {
        .ai-rule-form { grid-template-columns: 1fr; }
    }

    /* Danh sách chọn nhiều (checkbox) trong "Tùy chỉnh nâng cao" (Node / Lớp /
       Học sinh / Loại): TRƯỚC ĐÂY Node/Lớp/Học sinh dùng <select multiple>,
       đòi hỏi giáo viên phải giữ Ctrl/Cmd khi click để chọn thêm — click
       thường (không giữ Ctrl) sẽ THAY THẾ toàn bộ lựa chọn trước đó, khiến
       giáo viên tưởng đã chọn được nhiều mục nhưng lúc lưu chỉ còn đúng 1 mục
       (mục vừa click sau cùng). Đổi toàn bộ 4 chiều sang danh sách checkbox
       (mỗi mục có ô tick riêng, click vào đâu chỉ bật/tắt đúng mục đó, không
       ảnh hưởng các mục đã chọn khác) để chọn nhiều luôn hoạt động đúng như
       mong đợi mà không cần biết phím tắt nào. */
    .ai-rule-checklist {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-height: 140px;
        max-height: 220px;
        overflow-y: auto;
        padding: 6px;
        border: 2px solid #cfe3f7;
        border-radius: 10px;
        background: #fff;
        box-sizing: border-box;
    }
    .ai-rule-checklist-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 10px;
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.88rem;
        cursor: pointer;
        transition: background 0.15s ease;
    }
    .ai-rule-checklist-item:hover { background: #f4faff; }
    .ai-rule-checklist-item input[type="checkbox"] {
        width: 18px;
        height: 18px;
        accent-color: var(--color-primary);
        cursor: pointer;
        flex-shrink: 0;
    }
    .ai-rule-checklist-item.is-checked {
        background: #eaf6ff;
    }

    /* "🎖️ Vinh danh" — phòng vinh danh của học sinh (mỗi chủ đề đã chinh phục,
       cấp độ CAO NHẤT từng đạt) + ảnh giấy chứng nhận có thể tải về.
       Dùng chung ở cả index.php (tab "Thông tin cá nhân" của học sinh) và
       giaovien.php (modal "Chi tiết học sinh" của giáo viên). */
    .panel-desc { color: #5a6c85; font-weight: 600; margin: 0 0 18px; line-height: 1.5; }
    .honor-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 18px;
    }
    .honor-card {
        position: relative;
        background: linear-gradient(160deg, #ffffff 0%, var(--honor-light, #f4faff) 100%);
        border: 2px solid var(--honor-base, #dceafc);
        border-radius: 18px;
        padding: 20px 18px 18px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        box-shadow: 0 6px 18px rgba(30, 80, 150, 0.1);
        transition: transform 0.15s ease, box-shadow 0.15s ease;
        overflow: hidden;
    }
    .honor-card::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 18px;
        border: 1px solid rgba(255,255,255,0.6);
        pointer-events: none;
    }
    .honor-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 12px 28px rgba(30, 80, 150, 0.18);
    }
    .honor-card-ribbon {
        position: absolute;
        top: 12px;
        right: 14px;
        font-size: 1.6rem;
        filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
    }
    .honor-card-level {
        display: inline-flex;
        align-self: flex-start;
        align-items: center;
        padding: 4px 14px;
        border-radius: 999px;
        font-weight: 800;
        font-size: 0.75rem;
        letter-spacing: 0.03em;
    }
    .honor-card-title {
        margin: 4px 0 0;
        font-size: 1.02rem;
        font-weight: 800;
        color: #16213e;
        line-height: 1.4;
        padding-right: 26px;
    }
    .honor-card-meta { margin: 0; font-size: 0.85rem; color: #475569; font-weight: 700; }
    .honor-card-date { margin: 0; font-size: 0.8rem; color: #64748b; font-weight: 600; }
    .honor-download-btn {
        margin-top: 10px;
        width: 100%;
        background: linear-gradient(135deg, var(--honor-base, var(--color-primary)), var(--honor-dark, var(--color-primary)));
        font-size: 0.9rem;
        padding: 10px 16px;
    }
    @media (max-width: 480px) {
        .honor-grid { grid-template-columns: 1fr; }
    }

    /* Sub-tab nav dùng trong modal "Chi tiết học sinh" (giaovien.php) để
       chuyển giữa "📄 Chi tiết bài làm" và "🎖️ Vinh danh". */
    .modal-subtabs {
        display: flex;
        gap: 8px;
        margin-bottom: 16px;
        border-bottom: 2px solid #e6edf5;
        flex-wrap: wrap;
    }
    .modal-subtabs button {
        border: none;
        background: transparent;
        padding: 9px 16px;
        font-weight: 700;
        font-size: 0.92rem;
        color: #64748b;
        cursor: pointer;
        border-radius: 10px 10px 0 0;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .modal-subtabs button:hover { background: #f4faff; color: #24324a; }
    .modal-subtabs button.active {
        color: var(--color-primary);
        background: #eaf6ff;
        box-shadow: inset 0 -3px 0 var(--color-primary);
    }

    /* ---------------------------------------------------------------
       🧪 TẠO KIỂU BÀI TẬP MỚI (tab custom exercise templates)
       ------------------------------------------------------------- */
    .ce-form {
        display: flex;
        flex-direction: column;
        gap: 14px;
        max-width: 720px;
    }
    .ce-form textarea,
    .ce-form input[type="text"],
    .ce-form input[type="number"] {
        width: 100%;
        font-family: inherit;
        font-size: 0.95rem;
        padding: 10px 12px;
        border: 2px solid #cfe3f7;
        border-radius: 10px;
        outline: none;
        background: #fbfdff;
        color: #24324a;
    }
    .ce-form textarea:focus,
    .ce-form input[type="text"]:focus,
    .ce-form input[type="number"]:focus {
        border-color: var(--color-primary);
    }
    .ce-form input[type="file"] {
        font-family: inherit;
        font-size: 0.9rem;
    }
    #ceSpecJson {
        width: 100%;
        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 0.85rem;
        padding: 10px 12px;
        border: 2px solid #cfe3f7;
        border-radius: 10px;
        background: #fbfdff;
        color: #24324a;
        outline: none;
    }
    #ceSpecJson:focus { border-color: var(--color-primary); }
    .ce-preview-area {
        margin-top: 14px;
        padding: 16px;
        border: 1px dashed #cfe3f7;
        border-radius: 12px;
        background: #fbfdff;
    }
    .ce-template-list,
    .ce-attachment-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 16px;
    }
    .ce-template-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
        padding: 12px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: #ffffff;
    }
    .ce-template-info {
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
    }
    .ce-template-name {
        font-weight: 700;
        color: #0f172a;
        font-size: 0.95rem;
    }
    .ce-template-meta {
        font-size: 0.78rem;
        color: #64748b;
        font-weight: 600;
    }
    .ce-template-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .ce-template-actions .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    .ce-attach-area {
        margin-bottom: 16px;
        padding: 14px;
        border: 1px solid #cfe3f7;
        border-radius: 12px;
        background: #f4faff;
    }
    .ce-attach-area select[multiple] {
        width: 100%;
        font-family: inherit;
        font-size: 0.9rem;
        padding: 8px;
        border: 2px solid #cfe3f7;
        border-radius: 10px;
        background: #fff;
        color: #24324a;
    }

    /* ---- Thêm / xóa node + gán dạng bài (tab "Trạng thái Node") ---- */
    .node-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 16px;
    }
    .col-actions { width: 150px; text-align: right; white-space: nowrap; }
    .node-action-btn {
        padding: 4px 10px;
        font-size: 0.82rem;
        margin-left: 4px;
    }
    .node-action-btn.node-delete-btn { background: #fde0de; color: #a3251b; }
    .node-action-btn.node-delete-btn:hover { background: #f8c9c6; }

    .node-exercise-modal { max-width: 680px; }
    .node-exercise-section { margin-bottom: 16px; }
    .node-exercise-section h3 {
        margin: 0 0 10px;
        font-size: 0.95rem;
        color: var(--color-primary);
    }
    .node-exercise-list {
        display: flex;
        flex-direction: column;
        gap: 6px;
        max-height: 280px;
        overflow-y: auto;
        padding: 6px;
        border: 1px solid #e3edf7;
        border-radius: 10px;
        background: #fbfdff;
    }
    .node-exercise-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.12s ease;
    }
    .node-exercise-item:hover { background: #f0f7ff; }
    .node-exercise-item input[type="checkbox"] { flex-shrink: 0; width: 16px; height: 16px; }
    .node-exercise-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.88rem; color: #24324a; }
    .node-exercise-weight {
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 0.78rem;
        font-weight: 700;
        color: #5a6c85;
    }
    .node-exercise-weight input[type="number"] {
        width: 64px;
        font-family: inherit;
        font-size: 0.82rem;
        padding: 4px 6px;
        border: 1px solid #cfe3f7;
        border-radius: 6px;
        background: #fff;
        color: #24324a;
    }
    .node-exercise-weight input[type="number"]:disabled { opacity: 0.5; background: #f1f5f9; }

    /* ===============================================================
       HƯỚNG DẪN SỬ DỤNG (huong-dan.php) — nút "?" nổi + popup từng bước.
       Mọi class dùng tiền tố .hg- để không đụng style sẵn có.
       =============================================================== */
    body.hg-lock { overflow: hidden; }

    .hg-fab {
        position: fixed;
        right: 22px;
        bottom: 22px;
        z-index: 450;
        width: 30px;
        height: 30px;
        border: 2px solid #fff;
        border-radius: 50%;
        background: linear-gradient(135deg, #ff8c42, #ff6a3d);
        color: #fff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(255, 106, 61, 0.45);
        font-family: inherit;
        padding: 0;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .hg-fab::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
    .hg-fab:hover { transform: translateY(-1px) scale(1.08); box-shadow: 0 6px 16px rgba(255, 106, 61, 0.55); }
    .hg-fab:focus-visible { outline: 3px solid #2d7dd2; outline-offset: 3px; }
    .hg-fab-icon { font-size: 16px; font-weight: 800; line-height: 1; }
    .hg-fab-label {
        position: absolute;
        right: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%) translateX(6px);
        white-space: nowrap;
        background: #24324a;
        color: #fff;
        font-size: 0.85rem;
        font-weight: 700;
        padding: 8px 12px;
        border-radius: 10px;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease, transform 0.15s ease;
        box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    }
    .hg-fab-label::after {
        content: "";
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        border: 6px solid transparent;
        border-left-color: #24324a;
    }
    .hg-fab:hover .hg-fab-label,
    .hg-fab:focus-visible .hg-fab-label,
    .hg-fab.is-new .hg-fab-label { opacity: 1; transform: translateY(-50%) translateX(0); }
    .hg-fab.is-new::before {
        content: "";
        position: absolute;
        inset: -3px;
        border-radius: 50%;
        border: 3px solid #ff8c42;
        animation: hg-ring 1.8s ease-out infinite;
    }
    @keyframes hg-ring {
        0% { transform: scale(1); opacity: 0.9; }
        100% { transform: scale(1.7); opacity: 0; }
    }

    /* ---------- Khung popup ---------- */
    .hg-overlay { z-index: 520; }
    .hg-modal {
        width: 100%;
        max-width: 1020px;
        height: min(700px, calc(100vh - 32px));
        background: #fff;
        border-radius: 22px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 28px 70px rgba(15, 35, 70, 0.35);
        animation: hg-pop 0.22s ease-out;
    }
    @keyframes hg-pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

    .hg-header {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 16px 20px;
        background: linear-gradient(90deg, var(--color-primary), #57b0ff);
        color: #fff;
    }
    .hg-header-icon {
        flex-shrink: 0;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: #fff;
        color: #ff6a3d;
        font-size: 1.5rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .hg-header-text { flex: 1; min-width: 0; }
    .hg-header-title { margin: 0; font-size: 1.2rem; font-weight: 800; color: #fff; }
    .hg-header-sub { margin: 2px 0 0; font-size: 0.85rem; opacity: 0.92; font-weight: 600; }
    .hg-close {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 50%;
        background: rgba(255,255,255,0.22);
        color: #fff;
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
        transition: background 0.15s ease;
    }
    .hg-close:hover { background: rgba(255,255,255,0.38); }
    .hg-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

    .hg-progress { height: 5px; background: #e3edf7; }
    .hg-progress-fill {
        height: 100%;
        width: 0;
        background: linear-gradient(90deg, var(--color-accent), #ffb347);
        transition: width 0.3s ease;
    }

    .hg-body {
        flex: 1;
        min-height: 0;
        display: grid;
        grid-template-columns: 250px 1fr;
    }

    /* ---------- Mục lục ---------- */
    .hg-nav {
        overflow-y: auto;
        background: #f5f9ff;
        border-right: 1px solid #e2ecf7;
        padding: 14px 10px 18px;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    .hg-nav-group {
        margin: 12px 10px 4px;
        font-size: 0.7rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: #8a9ab3;
    }
    .hg-nav-group:first-child { margin-top: 2px; }
    .hg-nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        text-align: left;
        border: none;
        background: transparent;
        padding: 8px 10px;
        border-radius: 10px;
        font-family: inherit;
        font-size: 0.88rem;
        font-weight: 600;
        color: #475569;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .hg-nav-item:hover { background: #e8f1fc; color: var(--color-primary); }
    .hg-nav-item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
    .hg-nav-num {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #e2e8f0;
        color: #64748b;
        font-size: 0.75rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .hg-nav-item.is-visited .hg-nav-num { background: #d7f7e1; color: #16a34a; }
    .hg-nav-item.is-active { background: #fff; color: var(--color-primary); box-shadow: 0 2px 8px rgba(45,125,210,0.12); }
    .hg-nav-item.is-active .hg-nav-num { background: var(--color-primary); color: #fff; }

    /* ---------- Nội dung bước ---------- */
    .hg-content {
        overflow-y: auto;
        padding: 24px 30px 30px;
        outline: none;
        scroll-behavior: smooth;
    }
    .hg-step { animation: hg-fade 0.25s ease-out; }
    @keyframes hg-fade { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
    .hg-kicker {
        margin: 0 0 6px;
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-accent);
    }
    .hg-title { margin: 0 0 8px; font-size: 1.4rem; line-height: 1.3; color: #0f172a; font-weight: 800; }
    .hg-lead { margin: 0 0 18px; font-size: 0.98rem; line-height: 1.6; color: #475569; }
    .hg-subtitle { margin: 20px 0 10px; font-size: 1rem; font-weight: 800; color: #1e3a5f; }
    .hg-c-green { color: #16a34a; }
    .hg-c-red { color: #dc2626; }
    .hg-c-orange { color: #ea580c; }

    .hg-howto {
        list-style: none;
        counter-reset: hg;
        margin: 18px 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .hg-howto li {
        counter-increment: hg;
        position: relative;
        padding: 10px 14px 10px 50px;
        background: #f8fbff;
        border: 1px solid #e2ecf7;
        border-radius: 12px;
        font-size: 0.93rem;
        line-height: 1.55;
        color: #334155;
    }
    .hg-howto li::before {
        content: counter(hg);
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--color-primary);
        color: #fff;
        font-weight: 800;
        font-size: 0.82rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hg-tip, .hg-note {
        display: flex;
        gap: 12px;
        align-items: flex-start;
        padding: 12px 16px;
        border-radius: 12px;
        margin: 16px 0 0;
        font-size: 0.9rem;
        line-height: 1.55;
    }
    .hg-tip { background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; }
    .hg-note { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
    .hg-tip p, .hg-note p { margin: 0; }
    .hg-box-icon { font-size: 1.2rem; line-height: 1.3; flex-shrink: 0; }
    .hg-inline-fab {
        display: inline-flex; align-items: center; justify-content: center;
        width: 20px; height: 20px; border-radius: 50%;
        background: #ff8c42; color: #fff; font-weight: 800; font-size: 0.75rem; vertical-align: middle;
    }
    .hg-inline-info {
        display: inline-flex; align-items: center; justify-content: center;
        width: 18px; height: 18px; border-radius: 50%;
        border: 1.5px solid #cbd5e1; background: #f8fafc; color: #64748b;
        font-weight: 700; font-size: 0.68rem; vertical-align: middle;
    }
    .hg-content kbd {
        display: inline-block; padding: 1px 7px; border-radius: 6px;
        border: 1px solid #fdba74; border-bottom-width: 2px; background: #fff;
        font-family: inherit; font-size: 0.8rem; font-weight: 700;
    }

    .hg-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
    .hg-action-btn {
        font-family: inherit;
        font-size: 0.92rem;
        font-weight: 700;
        border: 2px solid var(--color-primary);
        background: #fff;
        color: var(--color-primary);
        border-radius: 999px;
        padding: 9px 18px;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .hg-action-btn:hover { background: var(--color-primary); color: #fff; }
    .hg-action-btn:focus-visible { outline: 3px solid #ffb347; outline-offset: 2px; }
    .hg-action-btn--sm { font-size: 0.82rem; padding: 6px 14px; margin-top: auto; align-self: flex-start; }

    /* ---------- Chân popup ---------- */
    .hg-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 20px;
        border-top: 1px solid #e2ecf7;
        background: #fff;
    }
    .hg-footer .btn { padding: 10px 20px; font-size: 0.95rem; }
    .hg-footer .btn:disabled { opacity: 0.45; cursor: not-allowed; }
    .hg-next { min-width: 150px; }
    .hg-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
    .hg-dots i {
        width: 8px; height: 8px; border-radius: 999px; background: #dbe4ef;
        transition: width 0.2s ease, background 0.2s ease;
    }
    .hg-dots i.is-visited { background: #9ccbf4; }
    .hg-dots i.is-active { width: 22px; background: var(--color-accent); }

    /* ---------- Màn hình mô phỏng ---------- */
    .hg-screen {
        border: 1px solid #d6e4f5;
        border-radius: 14px;
        overflow: hidden;
        background: #fff;
        box-shadow: 0 10px 24px rgba(30, 80, 150, 0.1);
        margin: 4px 0 6px;
    }
    .hg-screen-bar {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        background: #eef3f9;
        border-bottom: 1px solid #d6e4f5;
    }
    .hg-screen-bar i { width: 10px; height: 10px; border-radius: 50%; background: #f87171; }
    .hg-screen-bar i:nth-child(2) { background: #fbbf24; }
    .hg-screen-bar i:nth-child(3) { background: #34d399; }
    .hg-screen-bar span {
        margin-left: 8px; font-size: 0.75rem; font-weight: 700; color: #64748b;
        background: #fff; border-radius: 999px; padding: 3px 12px;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .hg-screen-body {
        padding: 16px;
        background: linear-gradient(180deg, #eaf6ff 0%, #fff8e7 100%);
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .hg-target { position: relative; display: inline-flex; }
    .hg-target--block { display: flex; }
    .hg-target--inline { display: block; }
    .hg-target::after {
        content: "";
        position: absolute;
        inset: -5px;
        border-radius: 14px;
        border: 2.5px dashed #ff8c42;
        pointer-events: none;
        animation: hg-glow 1.6s ease-in-out infinite;
    }
    @keyframes hg-glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
    .hg-pointer {
        position: absolute;
        right: 6px;
        bottom: -20px;
        font-size: 1.6rem;
        line-height: 1;
        pointer-events: none;
        z-index: 2;
        filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
        animation: hg-tap 1.3s ease-in-out infinite;
    }
    @keyframes hg-tap { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-4px, -7px); } }
    .hg-callout {
        display: inline-block;
        font-size: 0.75rem;
        font-weight: 800;
        color: #c2410c;
        background: #ffedd5;
        border-radius: 999px;
        padding: 3px 10px;
        margin-left: 8px;
        white-space: nowrap;
    }
    .hg-callout-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
    .hg-arrow-down { text-align: center; font-size: 0.8rem; font-weight: 700; color: #8a9ab3; }

    .hg-mock-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid rgba(45,125,210,0.18); }
    .hg-mock-tab { font-size: 0.8rem; font-weight: 700; color: #5a6c85; padding: 8px 12px; border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; }
    .hg-mock-tab.is-active { background: #fff; color: var(--color-primary); border-bottom-color: var(--color-primary); }

    .hg-grid-2, .hg-grid-3, .hg-grid-4 { display: grid; gap: 12px; }
    .hg-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
    .hg-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .hg-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .hg-mini-card { background: #fff; border: 1px solid #e2ecf7; border-radius: 12px; padding: 12px; }
    .hg-mini-card b { display: block; font-size: 0.86rem; color: #0f172a; margin-top: 4px; }
    .hg-mini-card p { margin: 4px 0 0; font-size: 0.8rem; line-height: 1.45; color: #64748b; }
    .hg-mini-icon { font-size: 1.4rem; }

    .hg-flow {
        list-style: none;
        margin: 0;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 18px;
    }
    .hg-flow-item {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 4px;
        background: #fff;
        border: 1px solid #e2ecf7;
        border-radius: 14px;
        padding: 14px 8px;
        font-size: 0.85rem;
        color: #0f172a;
    }
    .hg-flow-item small { color: #64748b; font-size: 0.74rem; line-height: 1.35; }
    .hg-flow-item:not(:last-child)::after {
        content: "➜";
        position: absolute;
        right: -15px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--color-accent);
        font-weight: 800;
    }
    .hg-flow-icon {
        width: 44px; height: 44px; border-radius: 50%;
        background: #eaf4ff; display: flex; align-items: center; justify-content: center;
        font-size: 1.35rem; margin-bottom: 2px;
    }

    .hg-mock-header {
        display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
        background: linear-gradient(90deg, var(--color-primary), #57b0ff);
        color: #fff; border-radius: 10px; padding: 10px 14px;
    }
    .hg-mock-header-title { font-weight: 800; font-size: 0.9rem; }
    .hg-mock-welcome {
        display: inline-flex; align-items: center; gap: 6px;
        background: rgba(255,255,255,0.18); padding: 5px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
    }
    .hg-mock-points { background: rgba(255,255,255,0.25); border-radius: 999px; padding: 1px 8px; }
    .hg-mock-btn {
        display: inline-flex; align-items: center; justify-content: center;
        padding: 7px 16px; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
        background: #eee; color: #555; white-space: nowrap;
    }
    .hg-mock-btn--primary { background: var(--color-primary); color: #fff; }
    .hg-mock-header .hg-mock-btn--primary { background: #fff; color: var(--color-primary); }

    .hg-mock-modal {
        background: #fffef6;
        border: 4px solid var(--color-accent);
        border-radius: 16px;
        padding: 14px 16px;
        max-width: 360px;
        width: 100%;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .hg-mock-modal--wide, .hg-mock-modal--quiz { max-width: 520px; }
    .hg-mock-modal-title { margin: 0; font-weight: 800; color: var(--color-primary); font-size: 0.98rem; }
    .hg-mock-desc { margin: 0; font-size: 0.8rem; color: #5a6c85; font-weight: 600; }
    .hg-mock-field { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; font-weight: 700; color: #475569; }
    .hg-mock-input {
        display: flex; align-items: center; background: #fff; border: 2px solid #cfe3f7; border-radius: 10px;
        padding: 7px 10px; font-weight: 600; color: #24324a; font-size: 0.85rem;
    }
    .hg-caret { width: 2px; height: 1em; background: var(--color-primary); margin-left: 2px; animation: hg-blink 1s step-end infinite; }
    @keyframes hg-blink { 50% { opacity: 0; } }
    .hg-mock-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }

    .hg-mock-term { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid #dbe4ef; }
    .hg-mock-term b { font-size: 0.95rem; color: #0f172a; }
    .hg-mock-term span { font-size: 0.78rem; color: #64748b; font-weight: 600; }
    .hg-mock-list { display: flex; flex-direction: column; gap: 10px; }
    .hg-mock-card {
        display: flex; align-items: center; gap: 12px;
        background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px 12px;
    }
    .hg-mock-card.is-locked { background: #f8fafc; }
    .hg-mock-status {
        flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
        display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800;
    }
    .hg-mock-card.is-locked .hg-mock-status { background: #94a3b8; }
    .hg-mock-card.is-unlocked .hg-mock-status { background: #2563eb; }
    .hg-mock-card.is-passed .hg-mock-status { background: #16a34a; }
    .hg-mock-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
    .hg-mock-card-body b { font-size: 0.88rem; color: #0f172a; }
    .hg-mock-card.is-locked .hg-mock-card-body b { color: #64748b; }
    .hg-mock-card-body small { font-size: 0.74rem; font-weight: 600; color: #64748b; }
    .hg-mock-level { font-size: 0.68rem; font-weight: 800; color: #fff; padding: 2px 9px; border-radius: 999px; }
    .hg-mock-chev { color: #cbd5e1; font-size: 1.2rem; }

    .hg-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
    .hg-legend li { display: flex; gap: 12px; align-items: flex-start; }
    .hg-legend b { font-size: 0.92rem; color: #0f172a; }
    .hg-legend p { margin: 2px 0 0; font-size: 0.87rem; line-height: 1.5; color: #475569; }
    .hg-legend-swatch {
        flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; color: #fff; font-weight: 800;
        display: flex; align-items: center; justify-content: center;
    }

    .hg-sub-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0; }
    .hg-sub {
        display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
        background: #f4faff; border: 2px solid #cfe3f7; border-radius: 14px; padding: 10px 6px;
    }
    .hg-sub b { font-size: 0.76rem; color: #24324a; line-height: 1.3; }
    .hg-sub-badge {
        width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary); color: #fff;
        display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem;
    }
    .hg-sub.is-done { background: #ecfdf3; border-color: #86efac; }
    .hg-sub.is-done .hg-sub-badge { background: #16a34a; }
    .hg-sub.is-locked { background: #f1f5f9; border-color: #e2e8f0; border-style: dashed; }
    .hg-sub.is-locked .hg-sub-badge { background: #94a3b8; }

    .hg-mock-section { margin: 4px 0 0; font-size: 0.82rem; font-weight: 800; color: #1e3a5f; }
    .hg-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .hg-levels--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hg-level {
        display: flex; align-items: center; gap: 10px;
        background: #fff; border: 2px solid #e2ecf7; border-left: 5px solid var(--lv); border-radius: 12px; padding: 10px;
    }
    .hg-level > span:nth-child(2) { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .hg-level b { font-size: 0.88rem; color: #0f172a; }
    .hg-level small { font-size: 0.72rem; color: #64748b; line-height: 1.35; }
    .hg-level-icon { font-size: 1.4rem; }
    .hg-level--locked { opacity: 0.6; filter: grayscale(0.6); }
    .hg-level-tag { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: #eafcf1; color: #1c7a41; font-size: 0.72rem; font-weight: 800; white-space: nowrap; }

    .hg-table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid #e2ecf7; border-radius: 12px; }
    .hg-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
    .hg-table th, .hg-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef3f9; vertical-align: top; }
    .hg-table thead th { background: #f5f9ff; color: #1e3a5f; font-weight: 800; }
    .hg-table tbody th { color: #475569; font-weight: 700; white-space: nowrap; }
    .hg-table tr:last-child th, .hg-table tr:last-child td { border-bottom: none; }
    .hg-yes { color: #15803d; font-weight: 700; }
    .hg-no { color: #64748b; font-weight: 700; }

    .hg-mock-pill { background: var(--color-primary); color: #fff; font-weight: 700; border-radius: 999px; padding: 4px 12px; font-size: 0.76rem; }
    .hg-mock-tally { margin: 0; font-size: 0.78rem; font-weight: 700; color: #b91c1c; }
    .hg-mock-question { margin: 2px 0; font-size: 1rem; font-weight: 800; color: #24324a; }
    .hg-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .hg-option {
        position: relative; display: flex; align-items: center; justify-content: center;
        padding: 10px; border: 3px solid #cfe3f7; background: #f4faff; border-radius: 12px; font-weight: 700; font-size: 0.9rem;
    }
    .hg-option.is-correct { background: #d7f7e1; border-color: var(--color-passed); }
    .hg-feedback { border-radius: 12px; padding: 10px 12px; font-size: 0.85rem; font-weight: 600; line-height: 1.5; }
    .hg-feedback.is-ok { background: #d7f7e1; color: #1c7a41; }
    .hg-feedback.is-bad { background: #fde0de; color: #a3251b; }
    .hg-ai-btn-wrap { margin-top: 10px; width: fit-content; }
    .hg-ai-btn {
        display: inline-block; font-size: 0.82rem; font-weight: 700; color: var(--color-primary);
        background: #fff; border: 2px solid var(--color-primary); border-radius: 999px; padding: 6px 14px;
    }
    .hg-ai-loading { display: flex; flex-direction: column; gap: 8px; background: #f4faff; border-radius: 12px; padding: 10px 12px; font-size: 0.82rem; font-weight: 700; color: var(--color-primary); }
    .hg-ai-track { position: relative; height: 8px; border-radius: 999px; background: #e3edf7; overflow: hidden; }
    .hg-ai-fill {
        position: absolute; top: 0; left: -40%; width: 40%; height: 100%; border-radius: 999px;
        background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
        animation: ai-progress-slide 1.1s ease-in-out infinite;
    }
    .hg-ai-result { display: flex; flex-direction: column; gap: 8px; }
    .hg-ai-part { background: #fff; border: 1px solid #e2ecf7; border-left: 4px solid var(--color-primary); border-radius: 10px; padding: 8px 12px; font-size: 0.83rem; color: #334155; }
    .hg-ai-part b { color: #1e3a5f; }
    .hg-ai-part p { margin: 4px 0 0; }
    .hg-ai-part ol { margin: 4px 0 0; padding-left: 20px; line-height: 1.6; }

    .hg-result {
        display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
        border-radius: 16px; padding: 18px 14px; border: 2px solid;
    }
    .hg-result.is-pass { background: #ecfdf3; border-color: #86efac; }
    .hg-result.is-fail { background: #fff7ed; border-color: #fdba74; }
    .hg-result-emoji { font-size: 2.2rem; }
    .hg-result b { font-size: 0.95rem; color: #0f172a; }
    .hg-result p { margin: 0 0 6px; font-size: 0.85rem; color: #475569; }
    .hg-panel-box { background: #f8fbff; border: 1px solid #e2ecf7; border-radius: 14px; padding: 4px 16px 14px; }
    .hg-bullets { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; line-height: 1.5; color: #334155; }

    .hg-bars { display: flex; flex-direction: column; gap: 8px; background: #fff; border-radius: 12px; padding: 12px; border: 1px solid #e2ecf7; }
    .hg-bar { display: grid; grid-template-columns: 130px 1fr 24px; align-items: center; gap: 10px; font-size: 0.8rem; font-weight: 700; color: #475569; }
    .hg-bar b { color: #0f172a; text-align: right; }
    .hg-bar-track { height: 10px; border-radius: 999px; background: #eef3f9; overflow: hidden; }
    .hg-bar-fill { display: block; height: 100%; width: var(--w); border-radius: 999px; background: linear-gradient(90deg, #ff8c42, #e74c3c); }
    .hg-hist { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e2ecf7; border-radius: 12px; padding: 10px 12px; font-size: 0.85rem; }
    .hg-hist b { flex: 1; min-width: 0; color: #0f172a; }
    .hg-hist-tag { font-size: 0.72rem; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: #e0f2fe; color: #0369a1; white-space: nowrap; }
    .hg-hist-tag.is-pass { background: #dcfce7; color: #15803d; }
    .hg-hist-score { font-weight: 800; color: #334155; white-space: nowrap; }

    .hg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
    .hg-chip {
        display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700;
        padding: 6px 14px; border-radius: 999px; background: #fff; border: 1.5px solid #dbe4ef; color: #475569;
    }
    .hg-chip i { width: 8px; height: 8px; border-radius: 50%; }
    .hg-chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
    .hg-challenge { background: #f4faff; border: 2px solid #dceafc; border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
    .hg-challenge-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
    .hg-challenge-top b { display: block; font-size: 0.95rem; color: #0f172a; }
    .hg-challenge-top small { font-size: 0.75rem; color: #64748b; font-weight: 700; }
    .hg-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
    .hg-badge { font-size: 0.72rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
    .hg-badge.is-green { background: #dcfce7; color: #15803d; }
    .hg-badge.is-amber { background: #fef3c7; color: #92400e; }
    .hg-challenge-line { margin: 0; font-size: 0.82rem; color: #334155; }
    .hg-challenge-line.hg-target::after { inset: -4px -6px; border-radius: 8px; }
    .hg-challenge-points { margin: 0; font-size: 0.82rem; font-weight: 800; color: #c2410c; }

    .hg-feature { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid #e2ecf7; border-top: 4px solid var(--c); border-radius: 14px; padding: 14px; }
    .hg-feature .hg-bullets { font-size: 0.85rem; }
    .hg-feature-head { font-weight: 800; color: var(--c); font-size: 0.95rem; }

    .hg-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 0.88rem; line-height: 1.5; color: #334155; }
    .hg-checks li { position: relative; padding-left: 26px; }
    .hg-checks li::before {
        content: "✓"; position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%;
        background: #dcfce7; color: #16a34a; font-size: 0.7rem; font-weight: 800;
        display: flex; align-items: center; justify-content: center;
    }
    .hg-faq { display: flex; flex-direction: column; gap: 8px; }
    .hg-faq details { background: #fff; border: 1px solid #e2ecf7; border-radius: 12px; padding: 0 14px; }
    .hg-faq details[open] { background: #f8fbff; border-color: #bfdbfe; }
    .hg-faq summary {
        cursor: pointer; list-style: none; padding: 11px 0; font-weight: 700; font-size: 0.9rem; color: #1e3a5f;
        display: flex; justify-content: space-between; gap: 10px;
    }
    .hg-faq summary::-webkit-details-marker { display: none; }
    .hg-faq summary::after { content: "+"; font-size: 1.1rem; color: var(--color-primary); font-weight: 800; }
    .hg-faq details[open] summary::after { content: "−"; }
    .hg-faq summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 6px; }
    .hg-faq p { margin: 0 0 12px; font-size: 0.87rem; line-height: 1.55; color: #475569; }
    .hg-finish {
        display: flex; align-items: center; gap: 14px; margin-top: 18px; padding: 14px 18px; border-radius: 14px;
        background: linear-gradient(90deg, #eaf4ff, #fff4e8); border: 1px solid #dbe7f5;
    }
    .hg-finish > span { font-size: 2rem; }
    .hg-finish p { margin: 0; font-size: 0.92rem; line-height: 1.55; color: #334155; }

    .sr-only {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }

    /* ---------- Responsive ---------- */
    @media (max-width: 860px) {
        .hg-flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        .hg-flow-item:nth-child(3)::after { display: none; }
        .hg-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .hg-grid-3 { grid-template-columns: 1fr; }
        .hg-levels { grid-template-columns: 1fr; }
    }
    @media (max-width: 760px) {
        .hg-overlay { padding: 0; }
        .hg-modal { height: 100vh; height: 100dvh; max-width: none; border-radius: 0; }
        .hg-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
        .hg-nav {
            flex-direction: row;
            overflow-x: auto;
            overflow-y: hidden;
            border-right: none;
            border-bottom: 1px solid #e2ecf7;
            padding: 8px 10px;
            gap: 6px;
            scrollbar-width: none;
        }
        .hg-nav::-webkit-scrollbar { display: none; }
        .hg-nav-group { display: none; }
        .hg-nav-item { width: auto; flex-shrink: 0; padding: 6px 10px 6px 6px; white-space: nowrap; background: #fff; border: 1px solid #e2ecf7; font-size: 0.8rem; }
        .hg-nav-item:not(.is-active) .hg-nav-label { display: none; }
        .hg-nav-item:not(.is-active) { padding: 6px; }
        .hg-content { padding: 18px 16px 24px; }
        .hg-title { font-size: 1.2rem; }
        .hg-grid-2 { grid-template-columns: 1fr; }
        .hg-sub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .hg-footer { padding: 10px 12px; }
        .hg-footer .btn { padding: 10px 14px; font-size: 0.88rem; }
        .hg-next { min-width: 0; }
        .hg-dots { display: none; }
        .hg-fab { right: 14px; bottom: 14px; }
        .hg-fab-label { display: none; }
    }
    @media (max-width: 480px) {
        .hg-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .hg-flow-item::after { display: none; }
        .hg-options { grid-template-columns: 1fr 1fr; }
        .hg-bar { grid-template-columns: 100px 1fr 20px; }
        .hg-callout { display: none; }
    }
    @media (prefers-reduced-motion: reduce) {
        .hg-fab.is-new::before, .hg-pointer, .hg-target::after, .hg-caret, .hg-ai-fill, .hg-step, .hg-modal { animation: none !important; }
        .hg-progress-fill, .hg-dots i { transition: none; }
    }

    /* ===============================================================
       LỚP PHỦ CHÚC MỪNG "GIẤY VINH DANH" khi vừa hoàn thành bậc luyện tập
       (xem showHonorCelebration() ở index.php). Màu hào quang lấy theo
       đúng cấp độ đạt được qua biến --honor-base / --honor-dark.
       =============================================================== */
    body.honor-celebration-lock { overflow: hidden; }
    .summary-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-top: 8px;
    }
    .honor-celebration {
        --honor-base: #F4B400;
        --honor-dark: #8a5a00;
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
        overflow-y: auto;
        background: radial-gradient(circle at 50% 42%, rgba(40, 30, 80, 0.72) 0%, rgba(8, 12, 32, 0.92) 70%);
        animation: honor-overlay-in 0.35s ease-out both;
    }
    .honor-fx-canvas {
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 0;
    }
    .honor-celebration-flash {
        position: fixed;
        inset: 0;
        pointer-events: none;
        background: radial-gradient(circle at 50% 45%, #fffbe6 0%, rgba(255, 251, 230, 0) 65%);
        opacity: 0;
        z-index: 1;
    }
    .honor-celebration.is-playing .honor-celebration-flash { animation: honor-flash 1s ease-out both; }

    .honor-celebration-close,
    .honor-celebration-sound {
        position: fixed;
        top: 16px;
        z-index: 3;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.6);
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        font-size: 1.15rem;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(4px);
        transition: background 0.15s ease, transform 0.15s ease;
    }
    .honor-celebration-close { right: 16px; }
    .honor-celebration-sound { right: 70px; }
    .honor-celebration-close:hover,
    .honor-celebration-sound:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.06); }
    .honor-celebration button:focus-visible { outline: 3px solid #ffd54f; outline-offset: 3px; }

    .honor-celebration-stage {
        position: relative;
        z-index: 2;
        width: 100%;
        max-width: 760px;
        margin: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 18px;
        text-align: center;
    }
    .honor-celebration-title {
        margin: 0;
        color: #fff;
        font-size: clamp(1.3rem, 4vw, 2rem);
        font-weight: 800;
        text-shadow: 0 0 18px var(--honor-base), 0 2px 6px rgba(0, 0, 0, 0.5);
    }
    .honor-celebration.is-playing .honor-celebration-title { animation: honor-title-in 0.6s 0.1s cubic-bezier(.2,1.4,.4,1) both; }

    .honor-cert-wrap {
        position: relative;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    .honor-cert-rays {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 160%;
        aspect-ratio: 1;
        transform: translate(-50%, -50%);
        background: repeating-conic-gradient(from 0deg,
            color-mix(in srgb, var(--honor-base) 55%, transparent) 0deg 8deg,
            transparent 8deg 22deg);
        -webkit-mask: radial-gradient(circle, #000 0%, transparent 62%);
        mask: radial-gradient(circle, #000 0%, transparent 62%);
        opacity: 0.75;
        pointer-events: none;
    }
    .honor-celebration.is-playing .honor-cert-rays { animation: honor-rays-spin 18s linear infinite, honor-fade-in 0.8s ease-out both; }
    .honor-cert-glow {
        position: absolute;
        inset: -6%;
        border-radius: 32px;
        background: radial-gradient(ellipse at center, color-mix(in srgb, var(--honor-base) 85%, #fff) 0%, transparent 70%);
        filter: blur(28px);
        pointer-events: none;
    }
    .honor-celebration.is-playing .honor-cert-glow { animation: honor-glow-pulse 2.2s ease-in-out infinite; }

    .honor-cert-card {
        position: relative;
        width: 100%;
        max-width: 640px;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 0 0 3px var(--honor-base), 0 0 40px var(--honor-base), 0 24px 60px rgba(0, 0, 0, 0.5);
        background: #fff;
    }
    .honor-celebration.is-playing .honor-cert-card {
        animation:
            honor-cert-pop 0.7s cubic-bezier(.2,1.3,.4,1) both,
            honor-cert-shake 0.55s 0.75s ease-in-out 3,
            honor-cert-float 3.4s 2.5s ease-in-out infinite;
    }
    .honor-cert-img { display: block; width: 100%; height: auto; }
    .honor-cert-shine {
        position: absolute;
        top: 0;
        left: -60%;
        width: 45%;
        height: 100%;
        background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.85) 50%, transparent 100%);
        transform: skewX(-18deg);
        pointer-events: none;
    }
    .honor-celebration.is-playing .honor-cert-shine { animation: honor-shine 2.8s 0.6s ease-in-out infinite; }

    .honor-celebration-note {
        margin: 0;
        max-width: 620px;
        padding: 12px 18px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.95);
        color: #24324a;
        font-weight: 600;
        font-size: 0.95rem;
        line-height: 1.55;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    }
    .honor-celebration-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .honor-celebration-download {
        background: linear-gradient(135deg, var(--honor-base), var(--honor-dark));
        color: #fff;
        box-shadow: 0 6px 18px color-mix(in srgb, var(--honor-base) 60%, transparent);
    }
    .honor-celebration-download:hover { filter: brightness(1.08); }
    .honor-celebration-actions .btn-ghost { background: rgba(255, 255, 255, 0.92); color: #24324a; }
    .honor-celebration-actions .btn-ghost:hover { background: #fff; }
    .honor-celebration.is-playing .honor-celebration-note,
    .honor-celebration.is-playing .honor-celebration-actions { animation: honor-fade-up 0.5s 0.9s ease-out both; }

    @keyframes honor-overlay-in { from { opacity: 0; } to { opacity: 1; } }
    @keyframes honor-fade-in { from { opacity: 0; } to { opacity: 0.75; } }
    @keyframes honor-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
    @keyframes honor-title-in { from { opacity: 0; transform: translateY(-16px) scale(0.9); } to { opacity: 1; transform: none; } }
    @keyframes honor-rays-spin { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
    @keyframes honor-glow-pulse { 0%, 100% { opacity: 0.55; transform: scale(0.98); } 50% { opacity: 1; transform: scale(1.04); } }
    @keyframes honor-cert-pop { 0% { opacity: 0; transform: scale(0.4) rotate(-6deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
    @keyframes honor-cert-shake {
        0%, 100% { transform: translate(0, 0) rotate(0); }
        20% { transform: translate(-3px, 1px) rotate(-0.8deg); }
        40% { transform: translate(3px, -1px) rotate(0.8deg); }
        60% { transform: translate(-2px, 0) rotate(-0.5deg); }
        80% { transform: translate(2px, 1px) rotate(0.4deg); }
    }
    @keyframes honor-cert-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
    @keyframes honor-shine { 0% { left: -60%; } 55%, 100% { left: 130%; } }
    @keyframes honor-fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

    @media (max-width: 560px) {
        .honor-celebration { align-items: flex-start; padding-top: 70px; }
        .honor-celebration-actions .btn { flex: 1 1 100%; }
    }
    @media (prefers-reduced-motion: reduce) {
        .honor-celebration.is-playing .honor-cert-rays,
        .honor-celebration.is-playing .honor-cert-glow,
        .honor-celebration.is-playing .honor-cert-shine { animation: none; }
        .honor-celebration.is-playing .honor-cert-card { animation: honor-overlay-in 0.3s ease-out both; }
    }

    /* ---------------------------------------------------------------
       CỠ CHỮ DÙNG CHUNG (index.php + giaovien.php) — xem font_scale.php.
       Mọi cỡ chữ trong ứng dụng đều dùng rem, nên chỉ cần đổi cỡ chữ gốc
       của <html> là toàn bộ giao diện to lên đúng tỉ lệ và vẫn tự xuống
       dòng. Dùng % để giữ cỡ chữ mặc định người dùng đặt trong trình duyệt.
       ------------------------------------------------------------- */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    html[data-font-scale="115"] { font-size: 115%; }
    html[data-font-scale="130"] { font-size: 130%; }
    html[data-font-scale="150"] { font-size: 150%; }
    html[data-font-scale="175"] { font-size: 175%; }
    html[data-font-scale="200"] { font-size: 200%; }

    /* Chữ to thì dòng cũng cần thoáng hơn để mắt người lớn tuổi dễ dò. */
    html[data-font-scale="130"] body,
    html[data-font-scale="150"] body,
    html[data-font-scale="175"] body,
    html[data-font-scale="200"] body { line-height: 1.55; }

    /* Nút cỡ chữ: chỉ 1 icon tròn nhỏ ở góc dưới trái; bấm vào mới mở bảng
       chọn phóng to / thu nhỏ. Kích thước tính bằng px để KHÔNG phóng theo
       chữ — luôn gọn một góc dù đang ở bậc lớn nhất. Vùng bấm 48px (khuyến
       nghị cho người lớn tuổi / màn cảm ứng). */
    /* Cùng cột với nút "?" hướng dẫn (right 22px, cao 30px): trang có nút
       hướng dẫn thì xếp ngay phía trên, cách 12px. */
    .font-scale-control {
        position: fixed;
        right: 22px;
        bottom: 22px;
        z-index: 1000;
        font-family: "Times New Roman", Tinos, "Liberation Serif", "Noto Serif", Times, serif;
        line-height: 1;
    }
    .font-scale-toggle {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        padding: 0;
        border: 2px solid #ffffff;
        border-radius: 50%;
        background: var(--color-primary);
        color: #ffffff;
        font-family: inherit;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
        opacity: 0.9;
        transition: transform 0.15s ease, opacity 0.15s ease;
    }
    /* Nút nhỏ 30px nhưng vùng bấm vẫn ~42px để người lớn tuổi dễ chạm. */
    .font-scale-toggle::after {
        content: "";
        position: absolute;
        inset: -6px;
        border-radius: 50%;
    }
    .font-scale-toggle:hover,
    .font-scale-toggle[aria-expanded="true"] {
        opacity: 1;
        transform: scale(1.08);
    }
    .font-scale-toggle-icon .small { font-size: 9px; }
    /* Huy hi��u % chỉ hiện khi đang khác cỡ mặc định, để biết trang đang phóng.
       Đặt bên trái nút để không bị mép màn hình bên phải cắt mất. */
    .font-scale-badge {
        position: absolute;
        top: -6px;
        right: calc(100% - 6px);
        padding: 2px 4px;
        border-radius: 999px;
        background: var(--color-accent);
        color: #ffffff;
        font-size: 9px;
        white-space: nowrap;
        font-weight: 700;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
    }
    .font-scale-badge[hidden] { display: none; }

    .font-scale-panel {
        position: absolute;
        right: 0;
        bottom: 40px;
        width: 216px;
        padding: 12px;
        background: #ffffff;
        border: 1px solid #dbe7f5;
        border-radius: 14px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
    }
    .font-scale-panel[hidden] { display: none; }
    .font-scale-title {
        margin: 0 0 10px;
        font-size: 15px;
        font-weight: 700;
        color: #1e293b;
    }
    .font-scale-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }
    .font-scale-btn {
        width: 52px;
        height: 48px;
        border: 2px solid var(--color-primary);
        border-radius: 10px;
        background: #ffffff;
        color: var(--color-primary);
        font-family: inherit;
        font-size: 20px;
        font-weight: 700;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .font-scale-btn-up { font-size: 24px; }
    .font-scale-btn:hover:not(:disabled) {
        background: var(--color-primary);
        color: #ffffff;
    }
    .font-scale-btn:disabled {
        border-color: #dbe2ea;
        color: #b6c4d6;
        cursor: not-allowed;
    }
    .font-scale-percent {
        flex: 1;
        text-align: center;
        font-size: 18px;
        font-weight: 700;
        color: #1e293b;
    }
    .font-scale-reset {
        display: block;
        width: 100%;
        min-height: 40px;
        margin-top: 10px;
        border: none;
        border-radius: 10px;
        background: #f1f5f9;
        color: #334155;
        font-family: inherit;
        font-size: 14px;
        cursor: pointer;
    }
    .font-scale-reset:hover:not(:disabled) { background: #e2e8f0; }
    .font-scale-reset:disabled { color: #94a3b8; cursor: default; }
    .font-scale-toggle:focus-visible,
    .font-scale-btn:focus-visible,
    .font-scale-reset:focus-visible {
        outline: 3px solid var(--color-accent);
        outline-offset: 2px;
    }
    .font-scale-control--above-help { bottom: 64px; }
    @media (max-width: 768px) {
        .font-scale-control { right: 14px; bottom: 14px; }
        .font-scale-control--above-help { bottom: 56px; }
    }
    @media print {
        .font-scale-control { display: none; }
    }

    /* Trình duyệt mặc định không cho nút/ô nhập kế thừa font của trang —
       ép kế thừa để mọi nơi đều là Times New Roman. */
    button, input, select, textarea, optgroup {
        font-family: inherit;
    }

/* ---- Lịch sử: lượt làm theo NHÓM ---- */
.history-card--group { border-left: 6px solid #7b5cd6; background: linear-gradient(180deg, #faf7ff 0%, #fff 60%); }
.history-badge--group { background: #efe8ff; color: #5a3fb0; }
.history-badge--group-run { background: #fff4d6; color: #8a5a00; }
.history-group-sub { color: #5b6b86; font-size: 0.9em; margin: 2px 0 8px; }
.history-group-members { background: #faf7ff; border: 2px solid #e1d6fb; border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; }
.history-group-title { font-weight: 800; color: #5a3fb0; margin-bottom: 6px; }
.history-group-member { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; border-radius: 8px; font-size: 0.95em; }
.history-group-member--me { background: #efe8ff; font-weight: 700; }
.history-group-mode { display: inline-block; background: #efe8ff; color: #5a3fb0; border-radius: 999px; padding: 2px 10px; font-size: 0.82em; font-weight: 700; margin-bottom: 6px; }
.history-group-opts { margin: 6px 0; display: grid; gap: 4px; }
.history-group-opt { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 5px 8px; border-radius: 8px; background: #f4f6fb; font-size: 0.92em; }
.history-group-opt--ok { background: #eafcf1; }
.history-group-opt--mine { outline: 2px solid #7b5cd6; }
.history-group-who { color: #5b6b86; font-style: italic; }
.history-group-pts { margin-left: 8px; font-weight: 700; color: #5a3fb0; }


/* ---- Bộ lọc lịch sử (index.php "Lịch sử của em" + giaovien.php "Chi tiết học sinh") ---- */
.hist-filter { background: #fff; border: 2px solid #dbe9f8; border-radius: 16px; padding: 14px 16px; margin-bottom: 18px; display: grid; gap: 14px; box-shadow: 0 2px 8px rgba(45,125,210,0.08); }
.hist-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.hist-filter-label { font-weight: 800; color: #24324a; min-width: 150px; }
.hist-filter-dates { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.hist-date-field { display: grid; gap: 2px; font-size: 0.82em; font-weight: 700; color: #5b6b86; }
.hist-date-field input[type="date"] { border: 2px solid #cfe0f4; border-radius: 10px; padding: 6px 10px; font-size: 1rem; color: #24324a; background: #f7fbff; }
.hist-date-field input[type="date"]:focus { outline: none; border-color: var(--color-primary); background: #fff; }
.hist-date-arrow { color: #8aa0bd; font-weight: 800; padding-bottom: 8px; }
.hist-filter-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-chip-btn { border: 2px solid #cfe0f4; background: #f3f8ff; color: var(--color-primary); font-weight: 700; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 0.95em; transition: background .15s, border-color .15s; }
.hist-chip-btn:hover { background: #e3effd; border-color: var(--color-primary); }
.hist-chip-btn--reset { color: #5b6b86; border-color: #e1e7ef; background: #fff; }
.hist-mode-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.hist-mode-chip { position: relative; cursor: pointer; }
.hist-mode-chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.hist-mode-chip span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 2px solid #e1e7ef; background: #f6f8fb; color: #7a889e; font-weight: 700; font-size: 0.95em; transition: all .15s; user-select: none; }
.hist-mode-chip:hover span { border-color: #b9c7da; }
.hist-mode-chip input:focus-visible + span { outline: 3px solid rgba(45,125,210,0.35); outline-offset: 2px; }
.hist-mode-chip input:checked + span { color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.hist-mode-chip input:checked + span::before { content: "✓"; font-weight: 900; }
.hist-mode-chip--level input:checked + span { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.hist-mode-chip--timed input:checked + span { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.hist-mode-chip--free input:checked + span { background: linear-gradient(135deg, #34d399, #059669); }
.hist-mode-chip--group input:checked + span { background: linear-gradient(135deg, #8b6bdf, #6a46c9); }
.hist-mode-chip--omr input:checked + span { background: linear-gradient(135deg, #14b8a6, #0f766e); }
@media (max-width: 640px) { .hist-filter-label { min-width: 100%; } }

/* Teacher: "⚙️ Cấp độ đạt bậc" — chọn 1 hoặc nhiều chủ đề để áp dụng mẫu cấp độ */
.lvc-step { border: 1px solid #cfe3f7; border-radius: 12px; padding: 8px 14px 14px; margin: 14px 0 0; min-width: 0; background: #fff; }
.lvc-step legend { font-weight: 800; font-size: 0.92rem; color: var(--color-primary); padding: 0 6px; }
.lvc-pick-bar, .lvc-template-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 8px; }
.lvc-pick-bar input[type=search] { flex: 1 1 220px; font-family: inherit; font-size: 0.92rem; padding: 8px 12px; border-radius: 10px; border: 2px solid #cfe3f7; }
.lvc-group-label, .lvc-template-bar label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.85rem; color: #3d4f66; flex-wrap: wrap; }
.lvc-pick-bar select, .lvc-template-bar select { font-family: inherit; font-size: 0.88rem; padding: 7px 10px; border-radius: 10px; border: 2px solid #cfe3f7; max-width: 100%; min-width: 220px; background: #fff; }
.lvc-pick-bar select { max-width: 460px; }
.lvc-pick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.lvc-count { font-weight: 800; color: var(--color-primary); font-size: 0.9rem; margin-right: auto; }
.lvc-mini { font-family: inherit; font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid #b7cee6; background: #fff; color: var(--color-primary); cursor: pointer; white-space: nowrap; }
.lvc-mini:hover { background: #eef6ff; }
.lvc-mini:focus-visible, .lvc-check:focus-visible { outline: 3px solid #9cc8f5; outline-offset: 2px; }
.lvc-nodelist { max-height: 460px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 10px; background: #fbfdff; padding: 6px 10px; }
.lvc-term + .lvc-term { border-top: 1px dashed #d5e4f3; margin-top: 6px; padding-top: 6px; }
.lvc-term-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; position: sticky; top: -6px; background: #fbfdff; padding: 6px 0; font-size: 0.88rem; z-index: 1; }
.lvc-term[hidden], .lvc-item[hidden] { display: none; }
.lvc-item { border-radius: 8px; border: 1px solid transparent; }
.lvc-item + .lvc-item { margin-top: 2px; }
.lvc-item:hover { background: #f1f7ff; }
.lvc-item.selected { background: #e3f0ff; border-color: #b7cee6; }
.lvc-item.child .lvc-item-row { padding-left: 24px; }
.lvc-item-row { display: grid; grid-template-columns: minmax(0, 1fr) 210px 120px 84px; align-items: center; gap: 6px 12px; padding: 5px 6px; }
.lvc-summary { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 0.8rem; color: #3d4f66; }
.lvc-summary-dots { display: inline-flex; gap: 3px; }
.lvc-summary-dots .lvc-dot { margin-right: 0; }
.lvc-summary-text { font-weight: 700; white-space: nowrap; }
.lvc-kind { font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.lvc-kind.is-default { background: #eef1f5; color: #4b5b70; }
.lvc-kind.is-custom { background: #e3f0ff; color: #1f5fa8; }
.lvc-detail-btn { justify-self: end; }
.lvc-pass.is-empty { background: transparent; color: #94a3b8; }
.lvc-pass.has-old { background: #fff3d6; color: #8a5a00; }
.lvc-item-label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600; min-width: 0; }
.lvc-item-label input { margin-top: 3px; flex: none; width: 16px; height: 16px; }
.lvc-item-name { overflow-wrap: anywhere; }
.lvc-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.lvc-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 600; color: #2b3a4f; background: #fff; border: 1px solid #dbe5f0; border-left: 4px solid var(--lv, #f1c40f); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.lvc-chip i { display: none; }
.lvc-chip b { color: #12304f; }
.lvc-chip em { font-style: normal; color: #5a6c85; }
.lvc-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-start; }
.lvc-pass, .lvc-old, .lvc-arch, .lvc-tag { font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.lvc-pass { background: #dcf5e6; color: #1c7a41; }
.lvc-old { background: #fff3d6; color: #8a5a00; }
.lvc-arch, .lvc-tag { background: #eef1f5; color: #4b5b70; }
.lvc-detail-modal { max-width: 640px; width: calc(100% - 32px); }
.lvc-detail-modal h2 { margin-top: 2px; }
.lvc-detail-eyebrow { margin: 0; font-size: 0.78rem; font-weight: 800; color: #5a6c85; text-transform: uppercase; letter-spacing: 0.04em; }
.lvc-detail-modal .lvc-table { margin-top: 6px; }
.lvc-detail-modal .lvc-table th:not(:first-child), .lvc-detail-modal .lvc-table td:not(:first-child) { text-align: center; }
.lvc-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.lvc-table th, .lvc-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eef2f7; }
.lvc-table th { font-size: 0.74rem; color: #5a6c85; font-weight: 800; }
.lvc-table tr.is-archived td { color: #6b7a8f; font-style: italic; }
.lvc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--lv, #f1c40f); margin-right: 6px; vertical-align: middle; border: 1px solid rgba(0, 0, 0, 0.15); }
.lvc-meta { font-size: 0.82rem; color: #4b5b70; margin: 8px 0; }
.lvc-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lvc-history-list { margin: 8px 0 0; padding-left: 20px; font-size: 0.8rem; color: #3d4f66; }
.lvc-history-list li + li { margin-top: 4px; }
.lvc-history-at { font-weight: 800; margin-right: 6px; }
.lvc-history-diff s { color: #94a3b8; }
.lvc-note { font-size: 0.85rem; color: #4b5b70; }
.lvc-dirty { color: #b35c00; font-weight: 800; }
.lvc-warning { background: #fff8e6; border: 1px solid #f3d38b; color: #6b4a00; border-radius: 10px; padding: 8px 12px; font-size: 0.85rem; margin: 6px 0 10px; line-height: 1.5; }
.lvc-warning.hidden { display: none; }
.lvc-sync-note { margin-top: 10px; background: #eefaf3; border: 1px solid #bfe7cf; color: #1f4d33; border-radius: 10px; padding: 10px 14px; font-size: 0.84rem; line-height: 1.5; }
.lvc-sync-note ul { margin: 4px 0 0; padding-left: 20px; }
    /* Thanh "Thêm bậc cao hơn / Áp dụng cho N chủ đề" nằm cố định ở cuối khung
       Bước 2 (luồng tài liệu bình thường, không sticky/fixed nên không trôi theo
       thanh cuộn). */
    .lvc-applybar {
        position: static;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px dashed #dceafc;
    }
.lvc-grow { flex: 1; }
.lvc-applybar .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.lvc-empty { color: #5a6c85; font-size: 0.9rem; }
@media (max-width: 860px) {
    .lvc-item-row { grid-template-columns: minmax(0, 1fr) auto; }
    .lvc-summary { grid-column: 1 / 2; padding-left: 24px; flex-wrap: wrap; }
    .lvc-badges { grid-column: 2 / 3; grid-row: 2; justify-content: flex-end; }
    .lvc-detail-btn { grid-column: 2 / 3; grid-row: 1; }
}
