/* on-luyen.css – Trang Ôn luyện GPLX
   v3.6.1 — 2026-09-15: BỎ khung iPhone 430×844 desktop.
                          Selector .ol-practice-screen{display:grid!important}
                          không có .active đã được vô hiệu.
                          Giữ 992 breakpoint làm last word.
   v3.6.3 — 2026-09-15: Mobile scroll fix.
                          - BỎ nested scroll .ol-options (chỉ .ol-prac-body cuộn)
                          - .ol-opt padding gọn: 8/12, min-height 44, font 14.5
                          - Câu hỏi: ol-q-content font 14.5, padding gọn
                          - Ảnh: max-height 28vh (ảnh nhỏ + đáp án fit màn hình)
                          - Tránh "đáp án bị che dưới" do 2 scroll container chồng
*/

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --ol-blue:    #1565C0;
    --ol-blue-d:  #0D47A1;
    --ol-blue-l:  #1E88E5;
    --ol-blue-p:  #E3F2FD;
    --ol-green:   #388E3C;
    --ol-green-l: #4CAF50;
    --ol-green-p: #E8F5E9;
    --ol-red:     #C62828;
    --ol-red-l:   #EF5350;
    --ol-red-p:   #FFEBEE;
    --ol-yellow:  #FFD600;
    --ol-orange:  #EF6C00;
    --ol-gray:    #F5F5F5;
    --ol-gray2:   #E0E0E0;
    --ol-gray3:   #BDBDBD;
    --ol-text:    #212121;
    --ol-text2:   #37474F;
    --ol-text3:   #78909C;
    --ol-font:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
html { font-size: 16px; }
body {
    font-family: var(--ol-font);
    background: #f0f2f5;
    color: var(--ol-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.ol-header {
    background: var(--ol-blue);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.ol-back-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    display: flex;
    align-items: center;
}
.ol-back-btn:hover { background: rgba(255,255,255,.15); }
.ol-title {
    font-size: 18px;
    font-weight: 500;
    flex: 1;
}
.ol-hang-badge {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 14px;
    font-weight: 600;
}

/* ===== LICENSE SELECTOR (in practice screen) ===== */
.ol-hang-bar {
    background: #fff;
    padding: 8px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--ol-gray2);
}
.ol-hang-chip {
    border: 1.5px solid var(--ol-gray3);
    border-radius: 16px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: #fff;
    color: var(--ol-text2);
    transition: all .15s;
}
.ol-hang-chip:hover { border-color: var(--ol-blue); color: var(--ol-blue); }
.ol-hang-chip.active {
    background: var(--ol-blue);
    border-color: var(--ol-blue);
    color: #fff;
}

/* ===== MAIN CONTENT ===== */
.ol-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
}

/* ===== MODE TABS (đã gộp 1 trang — ẩn) ===== */
.ol-mode-tabs {
    display: none !important;
}
.ol-mode-tab {
    flex: 1;
    padding: 10px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--ol-text3);
    border-bottom: 3px solid transparent;
    transition: all .15s;
}
.ol-mode-tab:hover { color: var(--ol-blue); }
.ol-mode-tab.active {
    color: var(--ol-blue);
    border-bottom-color: var(--ol-blue);
    font-weight: 600;
}

/* ===== MENU SECTIONS ===== */
.ol-section,
.ol-section.active { display: block; }
.ol-card.ol-focus-target {
    outline: 2px solid #0284c7;
    box-shadow: 0 0 0 4px rgba(2,132,199,.18);
    scroll-margin-top: 72px;
}

.ol-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    overflow: hidden;
    margin-bottom: 16px;
}
.ol-card-header {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ol-blue);
    border-bottom: 1px solid var(--ol-gray2);
    display: flex;
    align-items: center;
    gap: 8px;
}
.ol-card-header .icon { font-size: 18px; }
.ol-card-body { padding: 12px; }

/* ===== FIXED EXAM SETS (2-column grid) ===== */
.ol-de-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}
.ol-de-btn {
    border: 1.5px solid var(--ol-gray2);
    border-radius: 6px;
    padding: 8px 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: #fff;
    color: var(--ol-text2);
    transition: all .15s;
}
.ol-de-btn:hover {
    border-color: var(--ol-blue);
    color: var(--ol-blue);
    background: var(--ol-blue-p);
}
.ol-de-btn:active {
    background: var(--ol-blue);
    color: #fff;
}

/* ===== PRACTICE TYPE BUTTONS ===== */
.ol-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.ol-menu-item {
    border: 1.5px solid var(--ol-gray2);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    background: #fff;
    text-align: left;
    transition: all .2s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.ol-menu-item:hover {
    border-color: var(--ol-blue);
    background: var(--ol-blue-p);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21,101,192,.15);
}
.ol-menu-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--ol-blue-p);
    color: var(--ol-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.ol-menu-item:hover .ol-menu-icon {
    background: var(--ol-blue);
    color: #fff;
}
.ol-menu-text h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ol-text);
    margin-bottom: 4px;
}
.ol-menu-text p {
    font-size: 12px;
    color: var(--ol-text3);
    line-height: 1.4;
}

/* Critical item gets special red accent */
.ol-menu-item.critical { border-color: #FFCDD2; }
.ol-menu-item.critical:hover { border-color: var(--ol-red); background: var(--ol-red-p); }
.ol-menu-item.critical .ol-menu-icon { background: #FFCDD2; color: var(--ol-red); }
.ol-menu-item.critical:hover .ol-menu-icon { background: var(--ol-red); color: #fff; }

/* ===== PROGRESS BAR CHO BẢNG THÀNH TÍCH ÔN LUYỆN ===== */
.ol-progress-card {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg,#F8FAFC,#F1F5F9);
    border: 1px solid #E2E8F0;
    border-radius: 10px;
}
.ol-progress-card .ol-progress-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; color: var(--ol-text3); margin-bottom: 6px;
}
.ol-progress-card .ol-progress-head strong { color: var(--ol-blue); font-size: 13px; }
.ol-progress-bar {
    width: 100%;
    height: 10px;
    background: #E2E8F0;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.ol-progress-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ol-blue-l), var(--ol-blue));
    transition: width .35s ease;
    border-radius: 999px;
}
.ol-progress-bar.full > span { background: linear-gradient(90deg,#22C55E,#16A34A); }
.ol-progress-bar.partial > span { background: linear-gradient(90deg,#F59E0B,#D97706); }
.ol-progress-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 8px;
    margin-top: 10px;
    font-size: 11.5px;
    color: var(--ol-text3);
}
.ol-progress-stats .lbl { font-size: 10.5px; opacity: .85; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.ol-progress-stats .val { font-size: 14px; font-weight: 800; color: var(--ol-text); }
.ol-progress-stats .val.green { color: #15803D; }
.ol-progress-stats .val.red   { color: #B91C1C; }

/* ===== CHAPTER GRID — desktop gọn như mobile ===== */
.ol-chapter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}
.ol-chapter-btn {
    border: none;
    border-radius: 12px;
    padding: 14px 10px;
    cursor: pointer;
    background: #f1f5f9;
    text-align: center;
    transition: all .18s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: none;
    min-height: 88px;
}
.ol-chapter-btn:hover {
    background: var(--ol-blue);
    color: #fff;
    transform: translateY(-2px);
}
.ol-chapter-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ol-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all .18s;
}
.ol-chapter-btn:hover .ol-chapter-num { background: #fff; color: var(--ol-blue); }
.ol-chapter-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ol-text);
    margin: 0;
    transition: color .18s;
}
.ol-chapter-info p {
    font-size: 11.5px;
    color: var(--ol-text3);
    margin: 0;
    line-height: 1.35;
    transition: color .18s;
}
.ol-chapter-btn:hover .ol-chapter-info h4 { color: #fff; }
.ol-chapter-btn:hover .ol-chapter-info p { color: rgba(255,255,255,0.85); }

/* ===== RANGE GRID ===== */
.ol-range-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.ol-range-btn {
    border: 1.5px solid var(--ol-gray2);
    border-radius: 6px;
    padding: 10px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: #fff;
    color: var(--ol-text2);
    transition: all .15s;
}
.ol-range-btn:hover { border-color: var(--ol-blue); color: var(--ol-blue); background: var(--ol-blue-p); }

/* Custom range input */
.ol-custom-range {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    flex-wrap: wrap;
}
.ol-custom-range input[type=number] {
    width: 80px;
    padding: 8px;
    border: 1.5px solid var(--ol-gray3);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}
.ol-custom-range input:focus { outline: none; border-color: var(--ol-blue); }
.ol-custom-range span { color: var(--ol-text3); font-size: 14px; }
.ol-custom-go {
    padding: 8px 20px;
    background: var(--ol-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.ol-custom-go:hover { background: var(--ol-blue-d); }

/* ===== PRACTICE SCREEN (question view) ===== */
.ol-practice-screen {
    display: none;
    position: fixed;
    inset: 0;
    background: #f0f2f5;
    z-index: 200;
    flex-direction: column;
}
.ol-practice-screen.active { display: flex; }

/* Practice header */
.ol-prac-header {
    background: var(--ol-blue);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.ol-prac-title-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
}
.ol-prac-progress {
    font-size: 13px;
    opacity: .85;
    white-space: nowrap;
}
.ol-prac-close {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ol-prac-close:hover { background: rgba(255,255,255,.35); }

/* Practice body: question + answer + explanation */
.ol-prac-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
}

/* Question card */
.ol-q-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    overflow: hidden;
    margin-bottom: 12px;
}
.ol-q-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--ol-gray2);
    font-size: 13px;
    color: var(--ol-text3);
}
.ol-q-num {
    font-weight: 700;
    color: var(--ol-blue);
}
.ol-q-critical-badge {
    background: var(--ol-red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: .5px;
}
.ol-q-chapter-tag {
    margin-left: auto;
    font-size: 11px;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}
.ol-q-content {
    padding: 14px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--ol-text);
}
.ol-q-image {
    display: block;
    max-width: 100%;
    max-height: 300px;
    margin: 8px auto;
    border-radius: 4px;
    border: 1px solid var(--ol-gray2);
}

/* Options */
.ol-options { padding: 0 14px 14px; }
.ol-opt {
    border: 2px solid var(--ol-gray2);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: all .15s;
    font-size: 14px;
    line-height: 1.5;
}
.ol-opt:hover { border-color: var(--ol-blue); background: var(--ol-blue-p); }
.ol-opt.selected { border-color: var(--ol-blue); background: var(--ol-blue-p); }
.ol-opt.correct { border-color: var(--ol-green); background: var(--ol-green-p); }
.ol-opt.wrong { border-color: var(--ol-red); background: var(--ol-red-p); }
.ol-opt.disabled { cursor: default; pointer-events: none; }
.ol-opt-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--ol-gray3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    color: var(--ol-text3);
    background: #fff;
}
.ol-opt.selected .ol-opt-num { border-color: var(--ol-blue); color: var(--ol-blue); background: var(--ol-blue-p); }
.ol-opt.correct .ol-opt-num { border-color: var(--ol-green); color: var(--ol-green); background: var(--ol-green); color: #fff; }
.ol-opt.wrong .ol-opt-num { border-color: var(--ol-red); color: var(--ol-red); background: var(--ol-red); color: #fff; }

/* Explanation */
.ol-explanation {
    background: #FFF8E1;
    border: 1px solid #FFE082;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 0 14px 14px;
    font-size: 13.5px;
    line-height: 1.6;
    color: #5D4037;
}
.ol-explanation::before {
    content: '💡 Giải thích: ';
    font-weight: 700;
    color: var(--ol-orange);
}
.ol-explanation.no-expl::before {
    content: '✓ Đáp án đúng.';
    font-weight: 700;
    color: var(--ol-green);
}

/* Practice nav footer */
.ol-prac-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid var(--ol-gray2);
    padding: 10px 12px 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--nav-extra, 52px));
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 -6px 20px rgba(0,0,0,.12);
    flex-shrink: 0;
    max-height: none;
    overflow: visible;
}
.ol-prac-nav-btn {
    padding: 8px 18px;
    border: 1.5px solid var(--ol-gray3);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--ol-text2);
    transition: all .15s;
}
.ol-prac-nav-btn:hover { border-color: var(--ol-blue); color: var(--ol-blue); }
.ol-prac-nav-btn:disabled { opacity: .4; cursor: default; }
.ol-prac-nav-btn.primary {
    background: var(--ol-blue);
    border-color: var(--ol-blue);
    color: #fff;
}
.ol-prac-nav-btn.primary:hover { background: var(--ol-blue-d); }
.ol-prac-answers {
    flex: 1;
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-height: 34px;
    align-items: center;
}
.ol-prac-answers::-webkit-scrollbar { display: none; }
.ol-prac-qdot {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1.5px solid var(--ol-gray3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: var(--ol-text3);
    transition: all .1s;
}
.ol-prac-qdot:hover { border-color: var(--ol-blue); color: var(--ol-blue); }
.ol-prac-qdot.current { border-color: var(--ol-blue); background: var(--ol-blue); color: #fff; }
.ol-prac-qdot.answered { border-color: var(--ol-green); background: var(--ol-green-p); color: var(--ol-green); }
.ol-prac-qdot.correct-dot { border-color: var(--ol-green); background: var(--ol-green); color: #fff; }
.ol-prac-qdot.wrong-dot { border-color: var(--ol-red); background: var(--ol-red); color: #fff; }
.ol-sum-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 6px;
    max-width: 420px;
    margin: 0 auto 10px;
}
.ol-sum-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 800;
}
.ol-sum-cell.ok { background: #16a34a; color: #fff; }
.ol-sum-cell.bad { background: #dc2626; color: #fff; }
.ol-sum-cell.skip { background: #e2e8f0; color: #64748b; }
.ol-sum-leg { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: #64748b; }
.ol-sum-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.ol-sum-leg i.ok { background: #16a34a; }
.ol-sum-leg i.bad { background: #dc2626; }

/* Result bar */
.ol-result-bar {
    background: var(--ol-green-p);
    border: 1px solid var(--ol-green);
    border-radius: 6px;
    padding: 8px 14px;
    margin: 0 14px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ol-green);
    text-align: center;
}
.ol-result-bar.fail { background: var(--ol-red-p); border-color: var(--ol-red); color: var(--ol-red); }

/* ===== LOADING ===== */
.ol-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--ol-text3);
}
.ol-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--ol-gray2);
    border-top-color: var(--ol-blue);
    border-radius: 50%;
    animation: ol-spin .8s linear infinite;
    margin-bottom: 12px;
}
@keyframes ol-spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .ol-menu-grid { grid-template-columns: 1fr; }
    .ol-chapter-grid { grid-template-columns: 1fr; }
    .ol-de-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
    .ol-prac-qdot { width: 22px; height: 22px; font-size: 10px; }
    .ol-prac-answers { gap: 2px; max-height: 30px; }
}

/* Mobile tối ưu thiết bị thật */
@media (max-width: 480px) {
    html { font-size: 15px; }

    /* Header compact */
    .ol-header { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
    .ol-title { font-size: 15px; }
    .ol-hang-badge { width: 36px; height: 36px; font-size: 12px; }

    /* Hang bar scroll ngang */
    .ol-hang-bar { padding: 8px 12px; gap: 6px; overflow-x: auto; }
    .ol-hang-chip { padding: 6px 12px; font-size: 12px; min-height: 32px; }

    /* Main padding */
    .ol-main { padding: 12px; }
    .ol-card { margin-bottom: 12px; }
    .ol-card-body { padding: 12px; }

    /* Menu items lớn hơn */
    .ol-menu-item { padding: 12px; min-height: 64px; }
    .ol-menu-icon { width: 40px; height: 40px; font-size: 22px; }
    .ol-menu-text h3 { font-size: 14px; }
    .ol-menu-text p { font-size: 12px; }

    /* Chapter cards - FIX: 4 cột, không border/shadow, font lớn, nút xám đổi màu xanh khi hover */
    .ol-chapter-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .ol-chapter-btn {
        padding: 12px 6px;
        background: #f1f5f9;
        border: none;
        border-radius: 8px;
        box-shadow: none;
    }
    .ol-chapter-btn:hover {
        background: var(--ol-blue);
        color: #fff;
    }
    .ol-chapter-num {
        width: 32px;
        height: 32px;
        font-size: 13px;
        background: var(--ol-blue);
        color: #fff;
    }
    .ol-chapter-btn:hover .ol-chapter-num {
        background: #fff;
        color: var(--ol-blue);
    }
    .ol-chapter-info h4 {
        font-size: 13px;
        font-weight: 600;
    }
    .ol-chapter-info p {
        font-size: 10px;
        color: var(--ol-text3);
        line-height: 1.3;
    }
    .ol-chapter-btn:hover .ol-chapter-info h4 { color: #fff; }
    .ol-chapter-btn:hover .ol-chapter-info p { color: rgba(255,255,255,0.8); }

    /* Range buttons */
    .ol-range-btn { padding: 10px; min-height: 44px; font-size: 13px; }
    .ol-custom-range { flex-wrap: wrap; gap: 8px; }
    .ol-custom-range input { width: 70px; padding: 10px; font-size: 14px; }

    /* Practice screen */
    .ol-prac-header { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
    .ol-prac-close { width: 36px; height: 36px; font-size: 16px; }
    .ol-prac-title-bar { font-size: 14px; }
    .ol-prac-progress { font-size: 11px; }

    .ol-q-card { margin: 8px; padding: 12px; }
    .ol-q-content { font-size: 14px; line-height: 1.5; }
    .ol-q-image { max-height: 220px; margin: 10px 0; }
    .ol-opt {
        padding: 14px 12px;
        margin-bottom: 8px;
        font-size: 14px;
        min-height: 52px; /* vùng chạm lớn hơn cho ngón tay */
        border-radius: 8px;
    }
    .ol-opt-num { width: 28px; height: 28px; font-size: 13px; font-weight: 700; }

    /* Badge điểm liệt nổi bật trên mobile */
    .ol-q-critical-badge {
        display: inline-block;
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fecaca;
        font-size: 11px;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 4px;
        margin-left: 6px;
        letter-spacing: 0.3px;
    }

    /* Practice footer */
    .ol-prac-footer {
        position: fixed !important;
        left: 0; right: 0; bottom: 0;
        padding: 10px 8px 0;
        gap: 6px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--nav-extra, 52px));
        background: #fff;
        border-top: 1px solid var(--ol-gray2);
        flex-shrink: 0;
        max-height: none;
        overflow: visible;
        z-index: 100;
        box-shadow: 0 -6px 20px rgba(0,0,0,.14);
    }
    .ol-prac-body, .ol-practice-screen .ol-prac-body {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px) + var(--nav-extra, 52px)) !important;
    }
    .ol-prac-nav-btn { padding: 10px; min-height: 44px; font-size: 13px; }

    /* Mode tabs */
    .ol-mode-tabs { padding: 8px 12px; }
    .ol-mode-tab { padding: 8px 12px; min-height: 36px; font-size: 13px; }

    /* Wrong card */
    .ol-wrong-count { font-size: 11px !important; padding: 2px 8px !important; }
}

/* Safe area cho iPhone notch */
@supports (padding: max(0px)) {
    .ol-header {
        padding-top: max(10px, env(safe-area-inset-top));
    }
    .ol-prac-footer {
        padding-bottom: max(16px, calc(12px + env(safe-area-inset-bottom, 0px)));
    }
}

/* Touch target & feedback */
.ol-opt, .ol-menu-item, .ol-range-btn, .ol-chapter-btn,
.ol-hang-chip, .ol-prac-nav-btn, .ol-mode-tab, .ol-de-btn,
.ol-prac-qdot, .ol-prac-close, #btnWrongQuestions, .ol-btn-text,
#btnResetWrong, #btnCritical, #btnRandomExam {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(21, 101, 192, 0.15);
}

.ol-opt:active, .ol-menu-item:active, .ol-range-btn:active,
.ol-chapter-btn:active, .ol-prac-qdot:active {
    opacity: 0.85;
}

/* Landscape: header ngang gọn */
@media (max-width: 900px) and (orientation: landscape) {
    .ol-header { padding: 6px 12px; }
    .ol-card { padding: 8px; }
    .ol-card-body { padding: 10px; }
}

/* ============================================================
   FIXED SET CARDS — Thẻ bộ đề với progress + badge đạt/chưa đạt
   (dùng cho 30 bộ đề cố định ở mỗi hạng)
============================================================ */
.ol-de-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    width: 100%;
}
.ol-de-card {
    background: #fff;
    border: 1px solid var(--ol-gray2);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all .18s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    font: inherit;
    color: var(--ol-text);
    position: relative;
    overflow: hidden;
    min-height: 110px;
}
.ol-de-card:hover {
    border-color: var(--ol-blue);
    box-shadow: 0 6px 18px rgba(21,101,192,.12);
    transform: translateY(-1px);
}
.ol-de-card:active {
    transform: scale(.98);
}
.ol-de-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.ol-de-num {
    font-size: 16px;
    font-weight: 700;
    color: var(--ol-text);
}
.ol-set-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1.2;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.ol-set-pass {
    background: var(--ol-green-p);
    color: var(--ol-green);
    border: 1px solid var(--ol-green);
}
.ol-set-fail {
    background: var(--ol-red-p);
    color: var(--ol-red);
    border: 1px solid var(--ol-red);
}
.ol-set-progress {
    background: var(--ol-blue-p);
    color: var(--ol-blue);
    border: 1px solid var(--ol-blue);
}
.ol-set-new {
    background: #F5F5F5;
    color: var(--ol-text3);
    border: 1px dashed var(--ol-gray3);
}
.ol-set-meta {
    font-size: 12px;
    color: var(--ol-text3);
    line-height: 1.4;
}
.ol-set-correct { color: var(--ol-green); font-weight: 600; }
.ol-set-wrong   { color: var(--ol-red);   font-weight: 600; }
.ol-de-progress {
    height: 4px;
    background: var(--ol-gray);
    border-radius: 2px;
    overflow: hidden;
}
.ol-de-progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ol-blue), var(--ol-blue-l));
    border-radius: 2px;
    transition: width .4s ease;
}
.ol-de-card[data-completed="true"][data-passed="true"] .ol-de-progress > span {
    background: linear-gradient(90deg, var(--ol-green), var(--ol-green-l));
}
.ol-de-card[data-completed="true"][data-passed="false"] .ol-de-progress > span {
    background: linear-gradient(90deg, var(--ol-red), var(--ol-red-l));
}

/* Responsive: mobile 2 cột - thu gọn để không chiếm quá nhiều không gian */
@media (max-width: 600px) {
    .ol-de-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
    .ol-de-card { padding: 6px 4px; min-height: 55px; }
    .ol-de-num { font-size: 12px; }
    .ol-set-badge { font-size: 8px; padding: 1px 3px; }
    .ol-set-meta { display: none; }
    .ol-card { margin-bottom: 8px; }
    .ol-card-body { padding: 8px; }
}
@media (max-width: 360px) {
    .ol-de-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   WRONG QUESTION ITEMS — Kho câu sai với streak dots
============================================================ */
.ol-wrong-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ol-gray2);
    font-size: 13px;
}
.ol-wrong-item:last-child {
    border-bottom: none;
}
.ol-wrong-num {
    min-width: 38px;
    color: var(--ol-text3);
    font-weight: 600;
    font-size: 13px;
    background: var(--ol-gray);
    text-align: center;
    padding: 4px 0;
    border-radius: 6px;
}
.ol-wrong-info {
    flex: 1;
    min-width: 0;
}
.ol-wrong-streak {
    font-size: 13px;
    color: var(--ol-text);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ol-wrong-date {
    font-size: 11px;
    color: var(--ol-text3);
    margin-top: 2px;
}

/* ====== Streak Badge (Dùng trong practice lẫn preview) ====== */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.streak-soft {
    background: var(--ol-blue-p);
    color: var(--ol-blue);
    border: 1px solid var(--ol-blue);
}
.streak-warn {
    background: var(--ol-green-p);
    color: var(--ol-green);
    border: 1px solid var(--ol-green);
}
.streak-dots {
    display: inline-flex;
    gap: 3px;
}
.streak-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0,0,0,.12);
    transition: all .2s ease;
}
.streak-dot.on {
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(76,175,80,.18);
}
.streak-soft .streak-dot.on { background: var(--ol-blue); }
.streak-warn .streak-dot.on { background: var(--ol-green); }

/* ====== Progress Card (nếu chưa có) ====== */
.ol-progress-card {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #FAFCFF 0%, #F0F7FF 100%);
    border: 1px solid var(--ol-blue-p);
    border-radius: 12px;
    font-size: 13px;
}
.ol-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    gap: 8px;
}
.ol-progress-head strong {
    color: var(--ol-text);
    font-size: 13px;
}
.ol-progress-head > span {
    color: var(--ol-blue);
    font-size: 12px;
    font-weight: 600;
}
.ol-progress-bar {
    height: 8px;
    background: var(--ol-gray);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.ol-progress-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ol-blue), var(--ol-blue-l));
    border-radius: 4px;
    transition: width .4s ease;
}
.ol-progress-bar.partial > span {
    background: linear-gradient(90deg, var(--ol-yellow), var(--ol-orange));
}
.ol-progress-bar.full > span {
    background: linear-gradient(90deg, var(--ol-green), var(--ol-green-l));
}
.ol-progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
}
.ol-progress-stats > div {
    background: #fff;
    border: 1px solid var(--ol-gray2);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
}
.ol-progress-stats .lbl {
    font-size: 10px;
    color: var(--ol-text3);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ol-progress-stats .val {
    font-size: 14px;
    font-weight: 700;
    color: var(--ol-text);
}
.ol-progress-stats .val.green { color: var(--ol-green); }
.ol-progress-stats .val.red { color: var(--ol-red); }
.ol-progress-stats .val.gray { color: var(--ol-text3); }

/* Grid đề cố định: cập nhật container nếu trước đó dùng ol-de-btn */
#fixedSetsGrid.ol-de-grid {}
.ol-de-btn { display: none; } /* Ẩn class cũ để tránh xung đột layout */

/* Touch targets cho card đề */
.ol-de-card { touch-action: manipulation; -webkit-tap-highlight-color: rgba(21,101,192,.15); }
.ol-de-card:active { transform: scale(.97); }

/* ==========================================================================
   MOBILE-FIRST APP-NATIVE LAYOUT (<= 768px) — Ôn luyện
   ========================================================================== */
@media (max-width: 768px) {
    /* Header sticky — app-native */
    .ol-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    /* Thanh tìm kiếm thu gọn trên mobile */
    .ol-search-bar {
        padding: 5px 10px;
    }
    .ol-search-input {
        padding: 6px 12px;
        font-size: 13px;
        border-radius: 18px;
    }
    .ol-search-input::placeholder {
        font-size: 13px;
    }

    /* Practice screen: full viewport app-native */
    .ol-practice-screen {
        display: none;
        position: fixed;
        inset: 0;
        background: #fff;
        z-index: 500;
        flex-direction: column;
        overflow: hidden;
    }
    .ol-practice-screen.active { display: flex; }

    /* Practice header */
    .ol-prac-header {
        background: #fff;
        color: #1e293b;
        border-bottom: 1.5px solid #e2e8f0;
        padding: 0 12px;
        height: 50px;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
        position: relative;
        padding-top: max(env(safe-area-inset-top, 0px), 0px);
        box-shadow: none;
    }
    .ol-prac-close {
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        color: #475569;
        font-size: 15px;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }
    .ol-prac-close:active { background: #e2e8f0; }
    .ol-prac-title-bar {
        flex: 1;
        font-size: 14px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ol-prac-progress {
        font-size: 13px;
        color: #64748b;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Practice body — scrollable */
    .ol-prac-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        background: #f8fafc;
        max-width: 100%;
        margin: 0;
    }

    /* Question card — full width */
    .ol-q-card {
        background: #fff;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
        overflow: visible;
    }
    .ol-q-header {
        padding: 10px 14px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
    }
    .ol-q-num {
        font-weight: 700;
        color: #0284c7;
    }
    .ol-q-critical-badge {
        background: #dc2626;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        padding: 2px 6px;
        border-radius: 3px;
        flex-shrink: 0;
    }
    .ol-q-chapter-tag {
        margin-left: auto;
        font-size: 11px;
        background: #f1f5f9;
        color: #64748b;
        padding: 1px 8px;
        border-radius: 3px;
    }

    .ol-q-content {
        padding: 14px 14px 12px;
        font-size: 16px;
        line-height: 1.5;
        font-weight: 600;
        color: #1e293b;
        border-bottom: 1px solid #f1f5f9;
    }
    .ol-q-content.is-critical { color: #b91c1c; }
    .ol-q-image {
        display: block;
        max-width: 100%;
        max-height: 220px;
        margin: 8px 0;
        border-radius: 0;
        border: none;
    }

    /* Options — app-native row */
    .ol-options { padding: 4px 12px 12px; }
    .ol-opt {
        border: none;
        border-bottom: 1px solid #e2e8f0;
        border-radius: 0;
        padding: 13px 12px;
        margin-bottom: 0;
        gap: 12px;
        min-height: 52px;
        display: flex;
        align-items: center;
        transition: background 0.12s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2,132,199,0.08);
    }
    .ol-opt:last-child { border-bottom: none; }
    .ol-opt:hover { background: #f8fafc; border-color: #e2e8f0; }
    .ol-opt:active { background: #e0f2fe; }
    .ol-opt.selected { background: #e0f2fe !important; border-color: #0284c7 !important; }
    .ol-opt.correct { background: #dcfce7 !important; border-color: #16a34a !important; }
    .ol-opt.wrong { background: #fee2e2 !important; border-color: #dc2626 !important; }

    .ol-opt-num {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-radius: 50% !important;
        border: 1.5px solid #64748b !important;
        background: #fff !important;
        font-size: 14px;
        font-weight: 700;
        color: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: all 0.12s;
    }
    .ol-opt.selected .ol-opt-num { background: #0284c7 !important; border-color: #0284c7 !important; color: #fff !important; }
    .ol-opt.correct .ol-opt-num { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }
    .ol-opt.wrong .ol-opt-num { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }

    /* Explanation */
    .ol-explanation {
        margin: 8px 12px 12px;
        border-radius: 6px;
    }

    /* Fixed footer nav */
    .ol-prac-footer {
        position: fixed !important;
        left: 0; right: 0; bottom: 0;
        z-index: 300;
        display: flex !important;
        align-items: center;
        height: 54px;
        padding: 0;
        background: #fff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        gap: 0;
    }

    .ol-prac-nav-btn {
        width: 54px;
        min-width: 54px;
        height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        font-weight: 300;
        background: #fff;
        border: none;
        border-top: 2px solid transparent;
        cursor: pointer;
        color: #0284c7;
        transition: background 0.12s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2,132,199,0.1);
        border-radius: 0;
        padding: 0;
    }
    .ol-prac-nav-btn:active { background: #f0f9ff; }
    .ol-prac-nav-btn:disabled { color: #cbd5e1; cursor: not-allowed; }
    .ol-prac-nav-btn.primary {
        background: #fff;
        color: #0284c7;
        font-size: 12px;
        font-weight: 700;
        width: auto;
        flex: 1;
        padding: 0 16px;
        flex-direction: column;
        gap: 1px;
        border-top: 2px solid transparent;
    }
    .ol-prac-nav-btn.primary:active { background: #f0f9ff; }

    /* Q-dots strip */
    .ol-prac-answers {
        flex: 1;
        height: 54px;
        display: flex;
        align-items: center;
        gap: 3px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 4px;
    }
    .ol-prac-answers::-webkit-scrollbar { display: none; }
    .ol-prac-qdot {
        width: 28px;
        height: 28px;
        min-width: 28px;
        border-radius: 6px;
        border: 1px solid #cbd5e1;
        background: #fff;
        font-size: 11px;
        font-weight: 600;
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: all 0.1s;
    }
    .ol-prac-qdot:active { transform: scale(0.9); }
    .ol-prac-qdot.current { border-color: #0284c7; background: #e0f2fe; color: #0284c7; }
    .ol-prac-qdot.answered { border-color: #86efac; background: #dcfce7; color: #15803d; }
    .ol-prac-qdot.correct-dot { border-color: #16a34a; background: #16a34a; color: #fff; }
    .ol-prac-qdot.wrong-dot { border-color: #dc2626; background: #dc2626; color: #fff; }

    /* Swipe touch target */
    .ol-prac-body {
        touch-action: pan-y;
    }
}

/* Touch targets min 44px everywhere */
.ol-opt, .ol-prac-qdot, .ol-prac-nav-btn, .ol-prac-close {
    touch-action: manipulation;
}

/* ==========================================================================
   MOBILE-FIRST PRACTICE SCREEN (<= 768px) — App-native clean layout
   ========================================================================== */
@media (max-width: 768px) {
    /* Ẩn tất cả header/desktop nav */
    .ol-header,
    .ol-header *,
    .ol-hang-bar,
    .ol-hang-bar * { display: none !important; }

    /* Practice screen full viewport */
    .ol-practice-screen {
        display: none;
        position: fixed;
        inset: 0;
        background: #fff;
        z-index: 500;
        flex-direction: column;
        overflow: hidden;
    }
    .ol-practice-screen.active { display: flex; }

    /* Practice header — trắng, compact */
    .ol-prac-header {
        background: #fff;
        color: #1e293b;
        border-bottom: 1.5px solid #e2e8f0;
        padding: 0 10px;
        height: 46px;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        padding-top: max(env(safe-area-inset-top, 0px), 0px);
    }
    .ol-prac-close {
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        color: #475569;
        font-size: 15px;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }
    .ol-prac-close:active { background: #e2e8f0; }
    .ol-prac-title-bar {
        flex: 1;
        font-size: 13px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ol-prac-progress {
        font-size: 12px;
        color: #64748b;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Practice body */
    .ol-prac-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0;
        background: #fff;
        min-height: 0;
    }

    /* Question card */
    .ol-q-card {
        background: #fff;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
    }
    .ol-q-header {
        padding: 8px 14px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 12px;
    }
    .ol-q-num {
        font-weight: 700;
        color: #0284c7;
    }
    .ol-q-critical-badge {
        background: #dc2626;
        color: #fff;
        font-size: 9.5px;
        font-weight: 700;
        padding: 1px 5px;
        border-radius: 3px;
        flex-shrink: 0;
    }
    .ol-q-chapter-tag {
        margin-left: auto;
        font-size: 11px;
        background: #f1f5f9;
        color: #64748b;
        padding: 1px 8px;
        border-radius: 3px;
    }

    /* Câu hỏi */
    .ol-q-content {
        padding: 11px 14px 10px;
        font-size: 15px;
        line-height: 1.5;
        font-weight: 600;
        color: #1e293b;
        border-bottom: 1px solid #f1f5f9;
        word-break: break-word;
    }
    .ol-q-content.is-critical { color: #b91c1c; }
    .ol-q-image {
        display: block;
        max-width: 100%;
        max-height: 170px;
        width: auto;
        height: auto;
        object-fit: contain;
        margin: 8px auto;
    }

    /* Đáp án */
    .ol-options { padding: 2px 0 4px; }
    .ol-opt {
        border: none;
        border-bottom: 1px solid #f1f5f9;
        border-radius: 0;
        padding: 11px 14px;
        margin-bottom: 0;
        gap: 11px;
        min-height: 50px;
        display: flex;
        align-items: center;
        transition: background 0.1s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2, 132, 199, 0.06);
    }
    .ol-opt:last-child { border-bottom: none; }
    .ol-opt:hover  { background: #f8fafc; }
    .ol-opt:active { background: #dbeafe; }
    .ol-opt.selected { background: #e0f2fe !important; }
    .ol-opt.correct { background: #dcfce7 !important; }
    .ol-opt.wrong   { background: #fee2e2 !important; }

    .ol-opt-num {
        width: 30px;
        height: 30px;
        min-width: 30px;
        border-radius: 50% !important;
        border: 1.5px solid #64748b !important;
        background: #fff !important;
        font-size: 13px;
        font-weight: 700;
        color: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: all 0.1s;
    }
    .ol-opt.selected .ol-opt-num { background: #0284c7 !important; border-color: #0284c7 !important; color: #fff !important; }
    .ol-opt.correct .ol-opt-num { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }
    .ol-opt.wrong   .ol-opt-num { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }

    /* Explanation */
    .ol-explanation { margin: 6px 14px 12px; border-radius: 6px; }

    /* Footer nav — 3 nút */
    .ol-prac-footer {
        position: fixed !important;
        left: 0; right: 0; bottom: 0;
        z-index: 300;
        display: flex !important;
        align-items: center;
        height: 54px;
        padding: 0;
        background: #fff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -3px 14px rgba(0,0,0,0.09);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        gap: 0;
    }

    .ol-prac-nav-btn {
        width: 54px;
        min-width: 54px;
        height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        font-weight: 300;
        background: #fff;
        border: none;
        border-top: 2px solid transparent;
        cursor: pointer;
        color: #0284c7;
        transition: background 0.1s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2,132,199,0.08);
        border-radius: 0;
        padding: 0;
    }
    .ol-prac-nav-btn:active { background: #f0f9ff; }
    .ol-prac-nav-btn:disabled { color: #cbd5e1; cursor: default; }
    .ol-prac-nav-btn.primary {
        background: #fff;
        color: #0284c7;
        font-size: 13px;
        font-weight: 700;
        width: auto;
        flex: 1;
        padding: 0 16px;
        flex-direction: column;
        gap: 1px;
    }
    .ol-prac-nav-btn.primary:active { background: #f0f9ff; }

    /* Q-dots strip */
    .ol-prac-answers {
        flex: 1;
        height: 54px;
        display: flex;
        align-items: center;
        gap: 2px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 4px;
    }
    .ol-prac-answers::-webkit-scrollbar { display: none; }
    .ol-prac-qdot {
        width: 26px;
        height: 26px;
        min-width: 26px;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
        background: #fff;
        font-size: 11px;
        font-weight: 600;
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: all 0.1s;
    }
    .ol-prac-qdot:active { transform: scale(0.9); }
    .ol-prac-qdot.current { border-color: #0284c7; background: #e0f2fe; color: #0284c7; }
    .ol-prac-qdot.answered { border-color: #86efac; background: #dcfce7; color: #15803d; }
    .ol-prac-qdot.correct-dot { border-color: #16a34a; background: #16a34a; color: #fff; }
    .ol-prac-qdot.wrong-dot { border-color: #dc2626; background: #dc2626; color: #fff; }
}

/* ==========================================================================
   MOBILE-FIRST PRACTICE SCREEN (<= 768px) — 4 KHỐI NO-SCROLL chuẩn thi.html
   ========================================================================== */
@media (max-width: 768px) {

    /* ===== 1. NO-SCROLL CHỈ KHI ĐANG ÔN — KHÔNG khóa trang chọn đề ===== */
    body.practice-active {
        margin: 0;
        padding: 0;
        height: 100dvh;
        overflow: hidden; /* Ngăn cuộn toàn trang — KHÔNG position:fixed (chặn touch) */
        touch-action: manipulation;
    }

    /* Khung màn hình ôn */
    .ol-practice-screen {
        height: 100dvh;
        max-height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* ===== 2. ẨN PHẦN RƯỜM RÀ ===== */
    .ol-header,
    .ol-header *,
    .ol-hang-bar,
    .ol-hang-bar * { display: none !important; }

    /* ===== 3. PRACTICE SCREEN — full viewport flex 4 khối ===== */
    .ol-practice-screen {
        display: none;
        position: fixed;
        inset: 0;
        background: #fff;
        z-index: 500;
        flex-direction: column;
        overflow: hidden;
        padding: 0 !important;
        margin: 0 !important;
    }
    .ol-practice-screen.active { display: flex; }

    /* ===== 4. KHỐI 1: HEADER (44px) — Thoát | Tiêu đề | progress ===== */
    .ol-prac-header {
        background: #fff;
        color: #1e293b;
        border-bottom: 1.5px solid #e2e8f0;
        padding: 0 8px;
        height: 44px;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
        padding-top: max(env(safe-area-inset-top, 0px), 0px);
    }
    .ol-prac-close {
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        color: #475569;
        font-size: 13px;
        font-weight: 600;
        height: 32px;
        padding: 0 10px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        gap: 4px;
        cursor: pointer;
        flex-shrink: 0;
    }
    .ol-prac-close:active { background: #e2e8f0; }
    .ol-prac-close-icon {
        font-size: 18px;
        font-weight: 700;
        line-height: 1;
    }
    .ol-prac-close-label {
        font-size: 12px;
    }
    .ol-prac-title-bar {
        flex: 1;
        font-size: 17px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: center;
        padding: 0 4px;
    }
    .ol-prac-progress {
        font-size: 13px;
        color: #64748b;
        font-weight: 600;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ===== 4. SEARCH BAR — Thanh tìm kiếm sticky (NGOÀI menu ôn luyện) ===== */
.ol-search-bar {
    position: sticky;
    top: 0;
    z-index: 99;
    background: #fff;
    border-bottom: 1.5px solid #e2e8f0;
    padding: 8px 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ol-search-input {
    width: 100%;
    padding: 9px 16px;
    border: 1.5px solid #c7d9f5;
    border-radius: 22px;
    font-size: 14px;
    background: #f8faff;
    outline: none;
    box-sizing: border-box;
    color: #1e3a6e;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.ol-search-input:focus {
    border-color: #4a7fd4;
    box-shadow: 0 0 0 3px rgba(74,127,212,0.18);
    background: #fff;
}
.ol-search-input::placeholder {
    color: #8aa8d8;
}
.ol-search-results {
    position: absolute;
    left: 12px;
    right: 12px;
    background: #fff;
    border: 1px solid #c7d9f5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.16);
    max-height: 320px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    margin: 0 12px;
}
.ol-search-results.show {
    display: block;
}
.ol-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eef2fb;
    font-size: 14px;
    color: #2a3a5c;
    transition: background 0.15s, box-shadow 0.15s;
    background: #fff;
}
.ol-search-item:first-child { border-radius: 8px 8px 0 0; }
.ol-search-item:last-child { border-bottom: none; border-radius: 0 0 8px 8px; }
.ol-search-item:only-child { border-radius: 8px; }
.ol-search-item:hover {
    background: #eef4ff;
    box-shadow: inset 3px 0 0 #4a7fd4;
}
.ol-search-item.current { background: #dce8ff; }
.ol-search-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a7fd4, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(74, 127, 212, 0.35);
}
.ol-search-item.correct .ol-search-num { background: #2e9a4a; }
.ol-search-item.wrong .ol-search-num { background: #d94a4a; }
.ol-search-item.answered .ol-search-num { background: #7a8aa0; }
.ol-search-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}
.ol-search-empty {
    padding: 14px;
    text-align: center;
    color: #8899b8;
    font-size: 14px;
}

/* ===== QUICK VIEW — Xem nhanh câu hỏi khi click kết quả tìm kiếm ===== */
#olQuickView {
    display: flex;
}
#olQuickViewCard {
    position: relative;
}
/* Nội dung câu hỏi bên trong quick view */
#olQuickViewBody .ol-q-card {
    margin: 0;
    padding: 14px;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
#olQuickViewBody .ol-q-content {
    padding: 10px 0;
    font-size: 15px;
    line-height: 1.6;
}
#olQuickViewBody .ol-q-image {
    max-height: 220px;
    border-radius: 8px;
    margin: 10px 0;
    width: 100%;
    object-fit: contain;
}
#olQuickViewBody .ol-opt {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    cursor: default;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #334155;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
#olQuickViewBody .ol-opt-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
#olQuickViewBody .ol-opt.correct {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
    border-color: #2E7D32;
    color: #1B5E20;
    font-weight: 600;
}
#olQuickViewBody .ol-opt.correct .ol-opt-num {
    background: #2E7D32;
    color: #fff;
}
#olQuickViewBody .ol-opt.wrong {
    background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
    border-color: #C62828;
    color: #B71C1C;
    font-weight: 600;
}
#olQuickViewBody .ol-opt.wrong .ol-opt-num {
    background: #C62828;
    color: #fff;
}
#olQuickViewBody .ol-opt.correct::after {
    content: ' ✓';
    color: #2E7D32;
    font-weight: 800;
    font-size: 14px;
}
#olQuickViewBody .ol-opt.wrong::after {
    content: ' ✗';
    color: #C62828;
    font-weight: 800;
    font-size: 14px;
}
#olQuickViewBody .ol-explanation {
    margin-top: 12px;
    padding: 12px 14px;
    background: #FFF8E1;
    border: 1px solid #FFE082;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #5D4037;
}
#olQuickViewBody .ol-q-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
#olQuickViewBody .ol-q-chapter-tag {
    font-size: 11px;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
#olQuickViewBody .ol-q-critical-badge {
    font-size: 10px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
}

/* ===== 5. KHỐI 2: MA TRẬN (52px cố định, 2×15) ===== */
    .ol-prac-matrix {
        flex-shrink: 0;
        height: 52px;
        background: #f8f9fa;
        border-bottom: 1px solid #e2e8f0;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
    }
    .ol-prac-matrix-inner {
        padding: 4px 6px;
        height: 100%;
        box-sizing: border-box;
    }
    .ol-prac-matrix-grid {
        display: grid;
        grid-template-columns: repeat(15, 1fr);
        grid-template-rows: repeat(2, 22px);
        gap: 2px;
        height: 100%;
    }
    .ol-prac-matrix-cell {
        width: 100%;
        height: 22px;
        min-width: 0;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
        background: #fff;
        font-size: 11px;
        font-weight: 600;
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        position: relative;
        box-sizing: border-box;
        -webkit-tap-highlight-color: rgba(2, 132, 199, 0.06);
    }
    .ol-prac-matrix-cell:active { transform: scale(0.88); }
    .ol-prac-matrix-cell.current {
        border: 1.5px solid #0284c7;
        background: #e0f2fe;
        color: #0284c7;
    }
    .ol-prac-matrix-cell.answered {
        border-color: #86efac;
        background: #dcfce7;
        color: #15803d;
    }
    .ol-prac-matrix-cell.correct-dot {
        border-color: #15803d;
        background: #16a34a;
        color: #fff;
    }
    .ol-prac-matrix-cell.wrong-dot {
        border-color: #b91c1c;
        background: #dc2626;
        color: #fff;
    }
    .ol-prac-matrix-cell.has-critical::after {
        content: '★';
        position: absolute;
        top: -1px;
        left: 1px;
        font-size: 7px;
        color: #dc2626;
        line-height: 1;
        pointer-events: none;
    }

    /* ===== 6. KHỐI 3: BODY (flex 1 — co giãn) ===== */
    .ol-prac-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0;
        background: #fff;
        min-height: 0;
        touch-action: pan-y;
        padding-bottom: 60px; /* chừa chỗ cho footer nav */
    }

    /* Question card */
    .ol-q-card {
        background: #fff;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
    }
    .ol-q-header {
        padding: 6px 14px 4px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
    }
    .ol-q-num {
        font-weight: 700;
        color: #0284c7;
        font-size: 12px;
    }
    .ol-q-critical-badge {
        display: inline-block;
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fecaca;
        font-size: 10px;
        font-weight: 800;
        padding: 2px 7px;
        border-radius: 4px;
        letter-spacing: 0.3px;
    }
    .ol-q-chapter-tag {
        margin-left: auto;
        font-size: 10px;
        background: #f1f5f9;
        color: #64748b;
        padding: 1px 6px;
        border-radius: 3px;
    }

    /* Câu hỏi */
    .ol-q-content {
        padding: 10px 14px 8px;
        font-size: 19px;
        line-height: 1.35;
        font-weight: 600;
        color: #1e293b;
        border-bottom: 1px solid #f1f5f9;
        word-break: break-word;
    }
    .ol-q-content.is-critical { color: #c0392b; font-weight: 700; }
    .ol-q-image {
        display: block;
        max-width: 100%;
        max-height: 26vh;
        width: auto;
        height: auto;
        object-fit: contain;
        margin: 4px auto;
    }

    /* Đáp án */
    .ol-options { padding: 0; }
    .ol-opt {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 14px;
        border: none;
        border-bottom: 1px solid #f1f5f9;
        border-radius: 0;
        margin: 0;
        min-height: 52px;
        height: auto;
        background: #fff;
        transition: background 0.1s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2, 132, 199, 0.06);
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .ol-opt:last-child { border-bottom: none; }
    .ol-opt:active { background: #dbeafe; }
    .ol-opt.selected { background: #e0f2fe !important; }
    .ol-opt.correct { background: #dcfce7 !important; }
    .ol-opt.wrong   { background: #fee2e2 !important; }

    .ol-opt-num {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 50% !important;
        border: 1.5px solid #64748b !important;
        background: #fff !important;
        font-size: 14px;
        font-weight: 700;
        color: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: all 0.1s;
        margin-top: 2px;
    }
    .ol-opt.selected .ol-opt-num { background: #0284c7 !important; border-color: #0284c7 !important; color: #fff !important; }
    .ol-opt.correct .ol-opt-num { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }
    .ol-opt.wrong   .ol-opt-num { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }

    .ol-opt > span:last-child,
    .ol-opt > .ol-opt-text {
        font-size: 16px;
        line-height: 1.45;
        color: #1e293b;
        flex: 1;
        font-weight: 500;
        min-width: 0;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }
    .ol-opt.selected > span:last-child { color: #0c4a6e; font-weight: 600; }

    /* Explanation */
    .ol-explanation {
        margin: 6px 14px 12px;
        border-radius: 6px;
        font-size: 14px;
    }

    /* ===== 7. KHỐI 4: FOOTER NAV (48px) — Prev | Counter | Next ===== */
    .ol-prac-footer {
        position: relative !important;
        left: 0; right: 0; bottom: 0;
        z-index: 300;
        display: flex !important;
        align-items: center;
        height: 48px;
        padding: 0;
        background: #fff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -3px 14px rgba(0,0,0,0.09);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        gap: 0;
        flex-shrink: 0;
    }

    .ol-prac-nav-btn {
        width: 50px;
        min-width: 50px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        font-weight: 300;
        background: #fff;
        border: none;
        cursor: pointer;
        color: #0284c7;
        transition: background 0.1s;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(2, 132, 199, 0.08);
        border-radius: 0;
        padding: 0;
    }
    .ol-prac-nav-btn:active { background: #f0f9ff; }
    .ol-prac-nav-btn:disabled { color: #cbd5e1; cursor: default; }

    .ol-prac-nav-center {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        cursor: pointer;
        height: 48px;
        padding: 0 8px;
        transition: background 0.1s;
        -webkit-tap-highlight-color: rgba(2, 132, 199, 0.08);
    }
    .ol-prac-nav-center:active { background: #f0f9ff; }
    .ol-prac-nav-counter {
        font-size: 16px;
        font-weight: 700;
        color: #0284c7;
        line-height: 1.1;
        letter-spacing: 0.3px;
    }
    .ol-prac-nav-label {
        font-size: 9.5px;
        color: #94a3b8;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
}

#pracBody, .ol-prac-body {
    touch-action: pan-y;
    overscroll-behavior-x: none;
}
#pracBody.hlx-swiping { pointer-events: none; will-change: transform, opacity; }

/* ===== FIX 27/08: vuốt + không cắt chữ bởi footer ===== */
.hlx-q-spacer {
    height: 28px;
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}
.ol-opt,
.ol-opt * {
    touch-action: pan-y !important;
}
@media (max-width: 991px) {
    .ol-practice-screen,
    .ol-practice-screen.active {
        display: none;
        position: fixed !important;
        inset: 0 !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        width: 100% !important;
        flex-direction: column !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff;
        z-index: 500;
    }
    .ol-practice-screen.active {
        display: flex !important;
    }
    .ol-prac-header,
    .ol-prac-matrix {
        flex-shrink: 0 !important;
    }
    .ol-prac-body,
    #pracBody,
    .ol-practice-screen .ol-prac-body {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 32px !important;
        touch-action: pan-y !important;
    }
    .ol-prac-footer,
    #pracFooter {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        flex-shrink: 0 !important;
        height: auto !important;
        min-height: 52px !important;
        max-height: none !important;
        padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
        z-index: 20 !important;
        background: #fff !important;
        box-shadow: 0 -3px 14px rgba(0,0,0,.08);
    }
    .ol-bottom-nav {
        display: none !important;
    }
    .ol-practice-screen.active ~ .ol-bottom-nav,
    body:has(.ol-practice-screen.active) .ol-bottom-nav {
        display: none !important;
    }
    .hlx-q-spacer { height: 36px; }
}

/* =========================================================================
   2026-09-03 — ÔN LUYỆN = APP MOBILE (mọi kích thước)
   Xóa 2 hotfix desktop xung đột + đóng @media bị hở ngoặc.
   Màn ôn luôn: Header | Ma trận 2×15 | Câu hỏi | Footer Prev/Next
   Desktop ≥992: cùng chrome, khung app canh giữa.
   ========================================================================= */

/* Ma trận — base, không nhốt trong max-width 768 */
.ol-prac-matrix,
#olPracMatrixBar {
    flex-shrink: 0;
    height: 52px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
}
.ol-prac-matrix-inner {
    padding: 4px 6px;
    height: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
}
.ol-prac-matrix-grid,
#olPracMatrixGrid {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(2, 22px);
    gap: 2px;
    height: 100%;
    width: max-content !important;
    min-width: 100%;
}
.ol-prac-matrix-cell {
    width: 100%;
    height: 22px;
    min-width: 0;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(2, 132, 199, 0.06);
}
.ol-prac-matrix-cell:active { transform: scale(0.88); }
.ol-prac-matrix-cell.current {
    border: 1.5px solid #0284c7;
    background: #e0f2fe;
    color: #0284c7;
}
.ol-prac-matrix-cell.answered {
    border-color: #86efac;
    background: #dcfce7;
    color: #15803d;
}
.ol-prac-matrix-cell.correct-dot {
    border-color: #15803d;
    background: #16a34a;
    color: #fff;
}
.ol-prac-matrix-cell.wrong-dot {
    border-color: #b91c1c;
    background: #dc2626;
    color: #fff;
}
.ol-prac-matrix-cell.has-critical::after {
    content: '★';
    position: absolute;
    top: -1px;
    left: 1px;
    font-size: 8px;
    color: #dc2626;
    line-height: 1;
}

/* Màn ôn — app native 4 khối */
.ol-practice-screen,
#practiceScreen {
    display: none;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}
.ol-practice-screen.active,
#practiceScreen.active {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    z-index: 500 !important;
    overflow: hidden !important;
    flex-direction: column !important;
}

.ol-practice-screen.active .ol-prac-header,
#practiceScreen.active .ol-prac-header {
    display: flex !important;
    flex-shrink: 0 !important;
    height: auto !important;
    min-height: 48px !important;
    padding: 0 8px !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    background: #fff !important;
    color: #1e293b !important;
    border-bottom: 1.5px solid #e2e8f0 !important;
    box-shadow: none !important;
    align-items: center !important;
    align-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    position: relative !important;
    top: auto !important;
}
.ol-prac-close {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    height: 32px !important;
    width: auto !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}
.ol-prac-title-bar {
    flex: 1 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    text-align: center !important;
}
.ol-prac-progress {
    font-size: 13px !important;
    color: #64748b !important;
    font-weight: 600 !important;
}

.ol-practice-screen.active .ol-prac-body,
#practiceScreen.active .ol-prac-body,
#pracBody {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px 20px !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    background: #fff !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: 0 !important;
    border-radius: 0 !important;
}

.ol-practice-screen.active .ol-prac-footer,
#practiceScreen.active .ol-prac-footer,
#pracFooter {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex-shrink: 0 !important;
    height: auto !important;
    min-height: 52px !important;
    max-height: none !important;
    padding: 4px 8px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    background: #fff !important;
    border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -3px 14px rgba(0,0,0,.08) !important;
    z-index: 20 !important;
    align-items: center !important;
    gap: 6px !important;
}

body.practice-active {
    overflow: hidden !important;
    height: 100dvh !important;
}
body.practice-active .ol-bottom-nav,
.ol-practice-screen.active ~ .ol-bottom-nav {
    display: none !important;
}

/* Ảnh: không chiếm chỗ khi không có */
.ol-q-img[hidden],
.ol-q-img:not(.has-image),
#pracBody .ol-q-img[hidden],
#pracBody .ol-q-img:not(.has-image) {
    display: none !important;
}
.ol-q-img.has-image,
#pracBody .ol-q-img.has-image {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 8px auto 12px;
    max-height: 360px;
    overflow: hidden;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}
.ol-q-img img,
#pracBody .ol-q-img img {
    max-width: 100%;
    max-height: 350px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.hlx-q-spacer { height: 28px; width: 100%; flex-shrink: 0; pointer-events: none; }

/* Tab trang chủ/ôn/thi — chỉ menu mobile. Thanh 4 nút câu hỏi luôn ẩn. */
nav.ol-bottom-nav:not(.bottom-nav),
nav.ol-q-toolbar,
body.has-ol-bottom-nav nav.ol-bottom-nav:not(.bottom-nav) {
    display: none !important;
}
/* nav.bottom-nav.ol-bottom-nav kept visible — aligned in theme-ryw */

@media (max-width: 991px) {
    body:not(.practice-active) { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
    body:not(.practice-active) nav.bottom-nav.ol-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 40;
    }
}
body.practice-active nav.bottom-nav,
body.practice-active .ol-bottom-nav,
.ol-practice-screen.active ~ .ol-bottom-nav {
    display: none !important;
}

/* Desktop: cùng app native full-viewport, KHÔNG giả lập khung iPhone
   v3.6.1 — 2026-09-15: BỎ width 430px / height 844px / radius 20px / border-shadow.
                          Practice trên desktop = full viewport như mobile, nền page trắng.
                          Skin 2 cột (đề trái / matrix phải) được kẹp trong hlx-desk.css
                          chỉ khi .ol-practice-screen.active — selector đã đúng ở v3.6.1.
*/
@media (min-width: 992px) {
    body { padding-bottom: 0 !important; }
    body:not(.practice-active) .ol-bottom-nav { display: none !important; }

    body.practice-active {
        background: #e8eef5 !important;
        position: relative !important;
        height: 100dvh !important;
        overflow: hidden !important;
    }

    .ol-practice-screen.active,
    #practiceScreen.active {
        inset: 0 !important;
        width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        overflow: hidden !important;
        background: #fff !important;
    }

    .ol-practice-screen.active .ol-prac-header {
        padding-top: 8px !important;
        height: 52px !important;
    }
    .ol-prac-body .ol-q-content,
    #pracBody .ol-q-content {
        font-size: 17px !important;
        line-height: 1.55 !important;
    }
    .ol-opt,
    #pracBody .ol-opt {
        font-size: 15px !important;
        min-height: 48px !important;
    }

    /* Menu chọn đề: lưới gọn, không kéo full-bleed như điện thoại */
    .ol-main {
        max-width: 980px;
        padding: 24px 20px 40px;
    }
    .ol-de-grid {
        grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
        gap: 10px;
    }
}

/* ========================================================================
   2026-09-06 — FIX MOBILE/TABLET ÔN LUYỆN
   - Phóng to ảnh câu hỏi
   - Counter luôn nhảy theo currentIndex (kể cả khi click dot matrix)
   - Đáp án có scroll riêng khi câu dài
   ======================================================================== */

/* ===== ẢNH CÂU HỎI TO HƠN ===== */
@media (max-width: 991px) {
    .ol-q-img.has-image,
    #pracBody .ol-q-img.has-image {
        max-height: 360px !important;
    }
    .ol-q-img img,
    #pracBody .ol-q-img img {
        max-height: 350px !important;
    }
    .ol-q-image,
    #pracBody .ol-q-image {
        max-height: 350px !important;
    }
}

@media (max-width: 768px) {
    .ol-q-img.has-image,
    #pracBody .ol-q-img.has-image {
        max-height: 320px !important;
    }
    .ol-q-img img,
    #pracBody .ol-q-img img {
        max-height: 310px !important;
    }
    .ol-q-image,
    #pracBody .ol-q-image {
        max-height: 310px !important;
    }
}

@media (max-width: 480px) {
    .ol-q-img.has-image,
    #pracBody .ol-q-img.has-image {
        max-height: 260px !important;
    }
    .ol-q-img img,
    #pracBody .ol-q-img img {
        max-height: 250px !important;
    }
    .ol-q-image,
    #pracBody .ol-q-image {
        max-height: 250px !important;
    }
}

/* ===== ĐÁP ÁN SCROLL RIÊNG KHI CÂU DÀI =====
   Khóa cứng khung câu hỏi + đáp án, không tràn footer/matrix */
.ol-prac-body,
#pracBody {
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
}

/* q-card chứa q-content + q-img + options — không cho phép tràn */
.ol-q-card {
    max-width: 100% !important;
    overflow: hidden !important;
}

/* v3.6.3 — 2026-09-15: BỎ nested scroll trong .ol-options.
   Chỉ .ol-prac-body cuộn. .ol-options = block bình thường.
   Thu gọn option padding + ảnh max-height để fit màn hình. */
@media (max-width: 991px) {
    .ol-options {
        max-height: none !important;
        overflow: visible !important;
        -webkit-overflow-scrolling: auto;
        padding: 6px 0 16px !important;
        margin: 0 !important;
    }
}

@media (max-width: 480px) {
    .ol-options {
        max-height: none !important;
        padding-bottom: 12px !important;
    }
}

/* v3.6.3 — 2026-09-15: Mobile question content compact */
@media (max-width: 991px) {
    .ol-q-card {
        margin: 8px 12px !important;
        padding: 0 !important;
    }
    .ol-q-header {
        padding: 6px 10px !important;
        font-size: 12.5px !important;
    }
    .ol-q-content {
        padding: 10px 12px !important;
        font-size: 14.5px !important;
        line-height: 1.45 !important;
    }
    .ol-q-image {
        max-height: 28vh !important;
        margin: 6px auto !important;
    }
    .ol-q-image img {
        max-height: 26vh !important;
    }
}

/* Thu gọn ol-opt cho mobile: padding gọn, min-height nhỏ */
@media (max-width: 991px) {
    .ol-opt {
        padding: 8px 12px !important;
        min-height: 44px !important;
        font-size: 14.5px !important;
        line-height: 1.35 !important;
    }
}

/* Ảnh câu hỏi: auto size, max 28vh trên mobile */
@media (max-width: 991px) {
    .ol-q-img.has-image,
    .ol-practice-screen.active .ol-q-img.has-image {
        max-height: 28vh !important;
        margin: 6px auto 10px !important;
    }
    #pracBody .ol-q-img.has-image {
        max-height: 28vh !important;
    }
    .ol-q-img img,
    .ol-practice-screen.active .ol-q-img img,
    #pracBody .ol-q-img img {
        max-height: 26vh !important;
    }
}

/* ===== COUNTER LUÔN NHẢY =====
   Đảm bảo olPracCounter hiển thị rõ và luôn update */
.ol-prac-nav-counter {
    min-width: 64px !important;
    text-align: center !important;
    display: block !important;
    white-space: nowrap !important;
}
.ol-prac-nav-center {
    cursor: pointer;
}

/* ========================================================================
   DESKTOP POLISH — Làm đẹp desktop giống mobile (search bar + cards gọn)
   ======================================================================== */

/* Search bar — desktop cũng sticky + style giống mobile */
@media (min-width: 769px) {
    .ol-search-bar {
        position: sticky;
        top: 0;
        z-index: 99;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 20px;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        max-width: 980px;
        margin: 0 auto;
        width: 100%;
    }
    .ol-search-input {
        width: 100%;
        padding: 11px 18px;
        border: 1.5px solid #c7d9f5;
        border-radius: 22px;
        font-size: 15px;
        background: #f8faff;
        outline: none;
        box-sizing: border-box;
        color: #1e3a6e;
        transition: all .2s;
    }
    .ol-search-input:focus {
        border-color: #4a7fd4;
        box-shadow: 0 0 0 3px rgba(74,127,212,0.18);
        background: #fff;
    }
    .ol-search-results {
        position: absolute;
        left: 20px;
        right: 20px;
        background: #fff;
        border: 1px solid #c7d9f5;
        border-radius: 12px;
        box-shadow: 0 12px 32px rgba(0,0,0,0.18);
        max-height: 400px;
        overflow-y: auto;
        z-index: 9999;
        display: none;
        max-width: 980px;
        margin: 0 auto;
    }
    .ol-search-results.show { display: block; }
    .ol-search-item {
        padding: 14px 18px;
        font-size: 15px;
    }
    .ol-search-num {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .ol-search-text {
        white-space: normal;
        line-height: 1.45;
    }
}

/* Desktop cards — lưới gọn như mobile (không kéo full-bleed) */
@media (min-width: 769px) {
    .ol-main {
        max-width: 980px;
        padding: 20px 20px 40px;
    }
    .ol-card {
        margin-bottom: 14px;
    }
    .ol-card-header {
        padding: 12px 16px;
        font-size: 15px;
    }
    .ol-card-body {
        padding: 14px;
    }

    /* Chapter cards — desktop cũng 6 cột, không border/shadow */
    .ol-chapter-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }

    /* Range grid */
    .ol-range-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    /* Menu items — padding rộng hơn */
    .ol-menu-item {
        padding: 14px 16px;
    }
    .ol-menu-icon { width: 44px; height: 44px; font-size: 22px; }
    .ol-menu-text h3 { font-size: 15px; }
    .ol-menu-text p { font-size: 13px; }

    /* Practice screen trên desktop — bỏ khung điện thoại, full screen */
    .ol-practice-screen.active {
        inset: 0 !important;
        width: 100% !important;
        height: 100dvh !important;
        max-width: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
    }

    body.practice-active {
        background: #fff !important;
    }
}

/* Tablet (769-1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .ol-chapter-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}
