/* ===== QUESTION CARD ===== */
        .question-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 1.4rem;
            margin-bottom: 1.5rem;
            box-shadow: var(--shadow-sm);
            transition: all var(--transition-fast);
        }
        .question-card:hover {
            border-color: var(--border-hover);
        }
        .question-card.test-mode {
            border-left: 4px solid var(--accent);
        }
        .question-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
            padding-bottom: 0.55rem;
            margin-bottom: 0.65rem;
            border-bottom: 1px solid var(--border);
            min-width: 0;
        }
        .question-meta-group {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            flex-wrap: wrap;
            min-width: 0;
            flex: 1;
        }
        .meta-dot {
            color: var(--text-muted);
            font-weight: 700;
            font-size: 0.75rem;
            opacity: 0.5;
            user-select: none;
        }
        .question-card-top-actions {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            flex-shrink: 0;
        }
        .type-badge {
            display: inline-flex;
            align-items: center;
            font-size: 0.68rem;
            font-weight: 700;
            text-transform: lowercase;
            letter-spacing: 0.3px;
            color: var(--text-muted);
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 0.12rem 0.45rem;
            line-height: 1.2;
        }
        .question-number {
            font-size: 0.98rem;
            font-weight: 800;
            color: var(--text-primary);
            letter-spacing: -0.2px;
            text-transform: none;
            margin-bottom: 0;
            line-height: 1.2;
        }
        .question-topic-tag {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.68rem;
            font-weight: 600;
            color: var(--text-muted);
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 0.12rem 0.45rem;
            max-width: 200px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.2;
            margin-bottom: 0;
        }
        .lang-pill-group {
            display: inline-flex;
            align-items: center;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 50px;
            padding: 2px;
            gap: 2px;
        }
        .lang-pill {
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 0.75rem;
            font-weight: 700;
            padding: 0.2rem 0.6rem;
            border-radius: 50px;
            cursor: pointer;
            transition: all var(--transition-fast);
        }
        .lang-pill.active {
            background: var(--accent);
            color: #000;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
        }
        .grid-lang-bar,
        .grid-order-bar,
        .grid-filter-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 0.35rem 0.75rem;
            margin-bottom: 0.55rem;
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--text-primary);
        }
        .grid-topic-select {
            padding: 0.3rem 0.6rem;
            background: var(--bg-secondary);
            color: var(--text-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 0.78rem;
            font-weight: 600;
            outline: none;
            max-width: 65%;
            cursor: pointer;
        }
        .view-mode-toggle {
            display: inline-flex;
            align-items: center;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 50px;
            padding: 2px;
            gap: 2px;
        }
        .view-mode-btn {
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 0.74rem;
            font-weight: 700;
            padding: 0.2rem 0.55rem;
            border-radius: 50px;
            cursor: pointer;
            transition: all var(--transition-fast);
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            line-height: 1.2;
        }
        .view-mode-btn.active {
            background: var(--accent);
            color: #000;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        }
        .question-exam-tag {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.3px;
            border-radius: 50px;
            padding: 0.25rem 0.7rem;
            margin-bottom: 0;
        }
        .question-exam-tag.mains {
            color: #3b82f6;
            background: rgba(59, 130, 246, 0.12);
            border: 1px solid rgba(59, 130, 246, 0.25);
        }
        .question-exam-tag.advanced {
            color: #f59e0b;
            background: rgba(245, 158, 11, 0.12);
            border: 1px solid rgba(245, 158, 11, 0.3);
        }
        .question-text {
            font-size: 1rem;
            line-height: 1.7;
            /* style.css also defines .question-text at weight 600 — reset it here
               so the wording matches Test Cafe's .q-text. */
            font-weight: 400;
            color: var(--text-primary);
            margin-bottom: 1rem;
            white-space: pre-wrap;
            overflow-wrap: break-word;
            word-break: break-word;
            min-width: 0;
        }

        /* Smart Image Color Inversion in Dark Mode (from Quizzy-v4) */
        .question-image,
        .explanation-img,
        .mcq-opt-image,
        .image-question-wrap img,
        .question-text img,
        .explanation-text img,
        .q-explain img {
            max-width: 100% !important;
            height: auto;
            object-fit: contain;
            box-sizing: border-box;
            transition: filter 0.3s ease;
            filter: invert(1) hue-rotate(180deg) brightness(1.1);
            mix-blend-mode: screen;
        }

        [data-theme="light"] .question-image,
        [data-theme="light"] .explanation-img,
        [data-theme="light"] .mcq-opt-image,
        [data-theme="light"] .image-question-wrap img,
        [data-theme="light"] .question-text img,
        [data-theme="light"] .explanation-text img,
        [data-theme="light"] .q-explain img {
            filter: none;
            mix-blend-mode: darken;
        }

        /* ===== MATCH THE COLUMN / LIST-I / LIST-II TABLE ===== */
        .match-table-wrap {
            width: 100%;
            overflow-x: auto;
            margin: 1rem 0 1.25rem 0;
            -webkit-overflow-scrolling: touch;
        }
        .match-table {
            width: 100%;
            min-width: 440px;
            max-width: 100%;
            border-collapse: collapse;
            background: var(--bg-card);
            border: 2px solid var(--border-strong);
            border-radius: var(--radius-sm);
            font-size: 0.95rem;
            color: var(--text-primary);
            table-layout: auto;
        }
        .match-table thead tr {
            background: var(--bg-secondary);
            border-bottom: 2px solid var(--border-strong);
        }
        .match-table th.match-th {
            padding: 0.65rem 0.85rem;
            text-align: center;
            font-size: 0.95rem;
            font-weight: 700;
            color: var(--text-primary);
            letter-spacing: 0.2px;
        }
        .match-table th.match-th:first-child {
            border-right: 2px solid var(--border-strong);
        }
        .match-table tbody tr {
            border-bottom: 1px solid var(--border-strong);
        }
        .match-table tbody tr:last-child {
            border-bottom: none;
        }
        .match-table td {
            padding: 0.65rem 0.85rem;
            vertical-align: middle;
        }
        .match-table td.match-col-label {
            width: 3.5rem;
            min-width: 3rem;
            text-align: center;
            font-weight: 700;
            color: var(--text-primary);
            border-right: 1px solid var(--border);
            white-space: nowrap;
        }
        .match-table td.match-col-content {
            line-height: 1.55;
            color: var(--text-primary);
        }
        .match-table td.match-col-content:first-of-type {
            border-right: 2px solid var(--border-strong);
        }
        .match-table .match-item-text {
            font-size: 0.95rem;
        }
        .match-table .match-item-img-wrap {
            margin-top: 0.4rem;
        }
        .match-table .match-item-img {
            max-width: 100%;
            height: auto;
            max-height: 140px;
            object-fit: contain;
            border-radius: var(--radius-sm);
        }
        @media (max-width: 600px) {
            .match-table th.match-th,
            .match-table td {
                padding: 0.5rem 0.55rem;
                font-size: 0.88rem;
            }
            .match-table td.match-col-label {
                width: 2.5rem;
                min-width: 2.2rem;
            }
        }

        /* ===== FILL IN THE BLANK ===== */
        .fib-answer-box {
            display: none;
            margin-top: 1.25rem;
            padding: 1.25rem;
            background: linear-gradient(135deg, rgba(0,212,170,0.08), rgba(0,212,170,0.02));
            border: 2px solid var(--accent);
            border-radius: var(--radius-md);
            animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }
        .fib-answer-box::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient(90deg, var(--accent), var(--accent-light));
        }
        .fib-answer-box.show { display: block; }
        .fib-answer-label {
            font-size: 0.72rem;
            color: var(--accent);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 0.5rem;
        }
        .fib-answer-text {
            font-size: 1rem;
            color: var(--text-primary);
            font-weight: 600;
            line-height: 1.6;
        }

        /* ===== INTEGER TYPE ===== */
        .int-input-wrap {
            display: flex;
            gap: 0.75rem;
            margin-bottom: 1.25rem;
        }
        .int-input {
            flex: 1;
            padding: 1rem 1.25rem;
            background: var(--bg-primary);
            border: 2px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text-primary);
            font-size: 1rem;
            font-family: inherit;
            outline: none;
            transition: all 0.3s ease;
        }
        .int-input:focus {
            border-color: var(--accent);
            box-shadow: 0 0 20px var(--accent-glow);
        }
        .int-input::placeholder { color: var(--text-muted); }
        .int-check-btn {
            padding: 1rem 1.75rem;
            background: linear-gradient(135deg, var(--accent), var(--accent-light));
            border: none;
            border-radius: var(--radius-md);
            color: var(--bg-primary);
            font-size: 0.9rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            white-space: nowrap;
            box-shadow: 0 4px 15px var(--accent-glow);
        }
        .int-check-btn:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-glow);
        }
        .int-feedback {
            display: none;
            padding: 0.875rem 1.25rem;
            border-radius: var(--radius-sm);
            margin-bottom: 1.25rem;
            font-size: 0.9rem;
            font-weight: 600;
            animation: slideUp 0.3s ease;
        }
        .int-feedback.correct {
            display: block;
            background: rgba(39, 174, 96, 0.1);
            border: 1.5px solid var(--success);
            color: var(--success);
        }
        .int-feedback.wrong {
            display: block;
            background: rgba(231, 76, 60, 0.1);
            border: 1.5px solid var(--error);
            color: var(--error);
        }

        /* ===== MCQ OPTIONS ===== */
        .mcq-options {
            display: flex;
            flex-direction: column;
            gap: 0.6rem;
            margin-bottom: 1.25rem;
        }
        .mcq-option {
            width: 100%;
            display: flex;
            align-items: flex-start;
            gap: 0.85rem;
            padding: 0.9rem 1rem;
            background: var(--bg-secondary);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-md);
            text-align: left;
            font-family: inherit;
            font-size: 0.92rem;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all var(--transition-fast);
            position: relative;
            box-sizing: border-box;
        }
        .mcq-option:not(.read-only):hover {
            border-color: var(--accent);
            background: var(--bg-hover);
            color: var(--text-primary);
        }
        .mcq-option.read-only { cursor: default; }
        .mcq-letter {
            width: 28px;
            height: 28px;
            flex-shrink: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            font-size: 0.78rem;
            font-weight: 800;
            color: var(--text-muted);
            transition: all var(--transition-fast);
        }
        /* .mcq-text is the option BODY (text + image + flag). Only the text span
           itself gets pre-wrap — putting it on the body would render the markup's
           own indentation as blank space in front of every option. */
        .mcq-text {
            flex: 1;
            min-width: 0;
        }
        .mcq-opt-text {
            display: block;
            line-height: 1.55;
            white-space: pre-wrap;
            overflow-wrap: break-word;
            word-break: break-word;
        }
        .mcq-opt-image {
            display: block;
            max-width: 100%;
            height: auto;
            object-fit: contain;
            margin-top: 0.4rem;
            border-radius: var(--radius-sm);
        }
        .mcq-flag {
            display: inline-block;
            margin-top: 0.45rem;
            font-size: 0.72rem;
            font-weight: 800;
            letter-spacing: 0.2px;
            text-transform: uppercase;
            opacity: 0.9;
        }
        .mcq-option.selected {
            border-color: var(--accent);
            background: var(--accent-glow);
            color: var(--text-primary);
        }
        .mcq-option.selected .mcq-letter {
            background: var(--accent);
            border-color: var(--accent);
            color: #fff;
        }
        .mcq-option.correct {
            border-color: var(--st-green);
            background: var(--st-green-bg);
            color: var(--text-primary);
        }
        .mcq-option.correct .mcq-letter {
            background: var(--st-green);
            border-color: var(--st-green);
            color: #fff;
        }
        .mcq-option.correct .mcq-flag { color: var(--st-green); }
        .mcq-option.wrong {
            border-color: var(--st-red);
            background: var(--st-red-bg);
            color: var(--text-primary);
        }
        .mcq-option.wrong .mcq-letter {
            background: var(--st-red);
            border-color: var(--st-red);
            color: #fff;
        }
        .mcq-option.wrong .mcq-flag { color: var(--st-red); }
        .mcq-option.partial {
            border-color: var(--warning);
            background: var(--warning-bg);
            color: var(--text-primary);
        }
        .mcq-option.partial .mcq-letter {
            background: var(--warning);
            border-color: var(--warning);
            color: #fff;
        }

        /* ===== MULTI-CORRECT SUBMIT ===== */
        .multi-submit-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.6rem;
            width: 100%;
            padding: 1rem;
            background: linear-gradient(135deg, var(--accent), var(--accent-light));
            border: none;
            border-radius: var(--radius-md);
            color: var(--bg-primary);
            font-size: 0.95rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-bottom: 1.25rem;
            box-shadow: 0 4px 15px var(--accent-glow);
        }
        .multi-submit-btn:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-glow);
        }
        .multi-submit-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
            transform: none;
        }
        .multi-selected-count {
            font-size: 0.8rem;
            color: var(--text-muted);
            text-align: center;
            margin-bottom: 0.75rem;
        }

        /* ===== SHOW ANSWER ===== */
        .show-answer-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.6rem;
            width: 100%;
            padding: 0.85rem 1rem;
            background: var(--bg-secondary);
            border: 1.5px dashed var(--border);
            border-radius: var(--radius-md);
            color: var(--text-secondary);
            font-size: 0.9rem;
            font-weight: 700;
            cursor: pointer;
            transition: all var(--transition-fast);
            margin-top: 0.75rem;
        }
        .show-answer-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
            background: var(--accent-glow);
        }
        .show-answer-btn.revealed {
            border-style: solid;
            border-color: var(--accent);
            color: var(--accent);
            background: var(--accent-glow);
        }

        /* ===== EXPLANATION BOX ===== */
        .explanation-box, .q-explain {
            display: none;
            margin-top: 1.25rem;
            padding: 1rem 1.1rem;
            background: var(--bg-secondary);
            border-left: 3px solid var(--accent);
            border-radius: var(--radius-sm);
            animation: slideUp 0.3s ease;
        }
        .explanation-box.show, .q-explain.show,
        .q-analysis-panel .q-explain,
        .q-solution-panel .q-explain { display: block; }
        .explanation-box h4, .q-explain h4 {
            font-size: 0.82rem;
            font-weight: 800;
            color: var(--accent);
            margin-bottom: 0.45rem;
            text-transform: none;
            letter-spacing: normal;
        }
        .explanation-box p, .q-explain p,
        .explanation-text, .q-explain-text {
            font-size: 0.88rem;
            line-height: 1.7;
            color: var(--text-secondary);
            margin: 0;
        }
        /* Rich HTML content inside explanations and question text */
        .explanation-text ul, .q-explain-text ul,
        .explanation-text ol, .q-explain-text ol,
        .question-text ul, .q-text ul,
        .question-text ol, .q-text ol {
            padding-left: 1.5rem;
            margin: 0.5rem 0;
        }
        .explanation-text li, .q-explain-text li,
        .question-text li, .q-text li {
            margin: 0.25rem 0;
            font-size: 0.88rem;
            line-height: 1.65;
            color: var(--text-secondary);
        }
        .explanation-text table, .q-explain-text table,
        .question-text table, .q-text table {
            border-collapse: collapse;
            width: 100%;
            max-width: 100%;
            margin: 0.8rem 0;
            font-size: 0.92rem;
            table-layout: auto;
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm, 8px);
        }
        .explanation-text th, .explanation-text td,
        .q-explain-text th, .q-explain-text td,
        .question-text th, .question-text td,
        .q-text th, .q-text td {
            border: 1px solid var(--border);
            padding: 0.55rem 0.75rem;
            text-align: left;
            vertical-align: middle;
            color: var(--text-secondary);
        }
        .explanation-text th, .q-explain-text th,
        .question-text th, .q-text th {
            background: var(--bg-secondary);
            font-weight: 700;
            color: var(--text-primary);
        }
        /* Table label cells: (a), (b), (i), (ii), etc. */
        .question-text td.td-label, .q-text td.td-label,
        .explanation-text td.td-label, .q-explain-text td.td-label {
            white-space: nowrap !important;
            text-align: center !important;
            font-weight: 700 !important;
            width: 3.2rem !important;
            min-width: 3rem !important;
            color: var(--teal-accent, #00bfa5) !important;
            background: rgba(0, 191, 165, 0.04);
        }
        /* Empty header cells for matching columns */
        .question-text th.th-empty, .q-text th.th-empty,
        .question-text th:empty, .q-text th:empty,
        .explanation-text th.th-empty, .q-explain-text th.th-empty,
        .explanation-text th:empty, .q-explain-text th:empty {
            background: transparent !important;
            border-top-color: transparent !important;
            border-left-color: transparent !important;
            border-right-color: transparent !important;
            border-bottom: 1.5px solid var(--border) !important;
            width: 3.2rem !important;
            min-width: 3rem !important;
        }
        .explanation-img, .q-explain-img {
            max-width: 100%;
            max-height: 60vh;
            height: auto;
            object-fit: contain;
            margin-top: 0.6rem;
            border-radius: var(--radius-sm);
            display: block;
        }

        /* ===== QUIZ NAVIGATION ===== */
        .quiz-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 1.25rem;
            border-top: 1px solid var(--border);
            margin-top: 0.5rem;
        }
        .nav-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text-secondary);
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }
        .nav-btn:hover:not(:disabled) {
            border-color: var(--accent);
            color: var(--accent);
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.15);
        }
        .nav-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        /* ===== END-OF-SET CONTINUE PANEL ===== */
        .continue-panel {
            text-align: center;
            padding: 2rem 1.25rem;
            margin-top: 1.5rem;
            background: linear-gradient(135deg, var(--bg-card), rgba(255,255,255,0.02));
            border: 1.5px solid var(--border);
            border-left: 4px solid var(--accent);
            border-radius: var(--radius-lg);
        }
        .continue-panel h3 {
            font-size: 1.1rem;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 0.4rem;
        }
        .continue-panel p {
            font-size: 0.88rem;
            color: var(--text-muted);
            margin-bottom: 1.25rem;
        }
        .continue-panel strong { color: var(--accent); }
        .continue-count {
            display: inline-block;
            margin-left: 0.4rem;
            padding: 0.1rem 0.5rem;
            border-radius: 50px;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            font-size: 0.72rem;
            color: var(--text-muted);
        }
        .continue-actions {
            display: flex;
            gap: 0.75rem;
            justify-content: center;
            flex-wrap: wrap;
        }

        /* ===== FULL QUIZ SCROLL MODE ===== */
        .full-quiz-container {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            padding-bottom: 2rem;
        }
        /* Clears the sticky header + progress bar when jumping to a question. */
        .full-quiz-container .question-card,
        .test-question-list .question-card {
            scroll-margin-top: 150px;
        }
        .full-quiz-nav {
            position: fixed;
            bottom: 1.5rem;
            right: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            z-index: 100;
        }
        .full-quiz-nav-btn {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            color: var(--text-secondary);
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        }
        .full-quiz-nav-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
            transform: scale(1.1);
            box-shadow: 0 0 20px var(--accent-glow);
        }

        /* ===== TEST MODE ===== */
        .test-question-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            padding-bottom: 6rem;
        }
        .test-submit-bar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-secondary);
            border-top: 1.5px solid var(--border);
            padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
            display: flex;
            justify-content: center;
            gap: 1rem;
            z-index: 100;
            box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
        }
        .test-submit-btn {
            padding: 0.875rem 2.5rem;
            background: linear-gradient(135deg, var(--accent), var(--accent-light));
            border: none;
            border-radius: var(--radius-md);
            color: var(--bg-primary);
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px var(--accent-glow);
        }
        .test-submit-btn:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-glow);
        }
        .test-answered-count {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.875rem 1.25rem;
            background: var(--bg-primary);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-md);
            font-size: 0.85rem;
            color: var(--text-muted);
            font-weight: 600;
        }
        .test-answered-count .count {
            color: var(--accent);
            font-weight: 700;
        }

        /* ===== REVIEW MODE ===== */
        .review-header {
            text-align: center;
            padding: 1.5rem 0;
        }
        .review-header h2 {
            font-size: 1.5rem;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 0.5rem;
        }
        .review-filter-bar {
            display: flex;
            gap: 0.5rem;
            justify-content: center;
            flex-wrap: wrap;
            margin-bottom: 1.5rem;
        }
        .review-filter-btn {
            padding: 0.5rem 1rem;
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            border-radius: 50px;
            color: var(--text-muted);
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .review-filter-btn:hover, .review-filter-btn.active {
            border-color: var(--accent);
            color: var(--accent);
            background: rgba(0, 212, 170, 0.08);
        }
        .review-question-card {
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
            margin-bottom: 1rem;
        }
        .review-question-card.correct-card {
            border-left: 4px solid var(--success);
        }
        .review-question-card.wrong-card {
            border-left: 4px solid var(--error);
        }
        .review-question-card.skipped-card {
            border-left: 4px solid var(--warning);
        }
        .review-status-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            padding: 0.25rem 0.6rem;
            border-radius: 50px;
            font-size: 0.7rem;
            font-weight: 700;
            text-transform: uppercase;
            margin-bottom: 0.75rem;
        }
        .review-status-badge.correct {
            background: rgba(39, 174, 96, 0.1);
            color: var(--success);
            border: 1px solid var(--success);
        }
        .review-status-badge.wrong {
            background: rgba(231, 76, 60, 0.1);
            color: var(--error);
            border: 1px solid var(--error);
        }
        .review-status-badge.skipped {
            background: rgba(243, 156, 18, 0.1);
            color: var(--warning);
            border: 1px solid var(--warning);
        }
        .review-user-answer {
            margin-top: 1rem;
            padding: 0.75rem 1rem;
            background: var(--bg-primary);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
        }
        .review-user-answer .label {
            color: var(--text-muted);
            font-weight: 600;
            margin-bottom: 0.25rem;
        }
        .review-user-answer .value {
            color: var(--text-primary);
            font-weight: 500;
        }
        .review-correct-answer {
            margin-top: 0.75rem;
            padding: 0.75rem 1rem;
            background: rgba(0, 212, 170, 0.05);
            border: 1px solid var(--accent);
            border-radius: var(--radius-sm);
            font-size: 0.85rem;
        }
        .review-correct-answer .label {
            color: var(--accent);
            font-weight: 600;
            margin-bottom: 0.25rem;
        }
        .review-correct-answer .value {
            color: var(--text-primary);
            font-weight: 500;
        }

        /* ===== RESULTS SCREEN ===== */
        .results-hero {
            text-align: center;
            padding: 2rem 0 1rem;
        }
        .results-hero h1 {
            font-size: 1.8rem;
            font-weight: 800;
            color: var(--text-primary);
        }
        .results-card {
            text-align: center;
            padding: 2.5rem 1.5rem;
            background: linear-gradient(135deg, var(--bg-card), rgba(255,255,255,0.02));
            border: 1.5px solid var(--border);
            border-radius: var(--radius-lg);
            backdrop-filter: blur(20px);
            box-shadow: var(--shadow-card);
            margin-bottom: 2rem;
        }
        .results-score-big {
            font-size: 4.5rem;
            font-weight: 900;
            color: var(--accent);
            line-height: 1;
            text-shadow: 0 0 40px var(--accent-glow);
            animation: scorePop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        @keyframes scorePop {
            0% { transform: scale(0.3); opacity: 0; }
            100% { transform: scale(1); opacity: 1; }
        }
        .results-label {
            font-size: 0.95rem;
            color: var(--text-muted);
            margin: 1rem 0 2rem;
        }
        .results-stats-row {
            display: flex;
            justify-content: center;
            gap: 1.25rem;
            margin: 1.5rem 0;
            flex-wrap: wrap;
        }
        .results-stat-box {
            text-align: center;
            padding: 1.25rem 1.5rem;
            background: var(--bg-primary);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-md);
            min-width: 90px;
            transition: all 0.3s ease;
        }
        .results-stat-box:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.15);
        }
        .results-stat-box .value {
            font-size: 1.8rem;
            font-weight: 800;
        }
        .results-stat-box .value.correct { color: var(--success); text-shadow: 0 0 10px rgba(39, 174, 96, 0.3); }
        .results-stat-box .value.wrong { color: var(--error); text-shadow: 0 0 10px rgba(231, 76, 60, 0.3); }
        .results-stat-box .value.skipped { color: var(--warning); text-shadow: 0 0 10px rgba(243, 156, 18, 0.3); }
        .results-stat-box .label {
            font-size: 0.72rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-top: 0.35rem;
            font-weight: 600;
        }
        .results-percentage {
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 1.5rem;
        }
        .results-time {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin-bottom: 1.5rem;
        }
        .results-actions {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            max-width: 300px;
            margin: 0 auto;
        }

        /* ===== LOADING ===== */
        .loading-wrap {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 50vh;
            gap: 1.25rem;
        }
        .loading-wrap p {
            color: var(--text-muted);
            font-size: 0.95rem;
        }

        /* ===== PAGE HERO ===== */
        .page-hero {
            text-align: center;
            padding: 2rem 0 1rem;
        }
        .page-hero h1 {
            font-size: 1.7rem;
            font-weight: 800;
            color: var(--text-primary);
            margin-bottom: 0.4rem;
            letter-spacing: -0.3px;
        }
        .page-hero p {
            font-size: 0.88rem;
            color: var(--text-muted);
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 600px) {
            .subject-hero .hero-logo { width: 80px; }
            .subject-hero h1 { font-size: 1.5rem; }
            .subject-rect { padding: 1rem 1.25rem; }
            .subject-rect .rect-emoji { width: 48px; height: 48px; font-size: 1.8rem; }
            .quiz-header { flex-wrap: wrap; gap: 0.5rem; }
            .quiz-title-wrap { order: 3; width: 100%; text-align: left; margin-top: 0.25rem; }
            .question-card { padding: 1.25rem; }
            .results-score-big { font-size: 3.5rem; }
            .results-stats-row { gap: 0.75rem; }
            .results-stat-box { padding: 1rem; min-width: 70px; }
            .question-grid-panel { width: 95%; max-height: 85vh; }
            .grid-nums { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
            .mode-grid { grid-template-columns: 1fr; }
            .test-submit-bar { padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); gap: 0.5rem; }
            .test-submit-btn { padding: 0.75rem 1.5rem; font-size: 0.9rem; }
            .full-quiz-nav { bottom: calc(1rem + env(safe-area-inset-bottom)); right: 1rem; }
            .full-quiz-nav-btn { width: 40px; height: 40px; font-size: 1rem; }
            .bookmark-panel { width: 94%; max-height: 85vh; }
            .bookmark-panel-header .bookmark-close { width: 38px; height: 38px; }
            .bookmark-actions { flex-direction: column; }
            .bookmark-actions .btn { width: 100%; }
        }

        /* Mirrors the Test Cafe's 520px question-card block so the card tightens
           up on phones in exactly the same way. */
        @media (max-width: 520px) {
            .question-card { padding: 1.1rem 0.95rem; }
            .question-card-header { gap: 0.5rem; }
            .question-number { font-size: 0.98rem; }
            .question-card-top-actions { gap: 0.35rem; }
            .type-badge { font-size: 0.68rem; padding: 0.22rem 0.55rem; }
            .mcq-option { padding: 0.8rem 0.75rem; gap: 0.65rem; font-size: 0.88rem; }
            .mcq-letter { width: 25px; height: 25px; font-size: 0.72rem; }
            /* Phone browser chrome eats proportionally more of the viewport, so
               the image gets a tighter cap here than on desktop/tablet. */
            .question-image { max-height: 30vh; }
        }

        /* MathJax & KaTeX styling for dark/light themes and horizontal overflow */
        .katex, mjx-container { color: var(--text-primary); max-width: 100%; outline: none; }
        .katex-display, mjx-container[jax="CHTML"][display="true"] {
            overflow-x: auto !important;
            overflow-y: hidden !important;
            max-width: 100% !important;
            margin: 0.55em 0 !important;
            padding: 0.25rem 0 !important;
            -webkit-overflow-scrolling: touch;
        }
        .question-text .katex-html,
        .mcq-text .katex-html,
        .explanation-text .katex-html,
        .question-text mjx-container,
        .mcq-text mjx-container,
        .explanation-text mjx-container {
            max-width: 100%;
        }
    
        /* ===== TEST MODE CARD - ATTRACTIVE RECTANGLE ===== */
        .mode-card.test-mode-card {
            grid-column: 1 / -1;
            display: flex;
            align-items: center;
            text-align: left;
            gap: 1.5rem;
            padding: 1.5rem 2rem;
            background: linear-gradient(135deg, rgba(0,212,170,0.05), var(--bg-card));
            border: 2px solid var(--border);
        }
        .mode-card.test-mode-card:hover {
            border-color: var(--accent);
            box-shadow: var(--shadow-glow), 0 12px 40px rgba(0,0,0,0.2);
        }
        .mode-card.test-mode-card .mode-icon {
            font-size: 3rem;
            margin-bottom: 0;
            flex-shrink: 0;
        }
        .mode-card.test-mode-card .mode-content {
            flex: 1;
        }
        .mode-card.test-mode-card .mode-name {
            font-size: 1.2rem;
            margin-bottom: 0.3rem;
        }
        .mode-card.test-mode-card .mode-desc {
            font-size: 0.85rem;
            max-width: 400px;
        }
        .mode-card.test-mode-card .mode-badge {
            margin-top: 0.5rem;
        }
        @media (max-width: 600px) {
            .mode-card.test-mode-card {
                flex-direction: column;
                text-align: center;
                gap: 1rem;
            }
            .mode-card.test-mode-card .mode-icon {
                margin-bottom: 0.5rem;
            }
        }

        /* Grid number states (bookmarked/correct/wrong/reviewed) live in quiz-core.css
           alongside the rest of the grid panel styling. */



        /* ===== REVIEW BUTTON ===== */
        .review-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            padding: 0.3rem 0.6rem;
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-muted);
            font-size: 0.75rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-left: 0.5rem;
        }
        .review-btn:hover {
            border-color: var(--warning);
            color: var(--warning);
        }
        .review-btn.active {
            border-color: var(--warning);
            color: var(--warning);
            background: rgba(243, 156, 18, 0.08);
        }

        /* ===== SELECT ALL BUTTON ===== */
        .select-all-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.5rem 1rem;
            background: var(--bg-card);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-bottom: 1rem;
        }
        .select-all-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
            background: rgba(0, 212, 170, 0.08);
        }

        /* ===== BOOKMARK PANEL ===== */
        .bookmark-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.6);
            backdrop-filter: blur(8px);
            z-index: 1050;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .bookmark-overlay.active {
            display: block;
            opacity: 1;
        }
        .bookmark-panel {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.9);
            width: 90%;
            max-width: 500px;
            max-height: 80vh;
            background: var(--bg-primary);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-lg);
            z-index: 1051;
            display: none;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.4);
            opacity: 0;
            transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .bookmark-panel.active {
            display: flex;
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
        .bookmark-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 1.25rem;
            border-bottom: 1px solid var(--border);
            background: var(--bg-card);
        }
        .bookmark-panel-header h3 {
            font-size: 1rem;
            font-weight: 700;
            color: var(--text-primary);
        }
        .bookmark-panel-header .bookmark-close {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-primary);
            border: 1.5px solid var(--border);
            border-radius: 8px;
            color: var(--text-muted);
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .bookmark-panel-header .bookmark-close:hover {
            border-color: var(--error);
            color: var(--error);
            transform: rotate(90deg);
        }
        .bookmark-panel-body {
            padding: 1.25rem;
            overflow-y: auto;
            flex: 1;
        }
        .bookmark-section {
            margin-bottom: 1rem;
        }
        .bookmark-section-title {
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--accent);
            padding: 0.5rem 0.75rem;
            background: var(--bg-card);
            border-radius: var(--radius-sm);
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: all 0.2s ease;
        }
        .bookmark-section-title:hover {
            background: var(--bg-hover);
        }
        .bookmark-section-title .arrow {
            transition: transform 0.2s ease;
        }
        .bookmark-section-title.expanded .arrow {
            transform: rotate(90deg);
        }
        .bookmark-subsections {
            display: none;
            padding-left: 1rem;
            margin-top: 0.5rem;
        }
        .bookmark-subsections.show {
            display: block;
        }
        .bookmark-subsection {
            padding: 0.4rem 0.75rem;
            font-size: 0.85rem;
            color: var(--text-secondary);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: all 0.2s ease;
            margin-bottom: 0.25rem;
        }
        .bookmark-subsection:hover {
            background: var(--bg-hover);
            color: var(--accent);
        }
        .bookmark-subsection.selected {
            background: rgba(0, 212, 170, 0.08);
            color: var(--accent);
            font-weight: 600;
        }
        .bookmark-actions {
            display: flex;
            gap: 0.5rem;
            padding: 1rem 1.25rem;
            border-top: 1px solid var(--border);
            background: var(--bg-card);
        }
        .bookmark-actions .btn {
            flex: 1;
            font-size: 0.85rem;
            padding: 0.6rem 1rem;
        }
        .bookmark-input {
            width: 100%;
            padding: 0.75rem 1rem;
            background: var(--bg-primary);
            border: 1.5px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.9rem;
            margin-bottom: 0.75rem;
            outline: none;
        }
        .bookmark-input:focus {
            border-color: var(--accent);
        }
        .bookmark-empty {
            text-align: center;
            padding: 2rem;
            color: var(--text-muted);
            font-size: 0.9rem;
        }
        .bookmark-folder-actions {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }
        .bookmark-folder-actions .btn {
            font-size: 0.8rem;
            padding: 0.4rem 0.75rem;
        }

/* ===== IMAGE MCQ STYLES ===== */
.image-question-wrap {
    width: 100%;
    margin-bottom: 1.1rem;
    text-align: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.4rem 0;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.question-image {
    max-width: 100%;
    /* 75vh let one image claim almost the whole screen, pushing the options
       off-screen. Capped lower so the question text and at least the first
       couple of options stay visible without scrolling; a genuinely tall
       image still scrolls with the rest of the card. */
    max-height: 42vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
    border-radius: var(--radius-sm);
}
/* Image questions now use the same .mcq-option rows as every other MCQ, so the
   old 4-box `.image-mcq-*` grid is gone. */
.image-offline-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* ===== BREADCRUMB NAVIGATION ===== */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.breadcrumb-back {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}
.breadcrumb-back:hover {
    background: var(--bg-hover);
}
.breadcrumb-path {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    overflow-x: auto;
}
.breadcrumb-item {
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.breadcrumb-item:hover {
    color: var(--accent);
}
.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}
.breadcrumb-sep {
    color: var(--text-muted);
}

/* ===== DOWNLOAD & OFFLINE INDICATORS ===== */
.download-file-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}
.download-file-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.download-file-btn.downloaded {
    border-color: #10b981;
    color: #10b981;
}

.offline-indicator {
    display: none;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    z-index: 9999;
}
.offline-indicator.show {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ===== CUSTOM TEST BUILDER UI ===== */
/* ===== CUSTOM TEST BUILDER UI (Matching Question Cafe Aesthetic) ===== */
.ct-builder {
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 5rem;
}
.ct-controls-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.ct-cat-tabs, .ct-subj-tabs {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.ct-tab-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 25px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ct-tab-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-2px);
}
.ct-tab-pill.active {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow-strong);
}
.ct-search-input {
    width: 100%;
    padding: 0.75rem 1.25rem 0.75rem 2.6rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s ease;
}
.ct-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--accent-glow);
}
.ct-chapters-grid {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.ct-chapter-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s ease;
}
.ct-chapter-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}
.ct-chapter-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background: var(--bg-card);
    user-select: none;
}
.ct-chapter-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 1;
}
.ct-chap-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}
.ct-chap-meta-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}
.ct-chap-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.ct-topics-list {
    display: none;
    padding: 0.5rem 1.25rem 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.ct-topics-list.open {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ct-topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}
.ct-topic-row.selected {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.06);
}
.ct-topic-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}
.ct-topic-count-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ct-count-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.ct-count-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.ct-topic-count-wrap input {
    width: 48px;
    text-align: center;
    padding: 0.25rem 0.35rem;
    font-size: 0.88rem;
    font-weight: 700;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

/* Floating Sticky Action Bar */
.ct-floating-bar {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(900px, 94vw);
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 20px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 100;
    backdrop-filter: blur(16px);
}
.ct-float-info {
    display: flex;
    flex-direction: column;
}
.ct-float-count {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
}
.ct-float-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.ct-float-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
@media (max-width: 600px) {
    .ct-floating-bar {
        width: 96vw;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
        bottom: 0.75rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .ct-float-info {
        flex: 1 1 100%;
        text-align: center;
    }
    .ct-float-actions {
        width: 100%;
        justify-content: center;
    }
    .ct-float-actions .btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }
}

/* Custom Test Selected Drawer & Modal */
.ct-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ct-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.ct-selected-drawer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    width: min(760px, 96vw);
    max-height: 82vh;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5), 0 0 25px var(--accent-glow);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}
.ct-selected-drawer.open {
    transform: translate(-50%, 0);
}

.ct-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
}
.ct-drawer-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}
.ct-drawer-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.ct-drawer-body {
    padding: 1rem 1.4rem;
    overflow-y: auto;
    flex: 1;
}

.ct-selected-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.ct-selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}
.ct-selected-item:hover {
    border-color: var(--accent);
}
.ct-selected-item-info {
    flex: 1;
    min-width: 0;
}
.ct-selected-item-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ct-selected-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.ct-selected-item-ctrls {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.ct-selected-item-ctrls input {
    width: 48px;
    text-align: center;
    padding: 0.25rem 0.35rem;
    font-size: 0.88rem;
    font-weight: 700;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}
.ct-remove-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.ct-remove-btn:hover {
    border-color: var(--error, #ef4444);
    color: var(--error, #ef4444);
    background: rgba(239, 68, 68, 0.1);
}

.ct-drawer-foot {
    padding: 1.1rem 1.4rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

/* ===== ENHANCED BOOKMARK BUTTON & THIN CARDS ===== */
.bookmark-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.25s ease;
    color: var(--text-muted);
}
.bookmark-btn:hover {
    border-color: var(--accent);
    transform: scale(1.08);
    box-shadow: 0 0 10px var(--accent-glow);
}
.bookmark-btn.active {
    background: rgba(0, 212, 170, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Bilingual Language Toggle Button */
.lang-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    height: 34px;
    padding: 0 0.65rem;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.25s ease;
    color: var(--text-secondary);
    letter-spacing: 0.4px;
}
.lang-toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 0 10px var(--accent-glow);
}
.lang-toggle-btn.active {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--st-purple, #a855f7);
    color: var(--st-purple, #a855f7);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

/* Horizontal Thin Bookmark Card */
.bookmark-thin-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
    transition: all 0.2s ease;
}
.bookmark-thin-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateX(3px);
}
.bookmark-thin-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}
.bookmark-thin-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.bookmark-thin-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ================================================================
   MOBILE RESPONSIVE — Quiz Components
   Fixes SS1 (vertical block title), SS2 (breadcrumb overflow),
   SS3 (integer input + check button overflow), and general
   phone-layout polish.
   ================================================================ */

/* --- 600px and below --- */
@media (max-width: 600px) {

    /* ---- Breadcrumb bar (SS2): truncate the URL path text ---------- */
    .breadcrumb-bar {
        gap: 0.5rem;
        padding: 0.55rem 0.75rem;
        flex-wrap: nowrap;
    }
    .breadcrumb-back {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .breadcrumb-path {
        /* Allow it to shrink and clip the long jee-chapterwise/... string */
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        display: block;        /* Override flex so ellipsis works */
        font-size: 0.78rem;
        color: var(--accent);
    }
    .breadcrumb-item, .breadcrumb-sep { display: inline; }

    /* ---- Integer input + Check button (SS3) ----------------------- */
    /* Stack the input on top and make the button full-width on very
       narrow phones so neither element is clipped */
    .int-input-wrap {
        flex-direction: column;
        gap: 0.6rem;
    }
    .int-input {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
    }
    .int-check-btn {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }

    /* ---- Question card header ------------------------------------- */
    .question-card-header {
        gap: 0.4rem;
    }
    .question-card-top-actions {
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    /* ---- MCQ options ---------------------------------------------- */
    .mcq-option {
        padding: 0.75rem 0.85rem;
        gap: 0.6rem;
        font-size: 0.88rem;
    }

    /* ---- Nav buttons (Prev / Next) --------------------------------- */
    .nav-btn {
        padding: 0.65rem 1rem;
        font-size: 0.83rem;
        gap: 0.35rem;
    }

    /* ---- Question tags (topic / exam) ------------------------------ */
    .question-topic-tag,
    .question-exam-tag {
        font-size: 0.68rem;
        padding: 0.2rem 0.55rem;
    }

    /* ---- Explanation box ------------------------------------------ */
    .explanation-box, .q-explain {
        padding: 0.85rem 0.9rem;
    }
    .explanation-box p, .explanation-text,
    .q-explain p, .q-explain-text {
        font-size: 0.84rem;
    }

    /* ---- Bookmark panel ------------------------------------------- */
    .bookmark-panel {
        width: 96%;
        max-height: 88vh;
    }

    /* ---- Custom-test builder drawer on phone ----------------------- */
    .ct-builder { padding-bottom: 7rem; }
}

/* --- 480px and below (very small phones) --- */
@media (max-width: 480px) {

    /* Integer input stacked layout (already column above, tighten padding) */
    .int-input { padding: 0.75rem 0.85rem; }
    .int-check-btn { padding: 0.75rem 0.85rem; font-size: 0.88rem; }

    /* Question card */
    .question-card { padding: 0.9rem 0.75rem; }
    .question-card-header { gap: 0.35rem; padding-bottom: 0.5rem; margin-bottom: 0.55rem; }
    .question-number { font-size: 0.92rem; }
    .question-topic-tag { max-width: 125px; }

    /* MCQ letter bubble */
    .mcq-letter { width: 24px; height: 24px; font-size: 0.7rem; }

    /* Question text */
    .question-text { font-size: 0.94rem; line-height: 1.65; }

    /* Breadcrumb — even shorter */
    .breadcrumb-path { font-size: 0.72rem; }

    /* Review */
    .review-filter-btn { padding: 0.4rem 0.75rem; font-size: 0.75rem; }

    /* Image cap on tiny screens */
    .question-image { max-height: 28vh; }

    /* KaTeX math display horizontal scroll */
    .katex-display { overflow-x: auto; padding-bottom: 0.25rem; }
}

/* ==================== SOLUTION VIDEO CARD (CLEAN & MODERN) ==================== */
.solution-video-card {
    margin-top: 1rem;
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card, #1c1e27);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.solution-video-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.solution-video-facade {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    max-height: 360px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.solution-video-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #0b0c10;
    transition: transform 0.3s ease, filter 0.3s ease;
}
.solution-video-facade:hover .solution-video-thumb {
    transform: scale(1.02);
    filter: brightness(0.92);
}
.solution-video-play-btn {
    position: absolute;
    width: 62px;
    height: 62px;
    background: rgba(229, 62, 62, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.15);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 2;
    pointer-events: none;
}
.solution-video-facade:hover .solution-video-play-btn {
    transform: scale(1.15);
    background: #e53e3e;
    box-shadow: 0 10px 28px rgba(229, 62, 62, 0.5), 0 0 0 6px rgba(255, 255, 255, 0.25);
}
.solution-video-time-tag {
    position: absolute;
    bottom: 10px;
    right: 12px;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.3px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.solution-video-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-card, #1c1e27);
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
}
.solution-video-card:hover .solution-video-bar {
    background: rgba(255, 255, 255, 0.03);
}
.solution-video-bar-left {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.solution-video-bar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(229, 62, 62, 0.18);
    color: #e53e3e;
    font-size: 0.75rem;
    font-weight: bold;
}
.solution-video-bar-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    letter-spacing: 0.2px;
}
.solution-video-bar-hint {
    font-size: 0.78rem;
    color: var(--text-muted, #888);
}
.solution-video-iframe-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background: #000000;
}
.solution-video-iframe-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

