/* ========================================================================
   TOPIC BROWSER - Main Navigation & Layout

   NOTE: Component styles have been split out for maintainability:
   - syllabus-card.css: Syllabus selection cards
   - concept-card.css: Question browser cards, question items
   - power-meter.css: Progress rings, meters, star ratings
   - practice-cart.css: Floating practice cart
   ======================================================================== */

/* ========================================================================
   TOPIC ACCORDION
   ======================================================================== */

.topic-accordion {
    border-radius: 12px;
    overflow: hidden;
}

.topic-accordion .accordion-item {
    border: 1px solid var(--tb-border) !important;
    margin-bottom: 0.55rem !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: none !important;
    background: var(--tb-card);
}

.topic-accordion .accordion-button {
    padding: 0.7rem 1rem !important;
    background: var(--tb-card) !important;
    font-weight: 500;
    border-radius: 10px !important;
    color: var(--tb-text) !important;
}

.topic-accordion .accordion-button:not(.collapsed) {
    background: white;
    box-shadow: none;
}

.topic-accordion .accordion-button:focus {
    box-shadow: none;
    border-color: transparent;
}

.topic-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding-right: 1rem;
}

.topic-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    color: var(--tb-accent) !important;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: var(--tb-accent-soft) !important;
    box-shadow: none !important;
}

.topic-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topic-number {
    font-size: 0.72rem !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tb-text-subtle) !important;
    font-weight: 600;
}

.topic-name {
    font-size: 0.96rem !important;
    font-weight: 600 !important;
    color: var(--tb-text) !important;
}

.topic-count {
    background: var(--tb-bg) !important;
    color: var(--tb-text-muted) !important;
    font-size: 0.78rem !important;
    padding: 0.18rem 0.55rem !important;
    border-radius: 12px !important;
    border: 1px solid var(--tb-border);
    font-variant-numeric: tabular-nums;
}

/* ========================================================================
   SUBTOPIC GRID
   ======================================================================== */

.subtopic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.subtopic-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem !important;
    background: var(--tb-bg) !important;
    border-radius: 8px !important;
    text-decoration: none;
    color: var(--color-text);
    transition: all 0.2s ease;
    border: 1px solid var(--tb-border-soft) !important;
}

.subtopic-item:hover {
    background: var(--tb-accent-soft) !important;
    border-color: var(--jmaths-light-blue) !important;
    color: var(--topic-color, var(--color-primary));
    text-decoration: none;
    transform: translateX(4px);
}

.subtopic-code {
    font-weight: 600;
    font-size: 0.76rem !important;
    color: var(--tb-text-muted) !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
}

.subtopic-count {
    font-size: 0.8rem;
    color: var(--tb-text-subtle) !important;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.subtopic-arrow {
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.subtopic-item:hover .subtopic-arrow {
    opacity: 1;
}

/* ========================================================================
   MATH CONTENT - Prevent inline math from breaking across lines
   ======================================================================== */

.latex-content,
.math-inline,
mjx-container,
.katex,
.MathJax {
    white-space: nowrap;
    display: inline-block;
}

.katex-display,
.MathJax_Display {
    white-space: normal;
    display: block;
}

@media print {
    .latex-content,
    .math-inline,
    mjx-container,
    .katex {
        white-space: nowrap;
        display: inline-block;
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ========================================================================
   UNIFIED COMPACT HEADER
   ======================================================================== */

.unified-header {
    background: var(--tb-card) !important;
    border-radius: 10px !important;
    padding: 0.85rem 1.1rem !important;
    margin-bottom: 1rem;
    color: var(--tb-text) !important;
    border: 1px solid var(--tb-border) !important;
    box-shadow: none !important;
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.header-welcome {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-welcome h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem !important;
    opacity: 1 !important;
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    border-radius: 8px;
    padding: 0.4rem 0.7rem !important;
    color: var(--tb-text-muted) !important;
}

.header-stat .value {
    font-weight: 600;
    color: var(--tb-text);
    font-variant-numeric: tabular-nums;
}

.header-stat.streak {
    color: #b45309 !important;
    background: #fffbeb;
    border-color: #fde68a;
}
.header-stat.due {
    color: #b91c1c !important;
    background: #fef2f2;
    border-color: #fecaca;
}

.header-stat.clickable {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.header-stat.clickable:hover {
    background: var(--tb-accent-soft) !important;
    border-color: var(--jmaths-light-blue) !important;
    color: var(--tb-text) !important;
}

/* ========================================================================
   SEARCH & FILTERS
   ======================================================================== */

.search-container {
    flex: 1;
    max-width: 320px;
    min-width: 180px;
    position: relative;
}

.search-container input {
    width: 100%;
    padding: 0.6rem 0.85rem 0.6rem 2.5rem;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.95);
    font-size: 0.95rem;
}

.search-container input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.search-container .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--jmaths-gray-500);
}

.course-selector {
    background: white;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    color: var(--color-primary-hover);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.course-selector:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.course-selector:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.course-selector option {
    color: var(--color-text);
    background: white;
}

.course-selector-floating {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: var(--tb-card) !important;
    border: 1px solid var(--tb-border) !important;
    border-radius: 8px !important;
    padding: 0.32rem 0.6rem !important;
    color: var(--tb-text) !important;
    font-size: 0.86rem !important;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-align-last: center;
    min-width: 70px;
}

.course-selector-floating:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.3);
}

.course-selector-floating:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.3);
}

.course-selector-floating option {
    color: var(--color-text);
    background: white;
    text-align: left;
}

.filter-divider {
    width: 1px;
    height: 20px;
    background: rgba(0,0,0,0.15);
    margin: 0 0.25rem;
}

/* ========================================================================
   SEARCH RESULTS
   ======================================================================== */

.search-results-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--gradient-primary);
    color: white;
}

.search-results-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.search-results-content {
    padding: 0;
}

.search-results-content .search-result-item {
    padding: 1rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid var(--jmaths-gray-100);
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.search-results-content .search-result-item:hover {
    background: var(--jmaths-gray-50);
}

.search-results-content .search-result-item:last-child {
    border-bottom: none;
}

.search-results-content .result-main {
    flex: 1;
    min-width: 0;
}

.search-results-content .result-title {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-results-content .result-id {
    color: var(--jmaths-gray-500);
    font-weight: normal;
    font-size: 0.8rem;
    background: var(--jmaths-gray-100);
    padding: 2px 6px;
    border-radius: 4px;
}

.search-results-content .result-syllabus {
    font-weight: normal;
    font-size: 0.75rem;
    background: var(--color-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
}

.search-results-content .result-code {
    font-size: 0.8rem;
    color: var(--color-primary);
    margin-top: 4px;
    font-weight: 500;
}

.search-results-content .result-preview {
    font-size: 0.85rem;
    color: var(--jmaths-gray-600);
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-results-content .result-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.search-results-content .result-marks {
    font-size: 0.85rem;
    color: var(--color-success);
    font-weight: 600;
}

.search-results-content .result-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    background: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.search-results-content .result-btn:hover {
    background: var(--color-primary-hover);
}

.search-results-content .no-results,
.search-results-content .searching {
    padding: 2rem;
    text-align: center;
    color: var(--jmaths-gray-500);
}

.search-results-content .results-count {
    padding: 0.75rem 1.25rem;
    background: var(--jmaths-gray-50);
    font-size: 0.85rem;
    color: var(--jmaths-gray-500);
    border-bottom: 1px solid var(--jmaths-gray-100);
}

/* ========================================================================
   ACTION BUTTONS (Header)
   ======================================================================== */

.header-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.action-buttons select {
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    cursor: pointer;
    height: 32px;
}

.action-buttons .btn {
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-practice-primary {
    background: white;
    color: var(--color-primary-hover);
    border: none;
    font-weight: 600;
    padding: 0 1.5rem;
    height: 44px;
    font-size: 1rem;
    min-width: 140px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-practice-primary:hover {
    background: var(--jmaths-cream);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-practice-primary i {
    font-size: 1.1rem;
}

.btn-pick {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0 1.25rem;
    height: 44px;
    font-size: 0.95rem;
}

.btn-pick:hover {
    background: rgba(255,255,255,0.25);
}

.btn-pick.active {
    background: #fbbf24;
    color: #78350f;
    border-color: #fbbf24;
}

.btn-pick i {
    font-size: 1rem;
}

.btn-more {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1rem;
}

.btn-more:hover {
    background: rgba(255,255,255,0.25);
}

/* ========================================================================
   MORE MENU
   ======================================================================== */

.more-menu-container {
    position: relative;
}

.more-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: var(--z-index-dropdown);
    overflow: hidden;
}

.more-menu.show {
    display: block;
    animation: fadeIn 0.15s ease;
}

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

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: var(--jmaths-gray-700);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.more-menu-item:hover {
    background: var(--jmaths-gray-100);
}

.more-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--jmaths-gray-500);
}

.more-menu-item.review-due {
    color: var(--color-danger-hover);
    border-top: 1px solid var(--jmaths-gray-200);
}

.more-menu-item.review-due i {
    color: var(--color-danger-hover);
}

.menu-item-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.menu-item-helper {
    font-size: 0.7rem;
    color: var(--jmaths-gray-400);
    margin-top: 2px;
}

.more-menu-item.review-due .menu-item-helper {
    color: #f87171;
}

/* ========================================================================
   HEATMAP MODAL
   ======================================================================== */

.heatmap-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-index-modal);
    align-items: center;
    justify-content: center;
}

.heatmap-modal.show {
    display: flex;
}

.heatmap-container {
    background: var(--tb-card) !important;
    border-radius: 12px !important;
    padding: 1.5rem 2rem;
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08) !important;
    border: 1px solid var(--tb-border) !important;
}

.heatmap-view-options {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.heatmap-view-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--jmaths-gray-200);
    background: white;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.heatmap-view-btn:hover {
    background: var(--jmaths-gray-100);
}

.heatmap-view-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.heatmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--tb-border-soft) !important;
    background: var(--tb-bg) !important;
    color: var(--tb-text) !important;
}

.heatmap-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.heatmap-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--jmaths-gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.heatmap-close:hover {
    color: var(--jmaths-gray-700);
}

.heatmap-legend {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.heatmap-topic {
    margin-bottom: 0.75rem;
}

.heatmap-topic-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--jmaths-gray-500);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.heatmap-cells {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.heatmap-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
}

.heatmap-cell:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.heatmap-cell.level-0 { background: var(--color-bg-muted); color: var(--color-text-light); }
.heatmap-cell.level-1 { background: #fecaca; color: #991b1b; }
.heatmap-cell.level-2 { background: #fed7aa; color: #9a3412; }
.heatmap-cell.level-3 { background: #fef08a; color: #854d0e; }
.heatmap-cell.level-4 { background: #bbf7d0; color: #166534; }
.heatmap-cell.level-5 { background: var(--jmaths-light-blue); color: var(--color-primary-hover); }

.heatmap-loading {
    text-align: center;
    padding: 2rem;
    color: var(--jmaths-gray-500);
}

/* ========================================================================
   TOPIC SECTION
   ======================================================================== */

.topic-section {
    margin-bottom: 2rem;
    scroll-margin-top: 140px;
}

.topic-section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--jmaths-gray-200);
}

.topic-title {
    flex: 1;
}

.topic-title h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.topic-title small {
    color: var(--color-text-muted);
}

/* ========================================================================
   QUESTION PREVIEW MODAL
   ======================================================================== */

.question-preview-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* ========================================================================
   IB EXAM PAPER STYLING
   ======================================================================== */

.ib-exam-paper {
    font-family: var(--font-question);
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
    padding: 1.5rem;
}

.ib-exam-paper .question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--jmaths-gray-300);
}

.ib-exam-paper .question-number {
    font-weight: 700;
    font-size: 14pt;
}

.ib-exam-paper .question-marks {
    font-weight: 600;
    color: var(--jmaths-gray-600);
}

.ib-exam-paper .question-context {
    margin-bottom: 1.25rem;
    text-align: justify;
}

.ib-exam-paper .question-stem {
    margin-bottom: 1.5rem;
}

.ib-exam-paper .part-row {
    display: flex;
    margin: 0.75rem 0;
    page-break-inside: avoid;
}

.ib-exam-paper .part-label {
    min-width: 1.6rem;   /* hug the label ("a)") — was a fixed 50px column */
    margin-right: 0;     /* spacing comes from the row gap only, not gap + margin */
    font-weight: 600;
    flex-shrink: 0;
}

.ib-exam-paper .part-content {
    flex: 1;
    padding-right: 3rem;
}

.ib-exam-paper .part-marks {
    min-width: 40px;
    text-align: center;   /* centre "[4]" within the pill */
    color: var(--jmaths-gray-600);
    font-weight: 500;
}

.ib-exam-paper .sub-part {
    margin-left: 2rem;
}

.ib-exam-paper .answer-space {
    min-height: 60px;
    border-bottom: 1px dotted #ccc;
    margin: 1rem 0;
}

/* Question modal action bar — keep button labels on one line; let the whole
   bar wrap as units (the rate group drops to its own right-aligned row)
   instead of squeezing each label onto two/three lines. */
.qb-actionbar .btn,
.qb-actionbar .small {
    white-space: nowrap;
}
.qb-actionbar > .d-flex {
    flex-wrap: wrap;
    row-gap: 0.5rem;
}

/* Give the question-modal footer action row more visual weight. */
.question-modal-actions {
    border-top: 2px solid var(--bs-border-color);
    padding-top: 0.75rem;
}
.question-modal-actions .btn {
    font-weight: 600;
}
.question-modal-actions .btn-outline-primary,
.question-modal-actions .btn-outline-success,
.question-modal-actions .btn-outline-info {
    border-width: 2px;
}
.question-modal-actions .reveal-cta {
    font-weight: 700;
}

/* ========================================================================
   PDF EXPORT
   ======================================================================== */

.pdf-export-options {
    background: var(--jmaths-gray-50);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.pdf-export-options label {
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-download-pdf {
    background: var(--color-danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-download-pdf:hover {
    background: var(--color-danger-hover);
    color: white;
    transform: translateY(-1px);
}

.btn-download-pdf:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========================================================================
   VARIANTS LIST
   ======================================================================== */

.variants-list {
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid #e0e7ff;
}

.variant-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.variant-item:hover {
    background: #f0f4ff;
    color: #4338ca;
}

/* ========================================================================
   CONFIDENCE STARS
   ======================================================================== */

.confidence-stars {
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.question-meta .badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.2rem 0.4rem;
}

/* ========================================================================
   WELCOME & BANNERS
   ======================================================================== */

.welcome-placeholder {
    background: var(--tb-card) !important;
    border: 1px dashed var(--tb-border) !important;
    border-radius: 10px !important;
    padding: 2rem 1.25rem !important;
    text-align: center;
    margin-bottom: 1rem;
    box-shadow: none !important;
    color: var(--tb-text-muted) !important;
}

.welcome-placeholder h4 {
    color: var(--color-primary-hover);
    margin-bottom: 0.5rem;
}

.welcome-placeholder p {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.welcome-placeholder .btn {
    background: var(--color-primary);
    color: white;
    border: none;
}

.review-alert {
    background: rgba(254, 243, 199, 0.95);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: #92400e;
    font-size: 0.85rem;
}

.review-alert .btn {
    background: var(--color-warning);
    color: white;
    border: none;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.anon-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-info) 100%);
}

.anon-header .header-cta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.signup-banner {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-info) 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.3);
}

.signup-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.signup-banner-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.signup-banner-icon i {
    font-size: 1.5rem;
    color: white;
}

.signup-banner-text {
    flex: 1;
    color: white;
}

.signup-banner-text h5 {
    font-weight: 600;
    color: white;
}

.signup-banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.signup-banner-actions .btn-light {
    background: white;
    color: var(--color-primary);
    font-weight: 600;
    border: none;
}

.signup-banner-actions .btn-light:hover {
    background: #f0f0f0;
}

.signup-banner-actions .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

.signup-banner-actions .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

/* ========================================================================
   MOBILE RESPONSIVE - Topic Accordion & Header
   ======================================================================== */

@media (max-width: 992px) {
    .topic-browser-container .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .subtopic-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .topic-browser-container {
        padding-bottom: 80px;
    }

    .topic-browser-container .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .breadcrumb {
        font-size: 0.85rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    /* Topic accordion - touch friendly */
    .topic-accordion .accordion-item {
        margin-bottom: 0.5rem;
        border-radius: 8px !important;
    }

    .topic-accordion .accordion-button {
        padding: 0.75rem 1rem;
        min-height: 64px;
    }

    .topic-header-content {
        flex-wrap: nowrap;
        gap: 0.75rem;
    }

    .topic-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .topic-number {
        font-size: 0.65rem;
    }

    .topic-name {
        font-size: 0.95rem;
    }

    .topic-count {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }

    /* Subtopic grid - single column on mobile */
    .subtopic-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .subtopic-item {
        padding: 0.875rem 1rem;
        min-height: 48px;
        border-radius: 6px;
    }

    .subtopic-code {
        font-size: 0.9rem;
    }

    .subtopic-count {
        font-size: 0.75rem;
    }

    .subtopic-arrow {
        opacity: 1;
    }

    /* Header responsive */
    .header-top-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-stats {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        max-width: 100%;
    }

    .action-buttons {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn-practice-primary {
        height: 40px;
        padding: 0 1rem;
        font-size: 0.9rem;
        min-width: 120px;
    }

    .btn-pick {
        height: 40px;
        padding: 0 1rem;
        font-size: 0.85rem;
    }

    .btn-more {
        width: 40px;
        height: 40px;
    }

    .signup-banner-content {
        flex-direction: column;
        text-align: center;
    }

    .signup-banner-actions {
        width: 100%;
        flex-direction: column;
    }

    .signup-banner-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .topic-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .topic-name {
        font-size: 0.85rem;
    }

    .btn-practice-primary {
        height: 38px;
        padding: 0 0.75rem;
        min-width: auto;
    }

    .btn-practice-primary .btn-text {
        display: none;
    }

    .btn-pick {
        height: 38px;
        padding: 0 0.75rem;
    }

    .btn-pick .btn-text {
        display: none;
    }

    .btn-more {
        width: 38px;
        height: 38px;
    }
}

/* Landscape mobile - use 2 columns */
@media (max-width: 768px) and (orientation: landscape) {
    .subtopic-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .subtopic-item:hover {
        transform: none;
    }

    .subtopic-item:active {
        background: white;
        border-color: var(--topic-color, var(--color-primary));
    }
}

@media print {
    .ib-exam-paper {
        padding: 0;
        font-size: 11pt;
    }
    .no-print {
        display: none !important;
    }
}

/* Presentation mode — used when projecting to a class screen. zoom scales
   the entire subtree including rem-based children, which a font-size bump
   alone can't do. */
body.presentation-mode .topic-browser-container {
    zoom: 1.35;
}

.header-stat.presentation-toggle {
    cursor: pointer;
}
body.presentation-mode .header-stat.presentation-toggle {
    background: var(--accent, var(--color-primary));
    color: #fff;
}
body.presentation-mode .header-stat.presentation-toggle .value,
body.presentation-mode .header-stat.presentation-toggle i {
    color: #fff;
}

/* ========================================================================
   Styles migrated from topic-browser-refresh.css (v1/v2 split removed)
   ======================================================================== */
/* ========================================================================
   TOPIC BROWSER — visual refresh overlay (2026-05-16)

   Loaded AFTER static/css/components/topic-browser.css so it can override
   the existing visuals to match the calmer design of /exams/mastery/.

   Principles (same as my_mastery.html):
   - Soft 1px neutral borders instead of heavy shadows
   - Generous whitespace, rounded but not pillowy (10px radius)
   - Calm pastel palette for status colours
   - White cards on a near-white page
   - Muted-uppercase section headers
   - Tabular-nums for counts

   Does not touch JS behaviour, accordions, or layout structure — pure
   visual layer. Revert by removing this <link> from the template.
   ======================================================================== */

:root {
    --tb-bg: #fafbfc;
    --tb-card: #ffffff;
    --tb-border: #e8ecef;
    --tb-border-soft: #eef1f4;
    --tb-text: #2c3338;
    --tb-text-muted: #6a7280;
    --tb-text-subtle: #9aa1a9;
    --tb-accent: var(--color-primary);
    --tb-accent-soft: var(--jmaths-cream);
}

.topic-browser-container {
    background: var(--tb-bg);
    min-height: 100vh;
    padding-top: 0.5rem;
}

/* === Course heading — single source of truth for the page title ========== */
.course-heading {
    margin-bottom: 1rem;
}

.course-heading h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--tb-text);
    margin: 0 0 0.15rem;
    letter-spacing: -0.01em;
}

.course-heading-sub {
    margin: 0;
    color: var(--tb-text-muted);
    font-size: 0.92rem;
}

.course-heading-count {
    color: var(--tb-text-subtle);
    font-variant-numeric: tabular-nums;
    margin-left: 0.3em;
}

.course-heading-breadcrumb {
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.course-heading-breadcrumb a {
    color: var(--tb-text-muted);
    text-decoration: none;
}

.course-heading-breadcrumb a:hover {
    color: var(--tb-accent);
}

/* === Unit picker — dropdown (replaces the earlier chip row) ============== */
.unit-picker-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    padding: 0.55rem 0.85rem;
    background: var(--tb-card);
    border: 1px solid var(--tb-border);
    border-radius: 10px;
}

.unit-picker-label {
    font-size: 0.78rem;
    color: var(--tb-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
    white-space: nowrap;
}

.unit-picker-select {
    flex: 1;
    max-width: 420px;
}

/* Unit title becomes a clickable link on the overview page */
.unit-title-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s, color 0.15s;
}

.unit-title-link:hover {
    color: var(--tb-accent);
    border-bottom-color: var(--tb-accent);
}

/* === Footer prev/next nav =============================================== */
.unit-footer-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-top: 2rem;
}

.unit-nav-link {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    border: 1px solid var(--tb-border);
    border-radius: 10px;
    background: var(--tb-card);
    color: var(--tb-text);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    min-height: 70px;
}

.unit-nav-link:hover {
    border-color: var(--tb-accent);
    background: var(--tb-accent-soft);
    color: var(--tb-text);
}

.unit-nav-link.is-empty {
    border-style: dashed;
    background: var(--tb-bg);
    pointer-events: none;
}

.unit-nav-next { text-align: right; }

.unit-nav-label {
    color: var(--tb-text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.unit-nav-title {
    color: var(--tb-text);
    font-weight: 600;
    font-size: 0.92rem;
}

/* === Unified header — calm white card with stat tiles ===================== */

.unified-header .header-welcome h5 {
    color: var(--tb-text) !important;
}



/* Subtle accent colour for the meaningful stats — no longer relies on
   contrast against a teal gradient background. */

.header-stat.streak .value { color: #92400e; }


.header-stat.due .value { color: #991b1b; }


/* === Search container ==================================================== */
.unified-header .search-container input {
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    color: var(--tb-text);
}

.unified-header .search-container input::placeholder {
    color: var(--tb-text-subtle);
}

/* === Topic accordion — flat soft cards instead of shadowy boxes ========== */

.topic-accordion .accordion-item:hover {
    border-color: #d1d5db !important;
}


.topic-accordion .accordion-button:hover {
    background: #fafcfd !important;
}





/* === Subtopic mini-cards ================================================ */




/* === Welcome placeholder + empty states ================================= */


/* === Heatmap modal — softer ============================================= */


.heatmap-view-options .heatmap-view-btn {
    background: var(--tb-card) !important;
    border: 1px solid var(--tb-border) !important;
    color: var(--tb-text-muted) !important;
}

.heatmap-view-options .heatmap-view-btn.active {
    background: var(--tb-accent-soft) !important;
    border-color: var(--tb-accent) !important;
    color: var(--jmaths-dark-blue) !important;
}

/* === Floating course/unit selector bar ================================== */

/* === Practice cart (floating) =========================================== */
.practice-cart-floating,
.floating-cart-bar {
    background: var(--tb-card) !important;
    border: 1px solid var(--tb-border) !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08) !important;
    border-radius: 10px !important;
    color: var(--tb-text) !important;
}

/* === Section headers (where the template uses h2/h6 with text-muted) ==== */
.tb-section-header,
.topic-browser-container h6.text-muted {
    font-size: 0.74rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: var(--tb-text-muted) !important;
    font-weight: 600 !important;
    margin-bottom: 0.55rem !important;
}

/* === Question pick / cart button on question cards ====================== */
.question-card,
.concept-card {
    background: var(--tb-card) !important;
    border: 1px solid var(--tb-border) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

.question-card:hover,
.concept-card:hover {
    border-color: #d1d5db !important;
}

/* Flat concept-card: when a unit has only one auto-generated 'Practice
   questions' wrapper, drop the surrounding border/padding so questions
   render directly under the unit header without the visual nesting. */
.concept-card-flat {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.concept-card-flat .questions-container {
    padding: 0 !important;
}

/* === Source badges (V2 past-paper, etc.) ================================ */
.source-badge {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0.12rem 0.5rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

.source-badge.v2-badge {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
}

a.source-badge.v2-badge:hover {
    background: #ddd6fe;
    text-decoration: none;
}

.source-badge.v2-badge.source-badge-muted {
    opacity: 0.6;
    cursor: help;
}

.source-badge.qb-badge {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.source-badge.gen-badge {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.source-badge.cn-badge {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.source-badge.variant-badge {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.source-badge.legacy-badge {
    background: #f3f4f6;
    color: #9ca3af;
    border: 1px solid #e5e7eb;
}

/* Super-only "Variant of IB-XXX" lineage pill. Yellow tint so admins
   immediately recognise it as a moderation cue, distinct from the
   green variant-badge that students also see. */
.source-badge.variant-source-badge {
    background: #fef9c3;
    color: #713f12;
    border: 1px solid #fde68a;
    text-decoration: none;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.7rem;
    transition: background-color 0.15s ease;
}
.source-badge.variant-source-badge:hover {
    background: #fde68a;
    color: #713f12;
}

/* Question previews — show the full body so the row reads as a complete
   card (not a clamped row). Card-style was added Phase 4; previously
   .question-preview was max-height: 280px + overflow: hidden which
   truncated longer questions. */
.question-preview {
    line-height: 1.6;
    color: var(--tb-text);
    font-size: 0.92rem;
    position: relative;
    max-height: 380px;
}

/* Constrain inline diagrams (Mathpix imports often have native widths
   over 600px, which crowds the question card). Cap by both width and
   height so wide and tall diagrams both shrink to a sensible thumbnail
   inline; the full-size diagram still opens in the question modal. */
.question-preview img {
    max-width: 100% !important;
    max-height: 160px !important;
    width: auto !important;
    height: auto !important;
    display: block;
    margin: 0.4rem 0;
    border-radius: 4px;
}

/* Tables inside question previews — generated questions often contain
   data tables (frequency tables, probability distributions). Base CSS
   gives them no border or spacing, so they render as plain text. */
.question-preview table,
.exam-question-context table,
.exam-part-content table,
.ib-exam-paper table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.86rem;
    width: auto;
    max-width: 100%;
}

.question-preview table th,
.question-preview table td,
.exam-question-context table th,
.exam-question-context table td,
.exam-part-content table th,
.exam-part-content table td,
.ib-exam-paper table th,
.ib-exam-paper table td {
    border: 1px solid var(--tb-border);
    padding: 0.3rem 0.55rem;
    text-align: left;
    vertical-align: top;
}

.question-preview table thead th,
.question-preview table th:first-child,
.exam-question-context table thead th,
.exam-question-context table th:first-child,
.exam-part-content table thead th,
.exam-part-content table th:first-child,
.ib-exam-paper table thead th,
.ib-exam-paper table th:first-child {
    background: var(--tb-bg);
    font-weight: 600;
}

/* Bump the clamp so a small table doesn't get chopped — but keep the
   ceiling so very long questions still fade out gracefully. */

.question-preview.is-long::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--tb-card));
    pointer-events: none;
}

/* === Star ratings (confidence) — same calm pastels as mastery ============ */
.confidence-stars .star,
.power-meter .star {
    color: #fbbf24;
}

/* Reset overly saturated badges to pastel equivalents */
.badge.bg-success { background: #d1fae5 !important; color: #065f46 !important; }
.badge.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.badge.bg-danger  { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-info    { background: #dbeafe !important; color: #1e40af !important; }

/* Parent/variant side-by-side compare pane (builder preview modal) */
.compare-grid.is-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.compare-grid.is-split .compare-pane { border-left: 1px solid var(--border, #dee2e6); padding-left: 1.25rem; }
.compare-col-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted, var(--color-secondary)); margin-bottom: .5rem; font-weight: 600; }
@media (max-width: 768px) { .compare-grid.is-split { grid-template-columns: 1fr; } }
.badge.bg-primary { background: #ccfbf1 !important; color: #115e59 !important; }

/* ========================================================================
   BUILDER INFINITE SCROLL
   ======================================================================== */

/* The sentinel div sits below the question grid and is watched by an
   IntersectionObserver (rootMargin 600px) to trigger loadMore() before the
   user reaches the bottom of the list. */
#scrollSentinel {
    height: 1px;
    margin: 0;
}
