/* ═══════════════════════════════════════════════════════════════
   JLEARN ONLINE — MOBILE RESPONSIVE (CLEAN REWRITE v3.0.150)
   One file. One system. No conflicting !important chains.
   ═══════════════════════════════════════════════════════════════ */

/* ── GLOBAL: Android vertical scroll guaranteed ─────────────── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
}
/* Never trap scroll in a child container on mobile */
@media (max-width: 1023px) {
    html, body { height: auto !important; max-height: none !important; overflow-y: visible !important; }
    .page.active { min-height: 100dvh; }
}

/* ── SAFE AREA INSETS ───────────────────────────────────────── */
:root {
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

/* ── FIXED FOOTER: don't cover content ──────────────────────── */
@media (max-width: 1023px) {
    body { padding-bottom: calc(70px + var(--sab)) !important; }
    #site-footer {
        padding: 6px 10px calc(6px + var(--sab)) !important;
        font-size: 11px !important;
    }
}

/* --------------------------------------------------------------------------
   2. TOUCH TARGETS & FORM INPUTS (PREVENT IOS AUTO-ZOOM)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    input[type="text"], input[type="password"], input[type="email"],
    input[type="number"], input[type="search"], input[type="tel"],
    input[type="url"], input[type="date"], select, textarea {
        font-size: 16px !important;
        min-height: 44px;
        border-radius: 8px;
        touch-action: pan-y;
    }

    button, .btn, .tab-btn, .nav-link, .tool-tab-btn,
    .mobile-menu-toggle, .dropdown-item, .quiz-palette-item {
        min-height: 44px;
        touch-action: manipulation;
    }

    button:active, .btn:active, .tool-tab-btn:active, .role-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* --------------------------------------------------------------------------
   3. MOBILE NAVIGATION DRAWER & HAMBURGER MENU (INDEX.HTML & GLOBAL)
   -------------------------------------------------------------------------- */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.35rem;
    color: var(--primary-color, #005c30);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    z-index: 110;
}

.mobile-menu-toggle:focus {
    outline: 2px solid var(--secondary-color, #34d399);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    height: 100dvh;
    background: var(--surface-color, #ffffff);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.2);
    z-index: 999;
    padding: calc(var(--sat) + 20px) 20px calc(var(--sab) + 20px) 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-drawer.active {
    transform: translateX(-320px);
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.mobile-nav-header .drawer-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color, #005c30);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-nav-close {
    background: var(--hover-bg, #f1f5f9);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #64748b);
    font-size: 1.1rem;
    cursor: pointer;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-color, #1e293b);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    background: var(--primary-light, #ecfdf5);
    color: var(--primary-color, #005c30);
}

.mobile-nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   4. DUAL-COLUMN GENERATOR TOOLS MOBILE TAB SWITCHER
   -------------------------------------------------------------------------- */
.mobile-view-tabs {
    display: none;
    position: sticky;
    top: calc(var(--sat) + 56px);
    z-index: 85;
    background: var(--surface-color, #ffffff);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.mobile-view-tabs .tabs-segmented {
    display: flex;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
    width: 100%;
}

.mobile-view-tabs .tab-segment-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-view-tabs .tab-segment-btn.active {
    background: var(--surface-color, #ffffff);
    color: var(--primary-color, #005c30);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1023px) {
    .mobile-view-tabs { display: block; }

    #student-login-page .mobile-view-tabs,
    #student-portal-container .mobile-view-tabs,
    .student-portal-wrapper .mobile-view-tabs,
    body:not(.generator-page) .mobile-view-tabs { display: none !important; }

    html, body {
        height: auto !important; min-height: 100% !important;
        overflow-x: clip !important; overflow-y: auto !important;
        touch-action: pan-y !important; -webkit-overflow-scrolling: touch !important;
    }

    #app, .page, .page.active, .generator-app, .generator-container,
    .main-container, .dashboard-container, .app-layout-2col, main, aside, section {
        height: auto !important; min-height: 0 !important; max-height: none !important;
        overflow-y: visible !important; overflow-x: visible !important;
        touch-action: pan-y !important; -webkit-overflow-scrolling: touch !important;
    }

    .generator-app-grid, .exemplar-grid, .ilaw-grid, .ppt-grid, .co-maker-grid,
    #app > .generator-container, .app-layout-2col {
        display: flex !important; flex-direction: column !important;
        gap: 16px !important; height: auto !important; overflow: visible !important;
    }

    .generator-form-panel, .generator-preview-panel,
    #exemplar-form-panel, #exemplar-preview-panel,
    #ilaw-form-panel, #ilaw-preview-panel,
    #ppt-form-panel, #ppt-preview-panel, #ppt-input-panel, #ppt-result-panel,
    #co-form-panel, #co-right-panel, #co-preview-panel {
        width: 100% !important; max-width: 100% !important;
        height: auto !important; min-height: 0 !important;
        overflow-y: visible !important; overflow-x: visible !important;
    }

    body.mobile-view-preview-active .generator-form-panel,
    body.mobile-view-preview-active #exemplar-form-panel,
    body.mobile-view-preview-active #ilaw-form-panel,
    body.mobile-view-preview-active #ppt-form-panel,
    body.mobile-view-preview-active #ppt-input-panel,
    body.mobile-view-preview-active #co-form-panel { display: none !important; }

    body.mobile-view-form-active .generator-preview-panel,
    body.mobile-view-form-active #exemplar-preview-panel,
    body.mobile-view-form-active #ilaw-preview-panel,
    body.mobile-view-form-active #ppt-preview-panel,
    body.mobile-view-form-active #ppt-result-panel,
    body.mobile-view-form-active #co-right-panel,
    body.mobile-view-form-active #co-preview-panel { display: none !important; }
}

/* --------------------------------------------------------------------------
   5. RESPONSIVE TABLES & CONTAINERS
   -------------------------------------------------------------------------- */
.table-responsive {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem; border-radius: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

@media (max-width: 768px) {
    .ppt-slide-card, .slide-preview-container {
        width: 100% !important; min-height: auto !important; padding: 16px !important;
    }
    .ppt-slide-deck-list { display: flex; flex-direction: column; gap: 16px; }
    .ppt-thumbnails-carousel {
        display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 10px;
    }
    .ppt-thumbnail-item { scroll-snap-align: start; flex-shrink: 0; width: 140px; }
}

/* --------------------------------------------------------------------------
   6. STICKY MOBILE ACTION BARS
   -------------------------------------------------------------------------- */
.mobile-sticky-action-bar {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface-color, #ffffff);
    padding: 10px 16px calc(var(--sab) + 10px) 16px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    z-index: 90; align-items: center; justify-content: space-between; gap: 10px;
}
@media (max-width: 768px) {
    .mobile-sticky-action-bar { display: flex; }
    .has-mobile-action-bar { padding-bottom: calc(var(--sab) + 75px) !important; }
}

/* --------------------------------------------------------------------------
   7. CHIP ROWS & HORIZONTAL SCROLLING PICKERS
   -------------------------------------------------------------------------- */
.horizontal-chip-picker {
    display: flex; overflow-x: auto; white-space: nowrap; gap: 8px;
    padding: 6px 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.horizontal-chip-picker::-webkit-scrollbar { display: none; }
.chip-option {
    display: inline-flex; align-items: center; padding: 8px 14px;
    border-radius: 50px; border: 1px solid var(--border-color, #e2e8f0);
    background: var(--surface-color, #ffffff); font-size: 0.85rem;
    font-weight: 500; color: var(--text-color, #1e293b); cursor: pointer;
    flex-shrink: 0; transition: all 0.2s ease;
}
.chip-option.active {
    background: var(--primary-color, #005c30); color: #ffffff;
    border-color: var(--primary-color, #005c30);
    box-shadow: 0 2px 6px rgba(0, 92, 48, 0.25);
}

/* --------------------------------------------------------------------------
   8. MOBILE RESPONSIVENESS: DASHBOARDS & PORTALS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .navbar { padding: 8px 0; }
    .navbar .container { padding: 0 16px; }
    .mobile-menu-toggle { display: flex; }
    .nav-links, .desktop-nav-actions { display: none !important; }
    .container { padding: 0 14px; }

    .hero-section { padding: 2.5rem 0 1.5rem 0; text-align: center; }
    .hero-title { font-size: clamp(1.6rem, 6vw, 2.2rem) !important; line-height: 1.25 !important; }
    .hero-subtitle { font-size: 0.95rem !important; }
    .hero-actions { flex-direction: column; gap: 10px; width: 100%; }
    .hero-actions .btn { width: 100%; }

    .role-grid, .features-grid, .tools-grid, .stats-grid, .dashboard-grid {
        grid-template-columns: 1fr !important; gap: 14px !important;
    }
    .stats-summary-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }

    .card, .feature-card, .role-card, .tool-card { padding: 16px !important; }

    .modal-content, .dialog-box {
        width: 95% !important; max-width: 95% !important; margin: auto;
        padding: 18px !important; border-radius: 16px !important;
        max-height: 90vh !important; overflow-y: auto !important;
    }

    .assessment-header, #assessment-header {
        position: sticky !important; top: 0 !important;
        top: env(safe-area-inset-top, 0px) !important;
        z-index: 1040 !important;
        padding: 0.5rem 0.65rem !important; margin-bottom: 0.85rem !important;
        display: flex !important; flex-direction: row !important;
        align-items: center !important; justify-content: space-between !important;
        gap: 0.4rem !important; border-radius: 12px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important;
    }

    [data-theme="dark"] .assessment-header,
    [data-theme="dark"] #assessment-header {
        background: rgba(15, 23, 42, 0.96) !important;
    }

    #sticky-timer, .quiz-timer {
        padding: 6px 12px !important; font-size: 0.88rem !important;
        font-weight: 700 !important; min-height: 36px !important;
        border-radius: 50px !important;
        background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
        color: white !important; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3) !important;
        flex-shrink: 0 !important; margin: 0 !important; gap: 4px !important;
    }

    #violation-counter-container {
        display: inline-flex !important; align-items: center !important;
        justify-content: flex-end !important; flex-shrink: 0 !important; margin: 0 !important;
    }

    #violation-counter-main {
        padding: 6px 12px !important; font-size: 0.88rem !important;
        font-weight: 700 !important; min-height: 36px !important;
        border-radius: 50px !important;
        background: linear-gradient(135deg, #ef4444, #dc2626) !important;
        color: white !important; box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3) !important;
        flex-shrink: 0 !important; margin: 0 !important; cursor: pointer !important;
    }

    #violation-counter-collapsed { padding: 0 !important; gap: 4px !important; font-size: 0.88rem !important; }

    .assessment-header-title {
        display: flex !important; align-items: center !important;
        justify-content: center !important; flex: 1 1 auto !important; min-width: 0 !important;
    }
    .assessment-header-title h3 {
        font-size: 0.9rem !important; margin: 0 !important; font-weight: 700 !important;
        white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
    }

    .quiz-palette-container { padding: 0.65rem 0.75rem !important; margin-bottom: 1rem !important; border-radius: 10px !important; }
    .quiz-palette-header { margin-bottom: 0.45rem !important; }
    .quiz-palette-grid {
        display: flex !important; flex-wrap: wrap !important; gap: 5px !important;
        max-height: 105px !important; overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; overscroll-behavior-y: contain !important; padding: 3px 1px !important;
    }
    .quiz-palette-item { width: 35px !important; height: 35px !important; min-width: 35px !important; font-size: 0.82rem !important; border-radius: 6px !important; }
    .question-card { scroll-margin-top: 65px !important; }
    .question-options-list .option-item { padding: 12px 14px !important; font-size: 0.95rem !important; }

    .footer-grid { grid-template-columns: 1fr !important; gap: 20px !important; text-align: center; }
    .footer-links { align-items: center; }
}

/* --------------------------------------------------------------------------
   9. EXTRA SMALL PHONES (< 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
    .hero-title { font-size: 1.45rem !important; }
    .stats-summary-grid { grid-template-columns: 1fr !important; }
    .quiz-palette-grid { gap: 4px !important; max-height: 95px !important; }
}

/* --------------------------------------------------------------------------
   10. PRINT STYLES
   -------------------------------------------------------------------------- */
@media print {
    .mobile-menu-toggle, .mobile-menu-overlay, .mobile-nav-drawer,
    .mobile-view-tabs, .mobile-sticky-action-bar { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════
   v2 MOBILE POLISH LAYER
   ════════════════════════════════════════════════════════════════ */
* { min-width: 0; }
img, svg, video, canvas, iframe { max-width: 100%; }
pre, code { white-space: pre-wrap; word-break: break-word; }
html, body { overscroll-behavior-y: auto !important; -webkit-overflow-scrolling: touch !important; }
@media (max-width: 1023px) {
    html, body { height: auto !important; overflow-y: visible !important; }
    .page.active { min-height: 100dvh; }
}

/* Safe area for sticky headers */
.navbar, .ppt-page-header, #assessment-header.assessment-header, .jl-fixed-quizbar {
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
}
#jl-fixed-quizbar { padding-top: calc(8px + env(safe-area-inset-top, 0px)) !important; }

/* ═══════════════════════════════════════════════════════════════
   PHONE (< 768px) — ALL MOBILE STYLING IN ONE BLOCK
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

    /* ── TYPOGRAPHY ── */
    h1 { font-size: 1.3rem !important; line-height: 1.25; }
    h2 { font-size: 1.1rem !important; line-height: 1.3; }
    h3 { font-size: .98rem !important; }
    .container { padding-left: 14px !important; padding-right: 14px !important; }

    /* ── FORMS: 16px = no iOS zoom, comfy touch ── */
    input, select, textarea {
        font-size: 16px !important;
        min-height: 46px !important;
        border-radius: 12px !important;
        padding: 10px 12px !important;
    }
    textarea { min-height: 80px; }
    label { font-size: .78rem !important; font-weight: 700 !important; }
    .form-group { margin-bottom: 12px !important; }

    /* ── BUTTONS: full-width stacked, ≥48px ── */
    .btn-primary, .btn-success, .btn-danger, .btn-secondary,
    form button[type="submit"] {
        width: 100% !important;
        min-height: 48px !important;
        font-size: .9rem !important;
        border-radius: 12px !important;
    }
    .modal-actions { flex-direction: column !important; gap: 8px !important; }
    .btn:active { transform: scale(.97); opacity: .85; }

    /* ── TAP TARGETS ≥44px ── */
    a, button, select, .tab-btn, .nav-link, .dropdown-item {
        min-height: 44px;
    }
    .modal-close {
        width: 38px !important; height: 38px !important;
        min-width: 38px !important; min-height: 38px !important;
        max-width: 38px !important;
        border-radius: 50% !important;
        position: absolute !important; top: 10px; right: 10px;
    }

    /* ── STAT GRIDS → 2 columns ── */
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns: repeat(3"],
    .stats-grid, .stats-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* ── CARDS: uniform radius + shadow ── */
    .card, .lesson-card, .modern-lesson-card, .result-card,
    .stat-card, .panel, [class*="rounded-2xl"] {
        border-radius: 14px !important;
    }

    /* ═══ MODALS: bottom sheets ═══ */
    .modal-overlay, .modal-overlay.active {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    .modal {
        width: 100% !important;
        max-width: 100vw !important;
        max-height: 92dvh !important;
        border-radius: 20px 20px 0 0 !important;
        margin: 0 !important;
        animation: sheetUp .28s cubic-bezier(.22,.61,.36,1) both;
    }
    /* Small centered modals stay centered */
    #jl-quota-modal,
    #student-logout-modal,
    #lifeline-confirm-modal {
        align-items: center !important;
        justify-content: center !important;
        padding: 16px !important;
    }
    #jl-quota-modal > div,
    #student-logout-modal > div,
    #lifeline-confirm-modal > div {
        max-width: 360px !important;
        border-radius: 20px !important;
        max-height: min(85dvh, calc(100dvh - 32px)) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    /* Sheet headers sticky */
    .modal-header, .ai-header {
        position: sticky !important; top: 0; z-index: 2;
        padding: 12px 48px 12px 16px !important;
    }
    /* Inner scroll: momentum + safe-area */
    .modal-content, .ai-body, .result-details-content, .lc-body,
    .modal.active > form {
        padding: 12px 16px calc(16px + var(--sab)) !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }
    /* Action row: sticky bottom */
    .modal-actions, .ai-footer {
        position: sticky !important; bottom: 0; z-index: 2;
        background: #fff;
        margin: 0 -16px !important;
        padding: 10px 16px calc(10px + var(--sab)) !important;
        border-top: 1px solid #f1f5f9;
        flex-direction: column !important;
        gap: 8px !important;
    }
    .modal-actions .btn { width: 100% !important; }

    /* ═══ ASSESSMENT INSTRUCTIONS: compact ═══ */
    #assessment-instructions-modal .ai-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    #assessment-instructions-modal .ai-stat {
        padding: 10px 8px !important;
        text-align: center;
    }
    #assessment-instructions-modal .ai-stat-val { font-size: 1rem !important; }
    #assessment-instructions-modal .ai-stat-label { font-size: .6rem !important; }
    #assessment-instructions-modal .ai-section {
        padding: 10px 12px !important;
        border-radius: 12px !important;
        margin-bottom: 8px !important;
    }
    #assessment-instructions-modal .ai-rule {
        padding: 6px 8px !important;
        font-size: .76rem !important;
        margin-bottom: 4px !important;
    }
    #assessment-instructions-modal .ai-anticheat ul li { font-size: .74rem !important; }
    #assessment-instructions-modal .ai-ack { padding: 10px !important; }
    #assessment-instructions-modal .ai-ack-text { font-size: .76rem !important; }
    #assessment-instructions-modal .ai-footer {
        flex-direction: column !important;
        margin: 10px -14px -12px !important;
    }
    #assessment-instructions-modal .ai-header h3 { font-size: .9rem !important; }

    /* ═══ LIFELINE MODAL: compact ═══ */
    #lifeline-confirm-modal .lc-body {
        padding: 18px 16px calc(16px + var(--sab)) !important;
    }
    #lifeline-confirm-modal .btn {
        width: 100% !important; min-height: 48px !important;
        border-radius: 14px !important;
    }
    #lifeline-confirm-modal div[style*="display:flex; gap:10px"] {
        flex-direction: column !important; gap: 8px !important;
    }

    /* ═══ QUIZ PAGE ═══ */
    .assessment-header { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; }
    #sticky-timer { font-variant-numeric: tabular-nums; }
    .quiz-question { padding: 12px !important; border-radius: 12px !important; }
    .quiz-question h4 { font-size: .92rem !important; line-height: 1.4 !important; }
    /* Options as tappable cards */
    .quiz-question label {
        display: flex; align-items: flex-start; gap: 10px;
        padding: 10px 12px !important;
        border: 1.5px solid #e2e8f0 !important;
        border-radius: 10px !important;
        margin: 6px 0 !important;
        background: #fff;
    }
    .quiz-question label:active { background: #eef2ff; border-color: #a5b4fc; }
    /* Palette: swipeable strip */
    .quiz-palette-container .quiz-palette-items,
    .palette-items {
        display: flex !important; overflow-x: auto;
        -webkit-overflow-scrolling: touch; scrollbar-width: none;
        gap: 6px; padding-bottom: 4px;
    }
    .quiz-palette-container .quiz-palette-items::-webkit-scrollbar,
    .palette-items::-webkit-scrollbar { display: none; }
    /* Nav buttons sticky */
    .quiz-navigation {
        position: sticky; bottom: calc(64px + var(--sab));
        background: rgba(255,255,255,.95); backdrop-filter: blur(8px);
        padding: 10px; border-radius: 14px;
        box-shadow: 0 -4px 16px rgba(15,23,42,.08); z-index: 50;
    }
    .quiz-question input[type="text"],
    .quiz-question textarea { font-size: 16px !important; width: 100% !important; }

    /* ═══ RESULTS TABLE → CLEAN HORIZONTAL LIST (one line per student) ═══ */
    /* Results stay as a scrollable table — NOT transformed into cards */
    #results-section-teacher .table-container,
    #results-table-body .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 14px !important;
        border: 1.5px solid #e2e8f0 !important;
        background: #ffffff !important;
    }

    #results-section-teacher .data-table,
    #results-table-body {
        display: table !important;
        width: 100% !important;
        min-width: 680px !important;
        border-collapse: collapse !important;
    }

    #results-section-teacher .data-table thead,
    #results-table-body thead {
        display: table-header-group !important;
    }

    #results-section-teacher .data-table tbody,
    #results-table-body tbody {
        display: table-row-group !important;
    }

    #results-section-teacher tr.result-row,
    #results-table-body tr.result-row {
        display: table-row !important;
        background: #fff !important;
        border: none !important;
        border-bottom: 1px solid #f1f5f9 !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #results-section-teacher tr.result-row td,
    #results-table-body tr.result-row td {
        display: table-cell !important;
        padding: 8px 6px !important;
        vertical-align: middle !important;
        white-space: nowrap !important;
        border: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
        text-align: left !important;
        font-size: 0.78rem !important;
    }

    #results-section-teacher tr.result-row td::before,
    #results-table-body tr.result-row td::before {
        display: none !important;
        content: none !important;
    }

    #results-section-teacher tr.group-header,
    #results-table-body tr.group-header {
        display: table-row !important;
    }

    #results-section-teacher tr.group-header td,
    #results-table-body tr.group-header td {
        display: table-cell !important;
        padding: 10px 12px !important;
    }

    /* ═══ STUDENT TABLE → CLEAN HORIZONTAL LIST (one line per student) ═══ */
    #students-section .table-container,
    #students-table-body .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 14px !important;
        border: 1.5px solid #e2e8f0 !important;
        background: #ffffff !important;
    }

    #students-section .data-table,
    #students-table-body {
        display: table !important;
        width: 100% !important;
        min-width: 580px !important;
        border-collapse: collapse !important;
    }

    #students-section .data-table thead,
    #students-table-body thead {
        display: table-header-group !important;
    }

    #students-section .data-table tbody,
    #students-table-body tbody {
        display: table-row-group !important;
    }

    #students-section tr.student-row,
    #students-table-body tr.student-row {
        display: table-row !important;
        background: #fff !important;
        border: none !important;
        border-bottom: 1px solid #f1f5f9 !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #students-section tr.student-row td,
    #students-table-body tr.student-row td {
        display: table-cell !important;
        padding: 8px 6px !important;
        vertical-align: middle !important;
        white-space: nowrap !important;
        border: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
        text-align: left !important;
        font-size: 0.78rem !important;
    }

    #students-section tr.student-row td::before,
    #students-table-body tr.student-row td::before {
        display: none !important;
        content: none !important;
    }

    #students-section tr.group-header,
    #students-table-body tr.group-header {
        display: table-row !important;
    }

    #students-section tr.group-header td,
    #students-table-body tr.group-header td {
        display: table-cell !important;
        padding: 10px 12px !important;
    }

    /* ═══ TABLES: horizontal scroll with hint ── */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border-radius: 12px;
    }
    .data-table th, .data-table td { padding: 8px 10px; font-size: .82rem; }

    /* ═══ STUDENT MANAGEMENT: action buttons grid ── */
    #students-section .section-header > div[style*="flex"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    #students-section .section-header .btn {
        width: 100%; min-height: 46px; border-radius: 12px;
        justify-content: center; font-size: .82rem;
    }

    /* ═══ TEACHER DASHBOARD ── */
    .dashboard-section { padding: 12px !important; }
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }

    /* ═══ TOOL PAGES (ILAW / EXEMPLAR / PPT) ── */
    /* Stack panes vertically, natural scroll */
    .jl-grid-2col { grid-template-columns: 1fr !important; }

    /* ═══ TOASTS above footer ── */
    #jlearn-toast-notification {
        bottom: calc(76px + var(--sab)) !important;
        left: 12px; right: 12px;
    }

    /* ═══ REDUCED MOTION ── */
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    }
}

/* ═══ ANIMATION KEYFRAMES ═══ */
@keyframes sheetUp{from{transform:translateY(40px);opacity:.4}to{transform:translateY(0);opacity:1}}

/* ═══ TABLET (768-1023px): fine-tune only ══ */
@media (min-width: 768px) and (max-width: 1023px) {
    .container { padding-left: 20px; padding-right: 20px; }
    body { padding-bottom: calc(60px + var(--sab)); }
}

/* ═══ HOVER GUARD: no sticky hover on touch ══ */
@media (hover: none) and (pointer: coarse) {
    .lesson-card:hover, .modern-lesson-card:hover,
    .btn-action:hover, .ppt-template-card:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
}

/* ═══ STICKY QUIZ BAR (from JS) ══ */
#jl-fixed-quizbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 899;
    display: none; align-items: center; justify-content: space-between;
    padding: 8px 14px;
    padding-top: calc(8px + var(--sat));
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 6px 24px -8px rgba(15,23,42,.2);
    border-bottom: 1px solid #e2e8f0;
}

/* ═══════════════════════════════════════════════════════════════
   5. TEACHER DASHBOARD SMARTPHONE EXCELLENCE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Remove extra top space above dashboard */
    #teacher-dashboard-page {
        margin-top: 0 !important;
        padding-top: 0 !important;
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #teacher-dashboard-page .navbar {
        padding: max(6px, env(safe-area-inset-top, 0px)) 0 6px !important;
        margin-top: 0 !important;
    }

    #teacher-dashboard-page .dashboard-container .container {
        padding-top: 6px !important;
    }

    .dashboard-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    .dashboard-main {
        padding: 8px 10px !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .dashboard-section {
        padding: 14px 12px !important;
        border-radius: 16px !important;
        margin-bottom: 14px !important;
        background: #ffffff !important;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04) !important;
        border: 1px solid #f1f5f9 !important;
    }

    .section-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        margin-bottom: 14px !important;
        padding-bottom: 12px !important;
        border-bottom: 1.5px solid #f1f5f9 !important;
    }

    .section-header h2 {
        font-size: 1.25rem !important;
        font-weight: 800 !important;
        color: #0f172a !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin: 0 !important;
    }

    .section-header .btn,
    .section-header button {
        width: 100% !important;
        min-height: 44px !important;
        font-size: 0.9rem !important;
        font-weight: 700 !important;
        border-radius: 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
    }

    .section-header div[style*="display: flex"] {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .section-header div[style*="display: flex"] .btn {
        margin: 0 !important;
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
        min-height: 42px !important;
        white-space: normal !important;
        line-height: 1.2 !important;
        text-align: center !important;
    }

    /* ── LESSONS TAB MOBILE CARDS ── */
    .lessons-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        padding: 0 !important;
    }

    .lesson-card, .modern-lesson-card {
        background: #ffffff !important;
        border-radius: 18px !important;
        border: 1.5px solid #e2e8f0 !important;
        padding: 16px !important;
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05) !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin: 0 !important;
    }

    .lesson-card-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
        margin-top: 4px !important;
        padding-top: 10px !important;
        border-top: 1px solid #f1f5f9 !important;
    }

    .lesson-card-actions .btn,
    .lesson-card-actions .btn-action {
        min-height: 46px !important;
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
        font-weight: 700 !important;
        border-radius: 10px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
    }

    /* ── STUDENT MANAGEMENT → CLEAN HORIZONTAL SCROLLABLE TABLE ── */
    /* (Matches the Results tab layout — one row per student) */
    .group-title {
        font-size: 0.92rem !important;
        font-weight: 800 !important;
        color: #1e293b !important;
    }

    .student-count, .group-count-badge {
        background: #005c30 !important;
        color: #ffffff !important;
        font-size: 0.75rem !important;
        font-weight: 800 !important;
        padding: 3px 9px !important;
        border-radius: 20px !important;
    }

    /* ── BOTTOM SHEET MODALS ── */
    .modal.active {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        border-radius: 24px 24px 0 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        animation: slideUpBottomSheet 0.32s cubic-bezier(0.22, 0.61, 0.36, 1) both !important;
    }

    @keyframes slideUpBottomSheet {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }
}
