/* Shared CSS for Math Revision App */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =====================
   CSS Variables - Minimal Theme
   ===================== */
:root {
    /* Primary Colors */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;
    
    /* Secondary Colors */
    --color-secondary: #059669;
    --color-secondary-hover: #047857;
    --color-secondary-light: #ecfdf5;
    
    /* Accent Colors */
    --color-accent: #7c3aed;
    --color-accent-hover: #6d28d9;
    --color-accent-light: #f5f3ff;
    
    /* Neutral Colors */
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-bg: #ffffff;
    --color-bg-subtle: #f9fafb;
    --color-border: #e5e7eb;
    --color-border-focus: #2563eb;
    
    /* Shadows - Minimal */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* =====================
   Base Styles
   ===================== */
body {
    font-family: var(--font-family);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =====================
   Animation Keyframes
   ===================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake { animation: shake 0.4s ease-in-out; }

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

@keyframes slideOut {
    0% { opacity: 1; transform: translateX(0); max-height: 500px; margin-bottom: 1rem; }
    50% { opacity: 0; transform: translateX(100%); max-height: 500px; margin-bottom: 1rem; }
    100% { opacity: 0; transform: translateX(100%); max-height: 0; margin-bottom: 0; padding: 0; }
}

@keyframes slideOutLeft {
    0% { opacity: 1; transform: translateX(0); max-height: 500px; margin-bottom: 1rem; }
    50% { opacity: 0; transform: translateX(-100%); max-height: 500px; margin-bottom: 1rem; }
    100% { opacity: 0; transform: translateX(-100%); max-height: 0; margin-bottom: 0; padding: 0; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =====================
   Subject Switch Loading Overlay
   ===================== */
.subject-switch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.subject-switch-overlay.active {
    opacity: 1;
    visibility: visible;
}

.subject-switch-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.subject-switch-text {
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* =====================
   Export Button Loading States
   ===================== */
/* Loading spinner for export buttons */
.export-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* Show spinner and loading text when libs are loading */
button[data-libs-loading="true"] .export-btn-spinner {
    display: inline-block;
}

button[data-libs-loading="true"] .export-btn-text {
    display: none;
}

button[data-libs-loading="true"] .export-btn-loading-text {
    display: inline;
}

/* Hide loading text by default */
.export-btn-loading-text {
    display: none;
}

/* Styling for loading state button */
button[data-libs-loading="true"] {
    opacity: 0.7;
    cursor: wait;
}

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

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

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =====================
   Animation Classes
   ===================== */
.fade-in { animation: fadeIn 0.3s ease-out; }
.slide-down { animation: slideDown 0.25s ease-out; }
.slide-out { animation: slideOut 0.4s ease-out forwards; }
.slide-out-left { animation: slideOutLeft 0.4s ease-out forwards; }
.loading-spinner { animation: spin 1s linear infinite; }
.notification { animation: slideInNotification 0.3s ease-out, slideOutNotification 0.3s ease-in 2.7s forwards; }

/* =====================
   Button Styles
   ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 52px;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

/* Secondary Button */
.btn-secondary {
    background-color: var(--color-secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--color-secondary-hover);
}

/* Accent Button */
.btn-accent {
    background-color: var(--color-accent);
    color: white;
}

.btn-accent:hover {
    background-color: var(--color-accent-hover);
}

/* Ghost Button */
.btn-ghost {
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-ghost:hover {
    background-color: var(--color-bg-subtle);
    border-color: var(--color-text-muted);
}

/* Small Button */
.btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
}

/* =====================
   Card Styles
   ===================== */
.card {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.card-interactive:active {
    transform: scale(0.99);
}

/* Teacher theme card */
.card-teacher:hover {
    border-color: var(--color-primary);
}

/* Learner theme card */
.card-learner:hover {
    border-color: var(--color-secondary);
}

/* =====================
   Form Elements
   ===================== */
select,
input,
textarea {
    font-family: var(--font-family);
    font-size: 1rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 52px;
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.5rem;
    appearance: none;
}

/* =====================
   Badge Styles
   ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 9999px;
    line-height: 1.25;
}

.badge-primary {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-secondary {
    background-color: var(--color-secondary-light);
    color: var(--color-secondary);
}

.badge-accent {
    background-color: var(--color-accent-light);
    color: var(--color-accent);
}

.badge-neutral {
    background-color: var(--color-bg-subtle);
    color: var(--color-text-secondary);
}

/* =====================
   Typography
   ===================== */
.text-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}

.text-subtitle {
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--color-text-secondary);
}

.text-heading {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.text-body {
    font-size: 1rem;
    color: var(--color-text);
}

.text-small {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/* =====================
   Skeleton Loaders
   ===================== */
.skeleton {
    animation: skeleton-loading 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
}

.skeleton-text { height: 1rem; }
.skeleton-title { height: 1.5rem; }
.skeleton-badge { height: 1.75rem; border-radius: 9999px; }

/* =====================
   Utility Classes
   ===================== */
.touch-manipulation {
    touch-action: manipulation;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Focus visible for accessibility */
.focus-ring:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* =====================
   Layout Utilities
   ===================== */
.container-app {
    max-width: 56rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

@media (min-width: 640px) {
    .container-app {
        padding: 2rem 1.5rem;
    }
}

/* =====================
   Mobile Optimizations
   ===================== */
@media (max-width: 640px) {
    :root {
        --radius-lg: 12px;
    }
    
    .text-title {
        font-size: 1.75rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .btn {
        width: 100%;
    }
}

/* =====================
   Modal Mobile Optimizations
   ===================== */
@media (max-width: 480px) {
    /* Modal inner padding adjustments */
    [id$="Modal"] > div {
        padding: 1.25rem !important;
    }
    
    /* Modal title sizing */
    [id$="Modal"] h3 {
        font-size: 1.25rem !important;
    }
    
    /* Checkbox option cards - larger touch targets */
    [id$="Modal"] label.flex {
        padding: 1rem !important;
        min-height: 60px;
    }
    
    /* Checkbox sizing for touch */
    [id$="Modal"] input[type="checkbox"] {
        width: 1.5rem !important;
        height: 1.5rem !important;
        min-width: 1.5rem;
    }
    
    /* Modal action buttons - stack on very small screens */
    [id$="Modal"] .flex.gap-3:last-child {
        flex-direction: column;
    }
    
    [id$="Modal"] .flex.gap-3:last-child > button {
        width: 100%;
    }
}

/* =====================
   Landscape Orientation Optimizations
   ===================== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Modal landscape adjustments */
    [id$="Modal"] {
        align-items: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    [id$="Modal"] > div {
        max-height: 85vh;
        overflow-y: auto;
        padding: 1rem 1.25rem !important;
    }
    
    [id$="Modal"] h3 {
        font-size: 1.125rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Compact checkbox labels */
    [id$="Modal"] label.flex {
        padding: 0.625rem 0.875rem !important;
        min-height: 44px;
    }
    
    /* Side-by-side action buttons in landscape */
    [id$="Modal"] .flex.gap-3:last-child {
        flex-direction: row !important;
        gap: 0.5rem;
    }
    
    [id$="Modal"] .flex.gap-3:last-child > button {
        flex: 1;
        min-height: 44px;
        padding: 0.625rem 1rem;
    }
    
    /* Compact tab buttons */
    [id$="Modal"] [role="tablist"] button,
    [id$="Modal"] .flex.border-b button {
        padding: 0.5rem 0.75rem !important;
        min-height: 40px;
        font-size: 0.8125rem;
    }
    
    /* Bottom drawer landscape */
    .bottom-drawer {
        min-height: 40vh;
        max-height: 80vh;
        border-radius: 12px 12px 0 0;
    }
    
    .drawer-content {
        padding: 0 16px 16px;
        max-height: calc(80vh - 120px);
    }
    
    .drawer-tabs {
        padding: 0 16px;
        margin-bottom: 12px;
    }
    
    .drawer-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .drawer-question-header {
        padding-bottom: 10px;
    }
    
    .drawer-question-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Compact answer box */
    .answer-box {
        padding: 12px;
    }
    
    .answer-value {
        font-size: 1.125rem;
    }
    
    /* Smaller video container in landscape */
    .video-container {
        padding-bottom: 45%;
    }
    
    /* Compact buttons */
    .btn {
        min-height: 44px;
        padding: 0.625rem 1rem;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.875rem;
    }
    
    /* Compact cards */
    .card {
        padding: 1rem;
    }
    
    /* Question card landscape */
    .question-card {
        padding: 0.875rem !important;
    }
    
    /* Container padding reduction */
    .container-app {
        padding: 1rem 0.75rem;
    }
}

/* Even more compact for very short landscape screens */
@media (orientation: landscape) and (max-height: 400px) {
    .bottom-drawer {
        min-height: 50vh;
        max-height: 90vh;
    }
    
    .drawer-content {
        max-height: calc(90vh - 100px);
    }
    
    .drawer-handle {
        padding: 8px;
    }
    
    .drawer-close-btn {
        width: 36px;
        height: 36px;
        top: 8px;
        right: 8px;
    }
    
    [id$="Modal"] > div {
        max-height: 90vh;
        padding: 0.875rem 1rem !important;
    }
    
    [id$="Modal"] label.flex {
        padding: 0.5rem 0.75rem !important;
        min-height: 40px;
    }
}

/* =====================
   Question Card Responsive Layout
   ===================== */
.question-card {
    container-type: inline-size;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

/* =====================
   Drag and Drop Styles
   ===================== */
.drag-handle {
    cursor: grab;
    padding: 0.5rem;
    color: var(--color-text-muted);
    transition: color 0.15s ease;
    touch-action: none;
}

.drag-handle:hover {
    color: var(--color-text-secondary);
}

.drag-handle:active {
    cursor: grabbing;
}

.question-card.dragging {
    opacity: 0.5;
    transform: scale(0.98);
    box-shadow: var(--shadow-lg);
}

.question-card.drag-over {
    border: 2px dashed var(--color-primary);
    background: var(--color-primary-light);
}

.question-card.drag-over-top {
    border-top: 3px solid var(--color-primary);
}

.question-card.drag-over-bottom {
    border-bottom: 3px solid var(--color-primary);
}

.drop-indicator {
    height: 4px;
    background: var(--color-primary);
    border-radius: 2px;
    margin: 0.5rem 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.drop-indicator.visible {
    opacity: 1;
}

/* Tags Section - wrap nicely */
.question-card .tags-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.question-card .tags-section .badge,
.question-card .tags-section span[class*="bg-"] {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Actions Section - responsive layout */
.question-card .actions-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.question-card .actions-section > * {
    flex: 1 1 auto;
    min-width: 120px;
}

/* Card Header - stack on mobile */
.question-card-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 640px) {
    .question-card-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .question-card .actions-section {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        justify-content: flex-end;
    }
    
    .question-card .actions-section > * {
        flex: 0 0 auto;
    }
}

/* Source badge - allow text wrap on mobile */
@media (max-width: 640px) {
    .question-card .source-badge {
        white-space: normal;
        text-align: left;
        line-height: 1.4;
    }
}

/* =====================
   Bottom Drawer Component
   ===================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 100;
}

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

.bottom-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 101;
    min-height: 50vh;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bottom-drawer.open {
    transform: translateY(0);
}

/* Haptic threshold visual feedback */
.bottom-drawer.threshold-reached {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.5), 0 -8px 32px rgba(239, 68, 68, 0.25);
}

.bottom-drawer.threshold-reached .drawer-handle-bar {
    background: #ef4444;
    transform: scaleX(1.3);
}

/* Drag Handle */
.drawer-handle {
    padding: 12px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    cursor: grab;
}

.drawer-handle-bar {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    transition: background 0.15s ease, transform 0.15s ease;
}

/* Drawer Close Button */
.drawer-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--color-bg-subtle);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    touch-action: manipulation;
}

.drawer-close-btn:hover,
.drawer-close-btn:active {
    background: var(--color-border);
}

.drawer-close-btn svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
}

/* Drawer Content */
.drawer-content {
    padding: 0 20px 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Question Header in Drawer */
.drawer-question-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0;
}

.drawer-question-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.drawer-question-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
}

/* Drawer Tabs */
.drawer-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.drawer-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.drawer-tab:hover {
    color: var(--color-text);
}

.drawer-tab.active {
    color: var(--color-primary);
}

.drawer-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px 2px 0 0;
}

.drawer-tab-icon {
    display: block;
    margin: 0 auto 4px;
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Answer Box */
.answer-box {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    border-radius: 12px;
    padding: 16px;
}

.answer-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #059669;
    margin-bottom: 4px;
}

.answer-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #047857;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
}

.video-unavailable {
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
}

.play-icon {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.play-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.play-icon svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    margin-left: 4px;
}

.video-placeholder span {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Steps List */
.steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.step-item:last-child {
    border-bottom: none;
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text);
}

.no-steps-message {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-secondary);
}

/* Mobile Drawer Improvements */
@media (max-width: 480px) {
    .drawer-content {
        padding: 0 16px 24px;
    }

    .drawer-tabs {
        padding: 0 12px;
        gap: 2px;
    }

    .drawer-tab {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .drawer-tab-icon {
        width: 18px;
        height: 18px;
    }

    .drawer-question-text {
        font-size: 0.95rem;
    }

    .answer-value {
        font-size: 1.1rem;
    }
}

/* Desktop Drawer Styles */
@media (min-width: 768px) {
    .bottom-drawer {
        max-height: 60vh;
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
    }

    .bottom-drawer.open {
        transform: translateX(-50%) translateY(0);
    }

    .drawer-content {
        padding: 0 32px 32px;
    }

    .drawer-tabs {
        padding: 0 32px;
    }
    
    .drawer-close-btn {
        width: 36px;
        height: 36px;
    }
}

/* =====================
   Collapsible Question Details
   ===================== */
.question-details-section {
    width: 100%;
}

.question-details-collapsible {
    display: grid;
    grid-template-rows: 0fr;
    margin-top: 0;
    transition: grid-template-rows 0.3s ease-out, margin-top 0.3s ease-out;
}

.question-details-collapsible > .question-details-content {
    overflow: hidden;
    min-height: 0;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.2s ease-out;
}

.question-details-collapsible.open > .question-details-content {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.2s ease-out 0.1s;
}

.question-details-collapsible.open {
    grid-template-rows: 1fr;
    margin-top: 12px;
}

.question-details-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0 0 0;
    margin-top: 12px;
    border-top: 1px solid var(--color-border);
    background: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: color 0.15s ease;
    width: 100%;
    text-align: left;
}

.question-details-toggle:hover {
    color: var(--color-primary);
}

.question-details-toggle .chevron-icon {
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.question-details-toggle.open .chevron-icon {
    transform: rotate(180deg);
}

.question-details-content {
    background-color: var(--color-bg-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.question-details-content .detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.question-details-content .detail-row:last-child {
    margin-bottom: 0;
}

.question-details-content .detail-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    min-width: 60px;
}

.question-details-content .detail-value {
    font-size: 0.8125rem;
    color: var(--color-text);
}

/* =====================
   Card Menu (Dropdown)
   ===================== */
.card-menu-container {
    position: relative;
}

.card-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.card-menu {
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
}

.card-menu::-webkit-scrollbar {
    width: 4px;
}

.card-menu::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* =====================
   Print Styles for Exams/CATs
   ===================== */
@media print {
    /* Hide UI elements */
    .sidebar,
    .floating-nav,
    .bottom-drawer,
    .drawer-overlay,
    .btn,
    .card-menu-container,
    .question-actions,
    .filter-section,
    .search-section,
    .tab-navigation,
    .notification,
    .modal,
    .category-header .btn,
    .category-actions,
    [data-no-print],
    button:not(.print-include) {
        display: none !important;
    }

    /* Reset backgrounds and colors */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* Full width layout */
    .container-app,
    .main-content,
    .content-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Page setup */
    @page {
        size: A4;
        margin: 2cm 1.5cm;
    }

    /* Exam header - visible on print */
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 1.5cm;
        padding-bottom: 0.5cm;
        border-bottom: 2px solid black;
    }

    .print-header h1 {
        font-size: 18pt;
        font-weight: bold;
        margin-bottom: 0.3cm;
    }

    .print-header .exam-info {
        font-size: 11pt;
        color: #333;
    }

    /* Question cards for print */
    .question-card,
    .saved-question-card {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        padding: 0.5cm !important;
        margin-bottom: 0.5cm !important;
        border-radius: 0 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* Ensure questions don't break across pages */
    .question-content,
    .question-text {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* Question numbering for print */
    .question-card::before,
    .saved-question-card::before {
        content: "Q" counter(question) ". ";
        counter-increment: question;
        font-weight: bold;
    }

    .questions-container,
    .saved-questions-list {
        counter-reset: question;
    }

    /* Category sections - page break before each */
    .category-section {
        page-break-before: always !important;
        break-before: page !important;
    }

    .category-section:first-child {
        page-break-before: avoid !important;
        break-before: avoid !important;
    }

    /* Category headers */
    .category-header {
        background: #f5f5f5 !important;
        padding: 0.3cm !important;
        margin-bottom: 0.3cm !important;
        border-bottom: 1px solid #333 !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .category-header h3 {
        font-size: 14pt;
        font-weight: bold;
        margin: 0;
    }

    /* Marks display */
    .question-marks,
    .marks-badge {
        font-weight: bold;
        border: 1px solid #333;
        padding: 2px 6px;
        float: right;
    }

    /* Tags/badges simplified */
    .badge,
    .tag {
        background: #eee !important;
        color: black !important;
        border: 1px solid #999 !important;
        font-size: 9pt;
    }

    /* Hide decorative elements */
    .card-hover-effect,
    .ripple,
    .skeleton,
    .loading-spinner {
        display: none !important;
    }

    /* Links as text */
    a {
        color: black !important;
        text-decoration: none !important;
    }

    /* Ensure text is readable */
    * {
        color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Answer sections - optional visibility */
    .answer-section,
    .question-answer {
        border-top: 1px dashed #999;
        padding-top: 0.3cm;
        margin-top: 0.3cm;
    }

    /* Footer with page numbers */
    @page {
        @bottom-center {
            content: "Page " counter(page) " of " counter(pages);
            font-size: 10pt;
        }
    }
}

/* =====================
   Export Progress Modal
   ===================== */

/**
 * Export Progress Modal Overlay
 * Full-screen backdrop with blur effect for export progress indication
 * Uses CSS transitions for smooth show/hide animations
 */
.export-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.export-progress-overlay.active {
    opacity: 1;
    visibility: visible;
}

/**
 * Export Progress Modal Content
 * Centered card containing progress information
 * Responsive with landscape orientation support
 */
.export-progress-modal {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: calc(100% - 2rem);
    max-width: 400px;
    margin: 1rem;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

@media (min-width: 480px) {
    .export-progress-modal {
        padding: 2rem;
    }
}

.export-progress-overlay.active .export-progress-modal {
    transform: scale(1);
}

/**
 * Export Progress Header
 * Contains icon and title/subtitle
 */
.export-progress-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.export-progress-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: export-pulse 2s infinite;
    flex-shrink: 0;
}

@keyframes export-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.export-progress-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.export-progress-title {
    font-size: clamp(1.125rem, 4vw, 1.25rem);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.export-progress-subtitle {
    font-size: clamp(0.8125rem, 3.5vw, 0.875rem);
    color: var(--color-text-secondary);
    margin: 0;
}

/**
 * Export Progress Bar
 * Animated progress indicator with shimmer effect
 */
.export-progress-bar-container {
    margin-bottom: 1rem;
}

.export-progress-bar-bg {
    height: 8px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.export-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
    border-radius: 999px;
    transition: width 0.3s ease;
    position: relative;
}

.export-progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: export-shimmer 1.5s infinite;
}

@keyframes export-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/**
 * Export Progress Stats
 * Percentage and item count display
 */
.export-progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.export-progress-percentage {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.export-progress-count {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/**
 * Export Progress Status
 * Current operation status text
 */
.export-progress-status {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
    min-height: 1.25rem;
}

/**
 * Export Progress Cancel Button
 * Action button for cancel/close operations
 */
.export-progress-cancel {
    width: 100%;
    padding: 0.875rem;
    min-height: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.export-progress-cancel:hover {
    background: var(--color-bg-subtle);
    border-color: var(--color-text-muted);
}

/**
 * Export Progress Completion State
 * Visual changes when export is complete
 */
.export-progress-modal.complete .export-progress-icon {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-hover));
    animation: none;
}

.export-progress-modal.complete .export-progress-bar-fill {
    background: linear-gradient(90deg, var(--color-secondary), var(--color-secondary-hover));
}

.export-progress-modal.complete .export-progress-bar-fill::after {
    display: none;
}

/**
 * Export Progress Landscape Orientation Support
 * Compact layout for landscape mobile devices
 */
@media (orientation: landscape) and (max-height: 500px) {
    .export-progress-modal {
        padding: 1rem 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .export-progress-header {
        margin-bottom: 0.75rem;
    }

    .export-progress-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .export-progress-icon svg {
        width: 20px;
        height: 20px;
    }

    .export-progress-stats {
        margin-bottom: 0.75rem;
    }

    .export-progress-status {
        margin-bottom: 0.75rem;
    }

    .export-progress-percentage {
        font-size: 1.25rem;
    }
}

/* =====================
   Question Attempt UI Styles
   ===================== */

/* MCQ option card */
.mcq-option {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem; border: 2px solid #e5e7eb;
    border-radius: 12px; cursor: pointer; transition: all 0.2s;
    background: white; min-height: 56px;
}
.mcq-option:hover { border-color: #059669; background: #ecfdf5; }
.mcq-option.selected { border-color: #2563eb; background: #eff6ff; }
.mcq-option.correct { border-color: #16a34a; background: #dcfce7; }
.mcq-option.incorrect { border-color: #dc2626; background: #fef2f2; }
.mcq-option.reveal-correct { border-color: #16a34a; background: #dcfce7; }
.mcq-option.disabled { pointer-events: none; opacity: 0.7; }
.mcq-letter {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.875rem;
    background: #f3f4f6; color: #374151; flex-shrink: 0; transition: all 0.2s;
}
.mcq-option.selected .mcq-letter { background: #2563eb; color: white; }
.mcq-option.correct .mcq-letter { background: #16a34a; color: white; }
.mcq-option.incorrect .mcq-letter { background: #dc2626; color: white; }
.mcq-option.reveal-correct .mcq-letter { background: #16a34a; color: white; }

/* MCQ image placeholder */
.mcq-image-placeholder {
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; background: #f9fafb; border: 1px dashed #d1d5db;
    border-radius: 0.5rem; min-height: 60px;
}
.mcq-image-label { font-size: 0.875rem; color: #6b7280; font-weight: 500; }

/* Multi-select chip */
.chip {
    display: inline-flex; align-items: center;
    padding: 0.625rem 1.25rem; border: 2px solid #e5e7eb;
    border-radius: 9999px; cursor: pointer; transition: all 0.2s;
    font-weight: 500; font-size: 0.9375rem; background: white;
    user-select: none; min-height: 44px;
}
.chip:hover { border-color: #059669; background: #ecfdf5; }
.chip.selected { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.chip.correct { border-color: #16a34a; background: #dcfce7; color: #15803d; }
.chip.incorrect { border-color: #dc2626; background: #fef2f2; color: #dc2626; }
.chip.reveal-correct { border-color: #16a34a; background: #dcfce7; color: #15803d; }
.chip.disabled { pointer-events: none; opacity: 0.7; }

/* Typed input */
.typed-input {
    width: 100%; padding: 1rem 1.25rem; border: 2px solid #e5e7eb;
    border-radius: 12px; font-size: 1.125rem; transition: all 0.2s;
    outline: none; min-height: 56px;
}
.typed-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.typed-input.correct { border-color: #16a34a; background: #dcfce7; }
.typed-input.incorrect { border-color: #dc2626; background: #fef2f2; }

/* Special char buttons */
.special-char-btn {
    min-width: 44px; height: 44px; border: 1.5px solid #d1d5db; border-radius: 8px;
    background: white; font-size: 1.1rem; cursor: pointer; transition: all 0.15s;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 0.5rem; font-weight: 500; color: #374151;
}
.special-char-btn:hover { border-color: #2563eb; background: #eff6ff; }
.special-char-btn:active { transform: scale(0.95); }
.special-char-btn.disabled { pointer-events: none; opacity: 0.5; }

/* Clicking answer display box */
.click-answer-display {
    min-height: 48px; border: 2px solid #e5e7eb; border-radius: 12px;
    padding: 0.75rem 1rem; font-size: 1.25rem; font-weight: 700;
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    cursor: text; background: #fafafa; transition: border-color 0.2s;
    text-align: center; justify-content: center;
}
.click-answer-display:empty::before {
    content: 'Tap buttons below...'; color: #9ca3af; font-weight: 400; font-size: 1rem;
}
.click-answer-display.correct { border-color: #16a34a; background: #dcfce7; }
.click-answer-display.incorrect { border-color: #dc2626; background: #fef2f2; }
.click-answer-display.disabled { pointer-events: none; opacity: 0.8; }

.spanuserinputanswervalue {
    display: inline-flex; align-items: center; cursor: pointer;
    transition: all 0.15s; border-radius: 4px; padding: 0 1px;
}
.spanuserinputanswervalue:hover { background: #fee2e2; color: #dc2626; }
.extramargin-arithmeticoperators { margin: 0 4px; }
.extramargin-parentheses { margin: 0 1px; }

.char-category-separator {
    color: #d1d5db; font-size: 1.25rem; margin: 0 4px;
    display: inline-flex; align-items: center; user-select: none;
}

.clear-answer-btn {
    padding: 0.625rem 1.5rem; border: 1.5px solid #d1d5db; border-radius: 8px;
    background: white; font-size: 0.875rem; cursor: pointer; color: #6b7280;
    transition: all 0.15s; font-weight: 500; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
}
.clear-answer-btn:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.clear-answer-btn.disabled { pointer-events: none; opacity: 0.5; }

.placeholder-instructions {
    background: #fef2f2; border-radius: 10px; padding: 0.75rem 1.25rem;
    color: #059669; font-size: 0.875rem; text-align: center; font-weight: 500;
}

/* Loading spinner (question attempt) */
@keyframes qa-spin { to { transform: rotate(360deg); } }
.spinner {
    width: 48px; height: 48px; border: 4px solid #e5e7eb;
    border-top-color: #7c3aed; border-radius: 50%;
    animation: qa-spin 0.8s linear infinite;
}

/* Animated result icon */
@keyframes drawCircle { 0% { stroke-dashoffset: 314; } 100% { stroke-dashoffset: 0; } }
@keyframes drawCheck { 0% { stroke-dashoffset: 80; } 100% { stroke-dashoffset: 0; } }
@keyframes drawX { 0% { stroke-dashoffset: 60; } 100% { stroke-dashoffset: 0; } }
@keyframes scaleIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.result-icon-container { animation: scaleIn 0.4s ease-out; }
.result-circle { stroke-dasharray: 314; stroke-dashoffset: 314; animation: drawCircle 0.6s ease-out 0.2s forwards; }
.result-check { stroke-dasharray: 80; stroke-dashoffset: 80; animation: drawCheck 0.4s ease-out 0.6s forwards; }
.result-x-line { stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawX 0.3s ease-out 0.6s forwards; }

/* Modal overlay */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; animation: fadeInOverlay 0.2s ease-out;
}
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: white; border-radius: 16px; overflow: hidden;
    width: 90%; max-width: 420px; animation: slideUp 0.3s ease-out;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Hint panel */
.hint-panel {
    background: #fef9e7; border-left: 4px solid #f59e0b;
    padding: 1.25rem 1.5rem; animation: fadeIn 0.3s ease-out;
}

/* Solution dropdown */
.solution-dropdown-btn {
    background: #6b7280; color: white; padding: 0.625rem 1.25rem;
    border-radius: 8px; font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: none; display: inline-flex;
    align-items: center; gap: 0.375rem; transition: background 0.2s;
    min-height: 44px;
}
.solution-dropdown-btn:hover { background: #4b5563; }

.correct-answer-display {
    background: #f3f4f6; border: 2px solid #d1d5db; border-radius: 10px;
    padding: 0.75rem 1.25rem; font-size: 1.125rem; color: #374151;
    pointer-events: none; text-align: center;
}

/* Mobile touch target overrides */
.back-to-list-btn {
    min-height: 44px; display: inline-flex; align-items: center;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.result-back-btn {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 2rem; touch-action: manipulation;
}
.solution-tab-btn {
    min-height: 44px; display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.modal-hint-btn {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    touch-action: manipulation; padding: 0.5rem 1rem;
}

/* Landscape orientation support for question attempt */
@media (orientation: landscape) and (max-height: 500px) {
    .modal-content { max-height: 90vh; overflow-y: auto; }
    .result-icon-container svg { width: 80px; height: 80px; }
    .hint-panel { padding: 0.75rem 1rem; }
}

/* =====================
   Video Solution Player
   ===================== */
.qa-video-iframe-wrapper {
    position: relative; width: 100%; padding-bottom: 56.25%; /* 16:9 */
    background: #111827; border-radius: var(--radius-md); overflow: hidden;
}
.qa-video-iframe-wrapper iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}
.qa-video-placeholder {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--color-text-muted); gap: 0.75rem;
}
.qa-play-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(239, 68, 68, 0.15); display: flex;
    align-items: center; justify-content: center;
    font-size: 1.75rem; color: #ef4444;
}
.qa-video-meta {
    padding: 0.75rem 1rem; background: var(--color-bg-subtle);
    border-top: 1px solid var(--color-border);
    animation: fadeIn 0.25s ease-out;
}
.qa-source-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.875rem 1rem; border: 2px solid var(--color-border);
    border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s;
    background: var(--color-bg); min-height: 44px; touch-action: manipulation;
}
.qa-source-item:hover { border-color: #ef4444; background: #fef2f2; }
.qa-source-item.active { border-color: #ef4444; background: #fef2f2; }
.qa-play-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: #ef4444; color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.875rem; cursor: pointer; transition: all 0.2s;
    flex-shrink: 0; touch-action: manipulation;
}
.qa-play-btn:hover { background: #dc2626; transform: scale(1.1); }
.qa-source-item.active .qa-play-btn { background: #dc2626; }

/* =====================
   Question Images - Shared Styles
   ===================== */

/* Image containers */
.qi-intro-images,
.qi-question-images,
.qi-solution-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
}

/* Base image style */
.qi-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: zoom-in;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    background: var(--color-bg-subtle);
}

.qi-image:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

/* Context-specific image sizing */
.qi-intro-image,
.qi-question-image {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.qi-mcq-image {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.qi-solution-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.qi-inline-image,
.qi-intro-inline-image {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
    margin: 0.75rem 0;
}

/* Image link wrapper */
.qi-image-link {
    display: inline-block;
    text-decoration: none;
    line-height: 0;
}

/* Shimmer skeleton while images load */
.qi-image-wrapper {
    position: relative;
    overflow: hidden;
    min-height: 40px;
    min-width: 40px;
    background: var(--color-bg-subtle, #f1f5f9);
    border-radius: 6px;
}

/* Card images should not reserve large space */
.qi-image-wrapper:has(.qi-card-image) {
    min-height: 0;
    min-width: 0;
}

/* Card image wrappers: collapse if image hasn't loaded */
.qi-image-wrapper.qi-image-inline:not(:has(.qi-loaded)) {
    min-height: 0;
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Once image loads, expand wrapper */
.qi-image-wrapper:has(.qi-loaded) {
    max-height: none;
    opacity: 1;
}

.qi-image-inline {
    display: inline-block;
}

.qi-shimmer {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--color-bg-subtle, #f1f5f9) 0%,
        #e2e8f0 40%,
        var(--color-bg-subtle, #f1f5f9) 80%
    );
    background-size: 200% 100%;
    animation: qi-shimmer-move 1.5s ease-in-out infinite;
    z-index: 1;
}

@keyframes qi-shimmer-move {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.qi-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.qi-image.qi-loaded {
    opacity: 1;
}

/* Placeholder for missing images */
.qi-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-subtle);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.qi-placeholder-icon {
    font-size: 1.25rem;
}

.qi-placeholder-label {
    font-weight: 500;
}

.qi-load-failed {
    border-color: #e2a308;
    background: #fefce8;
    color: #92400e;
}

.qi-mcq-placeholder {
    width: 100%;
    justify-content: center;
    padding: 1.5rem;
}

/* Card-level images (question list previews) */
.qi-card-image {
    max-width: 80%;
    max-height: 120px;
    border-radius: 6px;
    margin: 0.5rem auto;
    display: block;
}

.qi-card-placeholder {
    margin: 0.5rem 0;
    font-size: 0.8rem;
}


   CSS-only Lightbox (tap-to-zoom)
   ===================== */
.qi-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: zoom-out;
    padding: 1rem;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.qi-lightbox:target {
    display: flex;
}

.qi-lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: qiLightboxIn 0.2s ease-out;
}

@keyframes qiLightboxIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .qi-intro-images,
    .qi-question-images,
    .qi-solution-images {
        flex-direction: column;
        align-items: center;
    }
    
    .qi-intro-image,
    .qi-question-image {
        max-height: 300px;
    }
    
    .qi-mcq-image {
        max-height: 150px;
    }
    
    .qi-lightbox img {
        max-width: 98vw;
        max-height: 85vh;
    }
}

/* =====================
   SUBSCRIPTION GATING - Locked Question Overlay
   ===================== */
.question-locked-overlay {
    position: relative;
    pointer-events: none;
    user-select: none;
}

.question-locked-overlay > *:not(.locked-badge) {
    filter: blur(4px);
    opacity: 0.5;
}

.locked-badge {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    z-index: 10;
    background: rgba(255, 255, 255, 0.6);
    border-radius: inherit;
}

.locked-badge-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.locked-badge-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.locked-badge-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: #92400e;
}

.locked-badge-cta {
    font-size: 0.75rem;
    color: #b45309;
    margin-top: 2px;
}

/* Upgrade banner shown after free questions */
.subscription-upgrade-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    margin-top: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.subscription-upgrade-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
}

.subscription-upgrade-banner h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 0.25rem;
}

.subscription-upgrade-banner p {
    font-size: 0.875rem;
    color: #a16207;
}

/* Learner theme variant */
.learner-theme .locked-badge-icon {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.learner-theme .locked-badge-text {
    color: #065f46;
}

.learner-theme .locked-badge-cta {
    color: #047857;
}

.learner-theme .subscription-upgrade-banner {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-color: #10b981;
}

.learner-theme .subscription-upgrade-banner h3 {
    color: #065f46;
}

.learner-theme .subscription-upgrade-banner p {
    color: #047857;
}
