/* ============================================== */
/* SJMaths — Class 9 Science Chapter Layout       */
/* Mobile-first • Separate pages per section      */
/* ============================================== */

:root {
    --sj-p: #4f46e5;
    --sj-pd: #4338ca;
    --sj-a: #f39c12;
    --sj-bg: #f8fafc;
    --sj-s: #0f172a;
    --sj-accent: #3b82f6;
    --sj-card-bg: #ffffff;
    --sj-border: #e2e8f0;
    --sj-tab-bg: #f1f5f9;
    --sj-tab-active: #4f46e5;
    --sj-tab-text: #475569;
    --sj-radius: 24px;
    --sj-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--sj-bg);
    color: var(--sj-s);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

.sj-container {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    padding: 15px;
}

/* ===== Top Navigation Bar ===== */
.sj-tbar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.sj-bcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
}

.sj-bcrumb a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.sj-bcrumb a:hover {
    color: var(--sj-p);
}

.sj-nav {
    display: flex;
    gap: 10px;
}

.sj-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 18px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.78rem;
    text-decoration: none;
    background: #fff;
    color: var(--sj-p);
    border: 2px solid var(--sj-p);
    transition: all 0.2s ease;
    min-height: 44px;
}

.sj-btn:hover {
    background: #f0fdf4;
    transform: translateY(-2px);
}

.sj-btn.next {
    background: var(--sj-p);
    color: #fff;
}

.sj-btn.next:hover {
    background: var(--sj-pd);
}

/* ===== Hero Banner ===== */
.sj-hero-v6 {
    background: linear-gradient(135deg, #073b4c 0%, #0f9d8a 100%) !important;
    border-radius: 20px !important;
    padding: 40px 20px !important;
    color: #fff !important;
    text-align: center !important;
    position: relative !important;
    margin-bottom: 25px !important;
    box-shadow: 0 20px 40px rgba(7, 59, 76, 0.18) !important;
    min-height: 240px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden;
}

.sj-hero-v6::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40' fill='%23ffffff' fill-opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
}

.sj-hero-v6 h1 {
    font-size: 1.8rem !important;
    margin-bottom: 12px;
    font-family: 'Outfit', sans-serif !important;
    z-index: 1;
    font-weight: 800;
    line-height: 1.2;
}

.sj-hero-v6 p {
    font-size: 0.88rem;
    opacity: 0.92;
    z-index: 1;
    max-width: 850px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== SECTION NAVIGATION BAR (links to separate pages) ===== */
.sj-section-nav {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 6px;
    overflow-x: auto !important;
    padding: 5px;
    background: #fff;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    margin-bottom: 25px;
    scrollbar-width: thin;
    position: sticky;
    top: 10px;
    z-index: 100;
    -webkit-overflow-scrolling: touch;
}

.sj-section-link {
    flex: 0 0 auto !important;
    min-width: max-content;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--sj-tab-text);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap !important;
    text-decoration: none;
    min-height: 44px;
}

.sj-section-link i {
    font-size: 0.85rem;
}

.sj-section-link:hover {
    background: var(--sj-tab-bg);
    color: var(--sj-s);
}

.sj-section-link.active {
    background: linear-gradient(135deg, var(--sj-tab-active), var(--sj-p));
    color: #fff;
    box-shadow: 0 6px 18px rgba(15, 157, 138, 0.3);
    transform: translateY(-1px);
}

/* ===== LANDING PAGE NAVIGATION CARDS ===== */
.sj-nav-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 35px;
}

.sj-nav-card {
    background: #fff;
    border-radius: 20px;
    padding: 25px 20px;
    text-decoration: none;
    color: inherit;
    border: 2px solid var(--sj-border);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.sj-nav-card:hover {
    border-color: var(--sj-accent);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(15, 157, 138, 0.12);
}

.sj-nav-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--sj-accent), var(--sj-p));
}

.sj-nav-card-body h3 {
    font-size: 1.05rem;
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
    margin-bottom: 4px;
}

.sj-nav-card-body p {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.sj-nav-card-arrow {
    margin-left: auto;
    color: var(--sj-accent);
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.sj-nav-card:hover .sj-nav-card-arrow {
    transform: translateX(5px);
}

/* ===== Page Content Fade-in ===== */
.sj-page-content {
    animation: sj-fade-in 0.4s ease;
}

@keyframes sj-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Section Cards ===== */
.sj-card {
    background: #fff;
    border-radius: 20px;
    padding: 25px 18px;
    margin-bottom: 30px;
    box-shadow: var(--sj-shadow);
    border: 1px solid var(--sj-border);
}

.sj-cheader {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 2px dashed #f1f5f9;
    padding-bottom: 15px;
}

.sj-cicon {
    width: 48px;
    height: 48px;
    background: rgba(15, 157, 138, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f9d8a;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sj-cheader h2 {
    font-size: 1.4rem;
    line-height: 1.25;
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
    font-weight: 700;
}

.sj-card h3 {
    font-size: 1.15rem;
    margin: 22px 0 14px;
    color: #073b4c;
    font-family: 'Outfit', sans-serif;
}

.sj-card h4 {
    font-size: 1rem;
    margin: 16px 0 10px;
    color: #1e293b;
    font-weight: 600;
}

.sj-card p {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #334155;
}

/* ===== Callout Boxes ===== */
.sj-ibox {
    background: #f0fdfa;
    border-left: 4px solid #0f9d8a;
    padding: 18px;
    border-radius: 0 14px 14px 0;
    margin: 18px 0;
    display: flex;
    gap: 12px;
}

.sj-ibox.warn {
    background: #fffbe6;
    border-left-color: #f39c12;
}

.sj-ibox.info {
    background: #f0f9ff;
    border-left-color: #0284c7;
}

.sj-ibox.success {
    background: #f0fdf4;
    border-left-color: #16a34a;
}

.sj-ibox.danger {
    background: #fef2f2;
    border-left-color: #ef4444;
}

/* ===== Formula Box ===== */
.sj-formula {
    background: #0f172a;
    color: #f8fafc;
    border-radius: 16px;
    padding: 22px 18px;
    text-align: center;
    font-size: 1.15rem;
    margin: 22px 0;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

/* ===== Three.js Animation Container ===== */
.sj-3d-container {
    width: 100%;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border-radius: 18px;
    overflow: hidden;
    margin: 22px 0;
    position: relative;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #334155;
}

.sj-3d-canvas {
    width: 100%;
    height: 320px;
    display: block;
}

.sj-3d-controls {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.sj-3d-btn {
    background: rgba(15, 157, 138, 0.9);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.sj-3d-btn:hover {
    background: rgba(15, 157, 138, 1);
    transform: scale(1.1);
}

.sj-3d-label {
    position: absolute;
    top: 12px;
    left: 16px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
}

.sj-3d-hint {
    position: absolute;
    top: 12px;
    right: 16px;
    color: #64748b;
    font-size: 0.7rem;
    z-index: 10;
}

/* ===== NCERT Exercise Questions ===== */
.sj-exercise-q {
    background: #fff;
    border: 1px solid var(--sj-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 18px;
    transition: box-shadow 0.2s;
}

.sj-exercise-q:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.sj-q-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sj-q-badge {
    background: var(--sj-accent);
    color: #fff;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.sj-q-text {
    font-size: 0.9rem;
    color: #0f172a;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.sj-ideal-answer {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--sj-accent);
    border-radius: 0 14px 14px 0;
    padding: 18px;
    margin-top: 12px;
}

.sj-ideal-answer summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--sj-accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sj-ideal-answer summary::-webkit-details-marker {
    display: none;
}

.sj-ideal-answer[open] summary {
    margin-bottom: 12px;
}

.sj-answer-content {
    font-size: 0.88rem;
    color: #334155;
    line-height: 1.8;
}

.sj-answer-content ol,
.sj-answer-content ul {
    margin-left: 18px;
    margin-bottom: 10px;
}

.sj-key-points {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 14px;
    margin-top: 12px;
}

.sj-key-points strong {
    color: #166534;
}

/* ===== Quiz Section ===== */
.sj-quiz-q {
    background: #fff;
    border: 1px solid var(--sj-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 18px;
}

.sj-quiz-opt {
    display: block;
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    margin-top: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s;
    background: #fff;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.sj-quiz-opt:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.sj-quiz-opt.correct {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
    font-weight: 700;
}

.sj-quiz-opt.wrong {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
}

.sj-quiz-feedback {
    display: none;
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.82rem;
}

.sj-quiz-feedback.show {
    display: block;
}

.sj-quiz-feedback.correct {
    background: #f0fdf4;
    color: #15803d;
}

.sj-quiz-feedback.wrong {
    background: #fef2f2;
    color: #b91c1c;
}

/* ===== Test Section ===== */
.sj-test-card {
    background: linear-gradient(135deg, #073b4c, #0f9d8a);
    border-radius: 20px;
    padding: 25px 20px;
    color: #fff;
    margin-bottom: 18px;
    text-align: center;
}

.sj-test-card h3 {
    color: #fff;
    margin-bottom: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
}

.sj-test-card p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    margin-bottom: 18px;
}

.sj-test-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    color: var(--sj-accent);
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
    min-height: 44px;
}

.sj-test-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.sj-test-meta {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.sj-test-meta span {
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== Revision Notes ===== */
.sj-revision-summary {
    background: #fff;
    border: 2px solid var(--sj-accent);
    border-radius: 20px;
    padding: 25px 20px;
    margin-bottom: 22px;
}

.sj-revision-summary h3 {
    color: var(--sj-accent);
    font-family: 'Outfit', sans-serif;
    margin-bottom: 14px;
    font-size: 1.15rem;
}

.sj-key-points-list {
    list-style: none;
    padding: 0;
}

.sj-key-points-list li {
    padding: 12px 12px 12px 38px;
    margin-bottom: 8px;
    background: #f0fdfa;
    border-radius: 12px;
    font-size: 0.88rem;
    color: #0f172a;
    position: relative;
}

.sj-key-points-list li::before {
    content: "\2713";
    position: absolute;
    left: 12px;
    top: 12px;
    color: var(--sj-accent);
    font-weight: 800;
}

.sj-mnemonic-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 14px;
    border-left: 5px solid #f59e0b;
}

.sj-mnemonic-card strong {
    color: #92400e;
}

/* ===== Tables ===== */
.sj-table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 0.82rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sj-table th,
.sj-table td {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
}

.sj-table th {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
}

.sj-table tr:nth-child(even) {
    background: #f8fafc;
}

/* ===== SVG Container ===== */
.sj-svg-container {
    width: 100%;
    background: #fcfcfd;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    margin: 22px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
}

.sj-svg-container svg {
    max-width: 100%;
    height: auto;
}

.sj-svg-caption {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 10px;
    text-align: center;
    font-weight: 500;
}

/* ===== Bottom Section Navigation (prev/next) ===== */
.sj-bottom-nav {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.sj-bottom-nav a {
    flex: 1;
    min-width: 140px;
    padding: 16px 20px;
    border-radius: 16px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    min-height: 44px;
}

.sj-bottom-nav .prev {
    background: #fff;
    color: var(--sj-s);
    border: 2px solid var(--sj-border);
}

.sj-bottom-nav .prev:hover {
    border-color: var(--sj-accent);
    background: #f0fdfa;
}

.sj-bottom-nav .next {
    background: linear-gradient(135deg, var(--sj-accent), var(--sj-p));
    color: #fff;
    justify-content: flex-end;
}

.sj-bottom-nav .next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 157, 138, 0.2);
}

/* ===== Responsive (min-width: 768px — tablet & up) ===== */
@media (min-width: 768px) {
    .sj-container {
        padding: 30px;
    }

    .sj-tbar {
        flex-direction: row;
        justify-content: space-between;
    }

    .sj-bcrumb {
        font-size: 0.75rem;
    }

    .sj-btn {
        flex: none;
        width: auto;
        padding: 10px 25px;
        font-size: 0.8rem;
    }

    .sj-hero-v6 {
        border-radius: 24px !important;
        padding: 70px 40px !important;
        min-height: 340px !important;
    }

    .sj-hero-v6 h1 {
        font-size: 3rem !important;
    }

    .sj-hero-v6 p {
        font-size: 1.1rem;
    }

    .sj-section-link {
        font-size: 0.85rem;
        padding: 14px 22px;
    }

    .sj-section-link i {
        font-size: 0.9rem;
    }

    .sj-nav-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .sj-nav-card {
        padding: 30px 25px;
    }

    .sj-nav-card-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .sj-nav-card-body h3 {
        font-size: 1.15rem;
    }

    .sj-nav-card-body p {
        font-size: 0.85rem;
    }

    .sj-card {
        border-radius: 24px;
        padding: 45px;
    }

    .sj-cheader h2 {
        font-size: 2.1rem;
    }

    .sj-cicon {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }

    .sj-card h3 {
        font-size: 1.25rem;
    }

    .sj-card p {
        font-size: 0.95rem;
    }

    .sj-formula {
        font-size: 1.35rem;
        padding: 25px 20px;
    }

    .sj-3d-container {
        border-radius: 20px;
        min-height: 400px;
    }

    .sj-3d-canvas {
        height: 400px;
    }

    .sj-table {
        font-size: 0.9rem;
        display: table;
    }

    .sj-table th,
    .sj-table td {
        padding: 12px 15px;
        white-space: normal;
    }

    .sj-quiz-opt {
        font-size: 0.9rem;
    }

    .sj-test-card {
        padding: 30px;
    }

    .sj-test-card h3 {
        font-size: 1.3rem;
    }

    .sj-revision-summary {
        padding: 30px;
    }

    .sj-key-points-list li {
        font-size: 0.9rem;
    }
}

/* ===== Large screens (min-width: 1024px) ===== */
@media (min-width: 1024px) {
    .sj-nav-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Mobile Header & Overflow Fixes ===== */
@media (max-width: 768px) {
    .sj-tbar .sj-nav {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .header-container {
        padding: 0 8px !important;
    }

    .header-actions {
        gap: 4px !important;
    }

    #headerLangToggleBtn {
        padding: 4px 6px !important;
        font-size: 0.75rem !important;
        margin-right: 2px !important;
    }

    .auth-btn-pill {
        padding: 6px 8px !important;
        font-size: 0.7rem !important;
    }

    .mobile-toggle {
        width: 32px !important;
        height: 32px !important;
        flex-basis: 32px !important;
        font-size: 1rem !important;
    }
}

/* ===== Dark Mode Styling for Science Chapters ===== */
body.dark-mode {
    background: #0f172a !important;
    color: #f8fafc !important;
}

body.dark-mode .sj-card,
body.dark-mode .sj-nav-card,
body.dark-mode .sj-exercise-q,
body.dark-mode .sj-quiz-q,
body.dark-mode .sj-revision-summary,
body.dark-mode .sj-section-nav,
body.dark-mode .sj-svg-container,
body.dark-mode .sj-ideal-answer {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .sj-cheader h2,
body.dark-mode .sj-card h3,
body.dark-mode .sj-card h4,
body.dark-mode .sj-card p,
body.dark-mode .sj-nav-card-body h3,
body.dark-mode .sj-nav-card-body p,
body.dark-mode .sj-q-text,
body.dark-mode .sj-answer-content,
body.dark-mode .sj-quiz-opt {
    color: #f8fafc !important;
}

body.dark-mode .sj-card p,
body.dark-mode .sj-nav-card-body p,
body.dark-mode .sj-answer-content {
    color: #94a3b8 !important;
}

body.dark-mode .sj-section-link {
    color: #94a3b8 !important;
}

body.dark-mode .sj-section-link:hover {
    background: #334155 !important;
    color: #fff !important;
}

body.dark-mode .sj-section-link.active {
    background: linear-gradient(135deg, #0f9d8a, #059669) !important;
    color: #fff !important;
}

body.dark-mode .sj-table th {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

body.dark-mode .sj-table td {
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

body.dark-mode .sj-table tr:nth-child(even) {
    background: #1a2234 !important;
}

body.dark-mode .sj-ibox {
    background: rgba(15, 157, 138, 0.1) !important;
    color: #cbd5e1 !important;
}

body.dark-mode .sj-ibox.warn {
    background: rgba(243, 156, 18, 0.1) !important;
}

body.dark-mode .sj-ibox.info {
    background: rgba(2, 132, 199, 0.1) !important;
}

body.dark-mode .sj-ibox.success {
    background: rgba(22, 163, 74, 0.1) !important;
}

body.dark-mode .sj-ibox.danger {
    background: rgba(239, 68, 68, 0.1) !important;
}

body.dark-mode .sj-quiz-opt {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode .sj-quiz-opt:hover {
    background: #334155 !important;
    border-color: #475569 !important;
}

body.dark-mode .sj-bottom-nav .prev {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode .sj-bottom-nav .prev:hover {
    background: #334155 !important;
}

body.dark-mode .sj-btn {
    background: #1e293b !important;
    border-color: var(--sj-p) !important;
    color: #34d399 !important;
}

body.dark-mode .sj-btn:hover {
    background: rgba(15, 157, 138, 0.15) !important;
}

body.dark-mode .sj-key-points-list li {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
}

/* UNIVERSAL MATH FORMULA NO-SCROLL SPINNER OVERRIDE */
mjx-container,
mjx-container *,
mjx-math,
mjx-math * {
    overflow: visible !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}
mjx-container::-webkit-scrollbar,
mjx-container *::-webkit-scrollbar,
mjx-math::-webkit-scrollbar,
mjx-math *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
mjx-assistive-mml {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
}
.katex, .katex-display, .MathJax, .MathJax_Display {
    overflow: visible !important;
    scrollbar-width: none !important;
}
.katex::-webkit-scrollbar, .MathJax::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}



        /* Unified Tab Content Display */
        .tab-pane {
            display: none;
            animation: fadeInTab 0.35s ease;
        }

        .tab-pane.active {
            display: block;
        }

        @keyframes fadeInTab {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Detail Toggles for Solved Examples */
        details.example-solution, details.exercise-solution {
            margin-top: 12px;
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            border-radius: 10px;
            padding: 12px 16px;
            transition: all 0.25s ease;
        }

        details.example-solution[open], details.exercise-solution[open] {
            background: #f0f3ff;
            border-color: #4f46e5;
        }

        details summary {
            font-size: 0.9rem;
            font-weight: 700;
            color: #4f46e5;
            cursor: pointer;
            outline: none;
            user-select: none;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        details summary::-webkit-details-marker {
            display: none;
        }

        details summary::before {
            content: "\f054";
            font-family: "Font Awesome 6 Free";
            font-weight: 900;
            font-size: 0.75rem;
            transition: transform 0.2s ease;
        }

        details[open] summary::before {
            transform: rotate(90deg);
        }

        .solution-content {
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px dashed #cbd5e1;
            font-size: 0.92rem;
            color: #334155;
            line-height: 1.6;
        }

        /* Worksheets Styling */
        .ws-level-badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.72rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 10px;
        }
        .ws-level-badge.easy { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
        .ws-level-badge.medium { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
        .ws-level-badge.hard { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
        
        .ws-list {
            list-style: none;
            padding: 0;
            margin: 15px 0;
        }
        .ws-item {
            background: #f8fafc;
            padding: 16px 20px;
            border-radius: 12px;
            margin-bottom: 12px;
            border: 1px solid #e2e8f0;
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }
        .ws-num {
            background: #cbd5e1;
            color: #334155;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.78rem;
            font-weight: 700;
            flex-shrink: 0;
        }
        .ws-btn-print {
            background: #4f46e5;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 50px;
            font-family: 'Outfit', sans-serif;
            font-weight: 700;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s ease;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
            text-decoration: none;
            font-size: 0.88rem;
        }
        .ws-btn-print:hover {
            background: #4338ca;
            transform: translateY(-2px);
        }

        /* Revision Table */
        .rev-table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
            font-size: 0.9rem;
        }
        .rev-table th, .rev-table td {
            border: 1px solid #e2e8f0;
            padding: 12px 16px;
            text-align: left;
        }
        .rev-table th {
            background: #f1f5f9;
            color: #1e293b;
            font-weight: 700;
        }
        .rev-table tr:nth-child(even) {
            background: #f8fafc;
        }

        /* Test Engine Styles */
        .test-selection-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            margin: 20px 0;
        }
        @media (min-width: 768px) {
            .test-selection-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }
        .sj-test-card {
            background: #fff;
            border-radius: 16px;
            border: 1px solid #e2e8f0;
            padding: 22px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.02);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        .sj-test-meta {
            display: flex;
            gap: 12px;
            font-size: 0.78rem;
            color: #64748b;
            margin: 12px 0 20px;
        }
        .sj-test-btn {
            padding: 10px 18px;
            border-radius: 50px;
            font-weight: 700;
            font-size: 0.85rem;
            color: white;
            background: #4f46e5;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
        }
        .sj-test-btn:hover {
            background: #4338ca;
            transform: translateY(-1px);
        }
        .test-progress-bar {
            width: 100%;
            height: 8px;
            background: #e2e8f0;
            border-radius: 4px;
            margin-bottom: 25px;
            overflow: hidden;
        }
        .test-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #4f46e5, #3b82f6);
            width: 0%;
            transition: width 0.4s ease;
        }
        .option-button {
            display: block;
            width: 100%;
            padding: 14px 18px;
            background: #f8fafc;
            border: 2px solid #e2e8f0;
            border-radius: 12px;
            text-align: left;
            font-size: 0.95rem;
            font-family: 'Poppins', sans-serif;
            color: #334155;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-bottom: 12px;
        }
        .option-button:hover:not(:disabled) {
            background: #f1f5f9;
            border-color: #cbd5e1;
            transform: translateX(4px);
        }
        .option-button.selected {
            background: #e0e7ff !important;
            border-color: #4f46e5 !important;
            color: #4f46e5 !important;
            font-weight: 600;
        }
        .grading-option {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px 16px;
            border-radius: 50px;
            font-size: 0.82rem;
            font-weight: 700;
            cursor: pointer;
            border: 2px solid #cbd5e1;
            background: #fff;
            transition: all 0.2s;
            margin-right: 8px;
            margin-top: 8px;
        }
        .grading-option.active-full {
            border-color: #10b981;
            background: #ecfdf5;
            color: #065f46;
        }
        .grading-option.active-half {
            border-color: #f59e0b;
            background: #fffbeb;
            color: #78350f;
        }
        .grading-option.active-zero {
            border-color: #ef4444;
            background: #fef2f2;
            color: #991b1b;
        }
        .test-action-btn {
            background: #4f46e5;
            color: white;
            border: none;
            padding: 12px 24px;
            font-family: 'Outfit', sans-serif;
            font-weight: 700;
            font-size: 0.9rem;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .test-action-btn:hover {
            background: #4338ca;
            transform: translateY(-1px);
        }
        .test-action-btn:disabled {
            background: #cbd5e1;
            cursor: not-allowed;
            transform: none;
        }

        @media print {
            body { background: white !important; color: black !important; }
            .sj-tbar, .sj-section-nav, #header-container, #footer-container, .sj-bottom-nav, .ws-btn-print {
                display: none !important;
            }
            .tab-pane { display: block !important; }
            .sj-card {
                box-shadow: none !important;
                border: none !important;
                padding: 0 !important;
                margin-bottom: 40px !important;
                page-break-inside: avoid;
            }
            .sj-container { max-width: 100% !important; padding: 0 !important; }
            .ws-item { border: 1px dashed #cbd5e1 !important; background: transparent !important; }
        }
    