@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;600&family=JetBrains+Mono:wght@400;700&display=swap');

body {
    font-family: 'Fredoka', sans-serif;
    background-color: #f0f4f8;
    color: #2d3748;
}

.code-font {
    font-family: 'JetBrains Mono', monospace;
}

/* Card Flip Effect */
.card-flip {
    perspective: 1000px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.card-flip:hover .card-inner,
.card-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card-back {
    background-color: #4c51bf;
    color: white;
    transform: rotateY(180deg);
}

.card-front {
    background-color: white;
    border: 2px solid #4c51bf;
}

canvas {
    background: white;
    border-radius: 8px;
    max-width: 100%;
}

body.dark-mode canvas {
    background: #1a1a1e;
}

/* Mobile Menu Transition */
#sidebar {
    transition: transform 0.3s ease-in-out;
}

.mobile-hidden {
    transform: translateX(-100%);
}

.mobile-visible {
    transform: translateX(0);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* DARK MODE */
body.dark-mode {
    background-color: #18181b;
    /* gray-900 */
    color: #f3f4f6;
    /* gray-100 */
}

body.dark-mode main {
    background-color: #18181b;
}

body.dark-mode header {
    background-color: #27272a;
    /* gray-800 */
    border-bottom-color: #374151;
    /* gray-700 */
}

body.dark-mode #chapter-title {
    color: #818cf8;
    /* indigo-400 */
}

body.dark-mode .bg-white {
    background-color: #27272a;
    color: #f3f4f6;
}

body.dark-mode .bg-gray-50 {
    background-color: #18181b;
    color: #f3f4f6;
}

body.dark-mode .text-gray-600,
body.dark-mode .text-gray-700,
body.dark-mode .text-gray-800 {
    color: #d1d5db;
    /* gray-300 */
}

body.dark-mode .text-indigo-700,
body.dark-mode .text-indigo-800 {
    color: #a5b4fc;
    /* indigo-300 */
}

body.dark-mode .bg-indigo-50,
body.dark-mode .bg-indigo-100 {
    background-color: #312e81;
    /* indigo-900 */
    color: #e0e7ff;
    /* indigo-100 */
}

body.dark-mode canvas {
    filter: invert(0.9) hue-rotate(180deg);
}

body.dark-mode .card-front {
    background-color: #27272a;
    border-color: #6366f1;
}

body.dark-mode .card-front span {
    color: #e0e7ff;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #27272a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode .bg-gray-100 {
    background-color: #374151;
    /* gray-700 */
    color: #f3f4f6;
}

body.dark-mode .bg-gray-200 {
    background-color: #4b5563;
    /* gray-600 */
    color: #f3f4f6;
}

body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #4b5563;
    /* gray-600 */
}

/* Fix for specific text colors in dark mode if needed */
body.dark-mode .text-pink-700 {
    color: #f9a8d4;
    /* pink-300 */
}

body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
}

/* Dark Mode Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Purple Variants */
body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-100 {
    background-color: #581c87;
    /* purple-900 */
    color: #e9d5ff;
    /* purple-100 */
    border-color: #6b21a8;
}

body.dark-mode .text-purple-700 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Orange Variants */
body.dark-mode .bg-orange-50,
body.dark-mode .bg-orange-100 {
    background-color: #7c2d12;
    /* orange-900 */
    color: #ffedd5;
    /* orange-100 */
    border-color: #9a3412;
}

body.dark-mode .text-orange-700 {
    color: #fdba74;
    /* orange-300 */
}

/* Green Variants (if used) */
body.dark-mode .bg-green-50,
body.dark-mode .bg-green-100 {
    background-color: #14532d;
    /* green-900 */
    color: #dcfce7;
}

.mobile-hidden {
    transform: translateX(-100%);
}

.mobile-visible {
    transform: translateX(0);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* DARK MODE */
body.dark-mode {
    background-color: #18181b;
    /* gray-900 */
    color: #f3f4f6;
    /* gray-100 */
}

body.dark-mode main {
    background-color: #18181b;
}

body.dark-mode header {
    background-color: #27272a;
    /* gray-800 */
    border-bottom-color: #374151;
    /* gray-700 */
}

body.dark-mode #chapter-title {
    color: #818cf8;
    /* indigo-400 */
}

body.dark-mode .bg-white {
    background-color: #27272a;
    color: #f3f4f6;
}

body.dark-mode .bg-gray-50 {
    background-color: #18181b;
    color: #f3f4f6;
}

body.dark-mode .text-gray-600,
body.dark-mode .text-gray-700,
body.dark-mode .text-gray-800 {
    color: #d1d5db;
    /* gray-300 */
}

body.dark-mode .text-indigo-700,
body.dark-mode .text-indigo-800 {
    color: #a5b4fc;
    /* indigo-300 */
}

body.dark-mode .bg-indigo-50,
body.dark-mode .bg-indigo-100 {
    background-color: #312e81;
    /* indigo-900 */
    color: #e0e7ff;
    /* indigo-100 */
}

body.dark-mode canvas {
    filter: invert(0.9) hue-rotate(180deg);
}

body.dark-mode .card-front {
    background-color: #27272a;
    border-color: #6366f1;
}

body.dark-mode .card-front span {
    color: #e0e7ff;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #27272a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode .bg-gray-100 {
    background-color: #374151;
    /* gray-700 */
    color: #f3f4f6;
}

body.dark-mode .bg-gray-200 {
    background-color: #4b5563;
    /* gray-600 */
    color: #f3f4f6;
}

body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #4b5563;
    /* gray-600 */
}

/* Fix for specific text colors in dark mode if needed */
body.dark-mode .text-pink-700 {
    color: #f9a8d4;
    /* pink-300 */
}

body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
}

/* Dark Mode Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Purple Variants */
body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-100 {
    background-color: #581c87;
    /* purple-900 */
    color: #e9d5ff;
    /* purple-100 */
    border-color: #6b21a8;
}

body.dark-mode .text-purple-700 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Orange Variants */
body.dark-mode .bg-orange-50,
body.dark-mode .bg-orange-100 {
    background-color: #7c2d12;
    /* orange-900 */
    color: #ffedd5;
    /* orange-100 */
    border-color: #9a3412;
}

body.dark-mode .text-orange-700 {
    color: #fdba74;
    /* orange-300 */
}

/* Green Variants (if used) */
body.dark-mode .bg-green-50,
body.dark-mode .bg-green-100 {
    background-color: #14532d;
    /* green-900 */
    color: #dcfce7;
    /* green-100 */
    border-color: #166534;
}

body.dark-mode .text-green-700 {
    color: #86efac;
    /* green-300 */
}

/* Gradient Overrides */
body.dark-mode .from-gray-50 {
    --tw-gradient-from: #18181b;
    /* gray-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .to-white {
    --tw-gradient-to: #27272a;
    /* gray-800 */
}

/* Blue Variants */
body.dark-mode .bg-blue-50,
body.dark-mode .bg-blue-100 {
    background-color: #1e3a8a;
    /* blue-900 */
    color: #dbeafe;
    /* blue-100 */
    border-color: #1e40af;
}

body.dark-mode .text-blue-800,
body.dark-mode .text-blue-900 {
    color: #93c5fd;
    /* blue-300 */
}

/* Red Variants */
body.dark-mode .bg-red-50,
body.dark-mode .bg-red-100 {
    background-color: #7f1d1d;
    /* red-900 */
    color: #fee2e2;
    /* red-100 */
    border-color: #991b1b;
}

body.dark-mode .text-red-800,
body.dark-mode .text-red-900 {
    color: #fca5a5;
}

body.dark-mode main {
    background-color: #18181b;
}

body.dark-mode header {
    background-color: #27272a;
    /* gray-800 */
    border-bottom-color: #374151;
    /* gray-700 */
}

body.dark-mode #chapter-title {
    color: #818cf8;
    /* indigo-400 */
}

body.dark-mode .bg-white {
    background-color: #27272a;
    color: #f3f4f6;
}

body.dark-mode .bg-gray-50 {
    background-color: #18181b;
    color: #f3f4f6;
}

body.dark-mode .text-gray-600,
body.dark-mode .text-gray-700,
body.dark-mode .text-gray-800 {
    color: #d1d5db;
    /* gray-300 */
}

body.dark-mode .text-indigo-700,
body.dark-mode .text-indigo-800 {
    color: #a5b4fc;
    /* indigo-300 */
}

body.dark-mode .bg-indigo-50,
body.dark-mode .bg-indigo-100 {
    background-color: #312e81;
    /* indigo-900 */
    color: #e0e7ff;
    /* indigo-100 */
}

body.dark-mode canvas {
    filter: invert(0.9) hue-rotate(180deg);
}

body.dark-mode .card-front {
    background-color: #27272a;
    border-color: #6366f1;
}

body.dark-mode .card-front span {
    color: #e0e7ff;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #27272a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode .bg-gray-100 {
    background-color: #374151;
    /* gray-700 */
    color: #f3f4f6;
}

body.dark-mode .bg-gray-200 {
    background-color: #4b5563;
    /* gray-600 */
    color: #f3f4f6;
}

body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #4b5563;
    /* gray-600 */
}

/* Fix for specific text colors in dark mode if needed */
body.dark-mode .text-pink-700 {
    color: #f9a8d4;
    /* pink-300 */
}

body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
}

/* Dark Mode Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Purple Variants */
body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-100 {
    background-color: #581c87;
    /* purple-900 */
    color: #e9d5ff;
    /* purple-100 */
    border-color: #6b21a8;
}

body.dark-mode .text-purple-700 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Orange Variants */
body.dark-mode .bg-orange-50,
body.dark-mode .bg-orange-100 {
    background-color: #7c2d12;
    /* orange-900 */
    color: #ffedd5;
    /* orange-100 */
    border-color: #9a3412;
}

body.dark-mode .text-orange-700 {
    color: #fdba74;
    /* orange-300 */
}

/* Green Variants (if used) */
body.dark-mode .bg-green-50,
body.dark-mode .bg-green-100 {
    background-color: #14532d;
    /* green-900 */
    color: #dcfce7;
    /* green-100 */
    border-color: #166534;
}

body.dark-mode .text-green-700 {
    color: #86efac;
    /* green-300 */
}

/* Gradient Overrides */
body.dark-mode .from-gray-50 {
    --tw-gradient-from: #18181b;
    /* gray-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .to-white {
    --tw-gradient-to: #27272a;
    /* gray-800 */
}

/* Blue Variants */
body.dark-mode .bg-blue-50,
body.dark-mode .bg-blue-100 {
    background-color: #1e3a8a;
    /* blue-900 */
    color: #dbeafe;
    /* blue-100 */
    border-color: #1e40af;
}

body.dark-mode .text-blue-800,
body.dark-mode .text-blue-900 {
    color: #93c5fd;
    /* blue-300 */
}

/* Red Variants */
body.dark-mode .bg-red-50,
body.dark-mode .bg-red-100 {
    background-color: #7f1d1d;
    /* red-900 */
    color: #fee2e2;
    /* red-100 */
    border-color: #991b1b;
}

body.dark-mode .text-red-800,
body.dark-mode .text-red-900 {
    color: #fca5a5;
    /* red-300 */
}

/* Specific Border Overrides */
body.dark-mode .border-gray-200 {
    border-color: #374151;
    /* gray-700 */
}

/* Gradient Overrides for Postulats */
body.dark-mode .from-indigo-50 {
    --tw-gradient-from: #312e81;
    /* indigo-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-purple-50 {
    --tw-gradient-from: #581c87;
    /* purple-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-blue-50 {
    --tw-gradient-from: #1e3a8a;
    /* blue-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-green-50 {
    --tw-gradient-from: #14532d;
    /* green-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

/* Indigo Variants */
body.dark-mode .text-indigo-800,
body.dark-mode .text-indigo-900 {
    color: #a5b4fc;
    /* indigo-300 */
}

/* Purple Variants */
body.dark-mode .text-purple-800,
body.dark-mode .text-purple-900 {
    /* indigo-900 */
    color: #e0e7ff;
    /* indigo-100 */
}

body.dark-mode canvas {
    filter: invert(0.9) hue-rotate(180deg);
}

body.dark-mode .card-front {
    background-color: #27272a;
    border-color: #6366f1;
}

body.dark-mode .card-front span {
    color: #e0e7ff;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #27272a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode .bg-gray-100 {
    background-color: #374151;
    /* gray-700 */
    color: #f3f4f6;
}

body.dark-mode .bg-gray-200 {
    background-color: #4b5563;
    /* gray-600 */
    color: #f3f4f6;
}

body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #4b5563;
    /* gray-600 */
}

/* Fix for specific text colors in dark mode if needed */
body.dark-mode .text-pink-700 {
    color: #f9a8d4;
    /* pink-300 */
}

body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
}

/* Dark Mode Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Purple Variants */
body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-100 {
    background-color: #581c87;
    /* purple-900 */
    color: #e9d5ff;
    /* purple-100 */
    border-color: #6b21a8;
}

body.dark-mode .text-purple-700 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Orange Variants */
body.dark-mode .bg-orange-50,
body.dark-mode .bg-orange-100 {
    background-color: #7c2d12;
    /* orange-900 */
    color: #ffedd5;
    /* orange-100 */
    border-color: #9a3412;
}

body.dark-mode .text-orange-700 {
    color: #fdba74;
    /* orange-300 */
}

/* Green Variants (if used) */
body.dark-mode .bg-green-50,
body.dark-mode .bg-green-100 {
    background-color: #14532d;
    /* green-900 */
    color: #dcfce7;
    /* green-100 */
    border-color: #166534;
}

body.dark-mode .text-green-700 {
    color: #86efac;
    /* green-300 */
}

/* Gradient Overrides */
body.dark-mode .from-gray-50 {
    --tw-gradient-from: #18181b;
    /* gray-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .to-white {
    --tw-gradient-to: #27272a;
    /* gray-800 */
}

/* Blue Variants */
body.dark-mode .bg-blue-50,
body.dark-mode .bg-blue-100 {
    background-color: #1e3a8a;
    /* blue-900 */
    color: #dbeafe;
    /* blue-100 */
    border-color: #1e40af;
}

body.dark-mode .text-blue-800,
body.dark-mode .text-blue-900 {
    color: #93c5fd;
    /* blue-300 */
}

/* Red Variants */
body.dark-mode .bg-red-50,
body.dark-mode .bg-red-100 {
    background-color: #7f1d1d;
    /* red-900 */
    color: #fee2e2;
    /* red-100 */
    border-color: #991b1b;
}

body.dark-mode .text-red-800,
body.dark-mode .text-red-900 {
    color: #fca5a5;
    /* red-300 */
}

/* Specific Border Overrides */
body.dark-mode .border-gray-200 {
    border-color: #374151;
    /* gray-700 */
}

/* Gradient Overrides for Postulats */
body.dark-mode .from-indigo-50 {
    --tw-gradient-from: #312e81;
    /* indigo-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-purple-50 {
    --tw-gradient-from: #581c87;
    /* purple-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-blue-50 {
    --tw-gradient-from: #1e3a8a;
    /* blue-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-green-50 {
    --tw-gradient-from: #14532d;
    /* green-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

/* Indigo Variants */
body.dark-mode .text-indigo-800,
body.dark-mode .text-indigo-900 {
    color: #a5b4fc;
    /* indigo-300 */
}

/* Purple Variants */
body.dark-mode .text-purple-800,
body.dark-mode .text-purple-900 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Green Variants */
body.dark-mode .text-green-800,
body.dark-mode .text-green-900 {
    color: #86efac;
    /* green-300 */
}

/* Pink Variants */
body.dark-mode .bg-pink-50,
body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #27272a;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.dark-mode .bg-gray-100 {
    background-color: #374151;
    /* gray-700 */
    color: #f3f4f6;
}

body.dark-mode .bg-gray-200 {
    background-color: #4b5563;
    /* gray-600 */
    color: #f3f4f6;
}

body.dark-mode .hover\:bg-gray-200:hover {
    background-color: #4b5563;
    /* gray-600 */
}

/* Fix for specific text colors in dark mode if needed */
body.dark-mode .text-pink-700 {
    color: #f9a8d4;
    /* pink-300 */
}

body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
}

/* Dark Mode Inputs */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

/* Purple Variants */
body.dark-mode .bg-purple-50,
body.dark-mode .bg-purple-100 {
    background-color: #581c87;
    /* purple-900 */
    color: #e9d5ff;
    /* purple-100 */
    border-color: #6b21a8;
}

body.dark-mode .text-purple-700 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Orange Variants */
body.dark-mode .bg-orange-50,
body.dark-mode .bg-orange-100 {
    background-color: #7c2d12;
    /* orange-900 */
    color: #ffedd5;
    /* orange-100 */
    border-color: #9a3412;
}

body.dark-mode .text-orange-700 {
    color: #fdba74;
    /* orange-300 */
}

/* Green Variants (if used) */
body.dark-mode .bg-green-50,
body.dark-mode .bg-green-100 {
    background-color: #14532d;
    /* green-900 */
    color: #dcfce7;
    /* green-100 */
    border-color: #166534;
}

body.dark-mode .text-green-700 {
    color: #86efac;
    /* green-300 */
}

/* Gradient Overrides */
body.dark-mode .from-gray-50 {
    --tw-gradient-from: #18181b;
    /* gray-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .to-white {
    --tw-gradient-to: #27272a;
    /* gray-800 */
}

/* Blue Variants */
body.dark-mode .bg-blue-50,
body.dark-mode .bg-blue-100 {
    background-color: #1e3a8a;
    /* blue-900 */
    color: #dbeafe;
    /* blue-100 */
    border-color: #1e40af;
}

body.dark-mode .text-blue-800,
body.dark-mode .text-blue-900 {
    color: #93c5fd;
    /* blue-300 */
}

/* Red Variants */
body.dark-mode .bg-red-50,
body.dark-mode .bg-red-100 {
    background-color: #7f1d1d;
    /* red-900 */
    color: #fee2e2;
    /* red-100 */
    border-color: #991b1b;
}

body.dark-mode .text-red-800,
body.dark-mode .text-red-900 {
    color: #fca5a5;
    /* red-300 */
}

/* Specific Border Overrides */
body.dark-mode .border-gray-200 {
    border-color: #374151;
    /* gray-700 */
}

/* Gradient Overrides for Postulats */
body.dark-mode .from-indigo-50 {
    --tw-gradient-from: #312e81;
    /* indigo-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-purple-50 {
    --tw-gradient-from: #581c87;
    /* purple-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-blue-50 {
    --tw-gradient-from: #1e3a8a;
    /* blue-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-green-50 {
    --tw-gradient-from: #14532d;
    /* green-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

/* Indigo Variants */
body.dark-mode .text-indigo-800,
body.dark-mode .text-indigo-900 {
    color: #a5b4fc;
    /* indigo-300 */
}

/* Purple Variants */
body.dark-mode .text-purple-800,
body.dark-mode .text-purple-900 {
    color: #d8b4fe;
    /* purple-300 */
}

/* Green Variants */
body.dark-mode .text-green-800,
body.dark-mode .text-green-900 {
    color: #86efac;
    /* green-300 */
}

/* Pink Variants */
body.dark-mode .bg-pink-50,
body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
    border-color: #9d174d;
}

body.dark-mode .text-pink-600,
body.dark-mode .text-pink-800,
body.dark-mode .text-pink-900 {
    color: #f9a8d4;
    /* pink-300 */
}


/* Teal Variants */
body.dark-mode .bg-teal-50,
body.dark-mode .bg-teal-100 {
    background-color: #134e4a;
    /* teal-900 */
    color: #ccfbf1;
    /* teal-100 */
    border-color: #115e59;
}

body.dark-mode .text-teal-700,
body.dark-mode .text-teal-800,
body.dark-mode .text-teal-900 {
    color: #5eead4;
    /* teal-300 */
}

body.dark-mode .from-teal-50 {
    --tw-gradient-from: #134e4a;
    /* teal-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

/* Yellow Variants */
body.dark-mode .bg-yellow-50,
body.dark-mode .bg-yellow-100 {
    background-color: #713f12;
    /* yellow-900 */
    color: #fef9c3;
    /* yellow-100 */
    border-color: #854d0e;
}

body.dark-mode .text-yellow-700,
body.dark-mode .text-yellow-800,
body.dark-mode .text-yellow-900 {
    color: #fde047;
    /* yellow-300 */
}

/* Cyan Variants */
body.dark-mode .bg-cyan-50,
body.dark-mode .bg-cyan-100 {
    background-color: #164e63;
    /* cyan-900 */
    color: #cffafe;
    /* cyan-100 */
    border-color: #155e75;
}

body.dark-mode .text-cyan-700,
body.dark-mode .text-cyan-800,
body.dark-mode .text-cyan-900 {
    color: #67e8f9;
    /* cyan-300 */
}

/* Emerald Variants */
body.dark-mode .bg-emerald-50,
body.dark-mode .bg-emerald-100 {
    background-color: #064e3b;
    /* emerald-900 */
    color: #d1fae5;
    /* emerald-100 */
    border-color: #065f46;
}

body.dark-mode .text-emerald-700,
body.dark-mode .text-emerald-800,
body.dark-mode .text-emerald-900 {
    color: #6ee7b7;
    /* emerald-300 */
}

/* Amber Variants */
body.dark-mode .bg-amber-50,
body.dark-mode .bg-amber-100 {
    background-color: #78350f;
    /* amber-900 */
    color: #fef3c7;
    /* amber-100 */
    border-color: #92400e;
}

body.dark-mode .text-amber-700,
body.dark-mode .text-amber-800,
body.dark-mode .text-amber-900 {
    color: #fcd34d;
    /* amber-300 */
}

/* Fuchsia Variants */
body.dark-mode .bg-fuchsia-50,
body.dark-mode .bg-fuchsia-100 {
    background-color: #701a75;
    /* fuchsia-900 */
    color: #fae8ff;
    /* fuchsia-100 */
    border-color: #86198f;
}

body.dark-mode .text-fuchsia-700,
body.dark-mode .text-fuchsia-800,
body.dark-mode .text-fuchsia-900 {
    color: #f0abfc;
    /* fuchsia-300 */
}

/* Rose Variants */
body.dark-mode .bg-rose-50,
body.dark-mode .bg-rose-100 {
    background-color: #881337;
    /* rose-900 */
    color: #ffe4e6;
    /* rose-100 */
    border-color: #9f1239;
}

body.dark-mode .text-rose-700,
body.dark-mode .text-rose-800,
body.dark-mode .text-rose-900 {
    color: #fda4af;
    /* rose-300 */
}

/* Violet Variants */
body.dark-mode .bg-violet-50,
body.dark-mode .bg-violet-100 {
    background-color: #4c1d95;
    /* violet-900 */
    color: #ede9fe;
    /* violet-100 */
    border-color: #5b21b6;
}

body.dark-mode .text-violet-700,
body.dark-mode .text-violet-800,
body.dark-mode .text-violet-900 {
    color: #c4b5fd;
    /* violet-300 */
}

/* Sky Variants */
body.dark-mode .bg-sky-50,
body.dark-mode .bg-sky-100 {
    background-color: #0c4a6e;
    /* sky-900 */
    color: #e0f2fe;
    /* sky-100 */
    border-color: #075985;
}

body.dark-mode .text-sky-700,
body.dark-mode .text-sky-800,
body.dark-mode .text-sky-900 {
    color: #7dd3fc;
    /* sky-300 */
}

/* Lime Variants */
body.dark-mode .bg-lime-50,
body.dark-mode .bg-lime-100 {
    background-color: #365314;
    /* lime-900 */
    color: #ecfccb;
    /* lime-100 */
    border-color: #3f6212;
    /* purple-300 */
}

/* Green Variants */
body.dark-mode .text-green-800,
body.dark-mode .text-green-900 {
    color: #86efac;
    /* green-300 */
}

/* Pink Variants */
body.dark-mode .bg-pink-50,
body.dark-mode .bg-pink-100 {
    background-color: #831843;
    /* pink-900 */
    color: #fbcfe8;
    /* pink-100 */
    border-color: #9d174d;
}

body.dark-mode .text-pink-600,
body.dark-mode .text-pink-800,
body.dark-mode .text-pink-900 {
    color: #f9a8d4;
    /* pink-300 */
}


/* Teal Variants */
body.dark-mode .bg-teal-50,
body.dark-mode .bg-teal-100 {
    background-color: #134e4a;
    /* teal-900 */
    color: #ccfbf1;
    /* teal-100 */
    border-color: #115e59;
}

body.dark-mode .text-teal-700,
body.dark-mode .text-teal-800,
body.dark-mode .text-teal-900 {
    color: #5eead4;
    /* teal-300 */
}

body.dark-mode .from-teal-50 {
    --tw-gradient-from: #134e4a;
    /* teal-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

/* Yellow Variants */
body.dark-mode .bg-yellow-50,
body.dark-mode .bg-yellow-100 {
    background-color: #713f12;
    /* yellow-900 */
    color: #fef9c3;
    /* yellow-100 */
    border-color: #854d0e;
}

body.dark-mode .text-yellow-700,
body.dark-mode .text-yellow-800,
body.dark-mode .text-yellow-900 {
    color: #fde047;
    /* yellow-300 */
}

/* Cyan Variants */
body.dark-mode .bg-cyan-50,
body.dark-mode .bg-cyan-100 {
    background-color: #164e63;
    /* cyan-900 */
    color: #cffafe;
    /* cyan-100 */
    border-color: #155e75;
}

body.dark-mode .text-cyan-700,
body.dark-mode .text-cyan-800,
body.dark-mode .text-cyan-900 {
    color: #67e8f9;
    /* cyan-300 */
}

/* Emerald Variants */
body.dark-mode .bg-emerald-50,
body.dark-mode .bg-emerald-100 {
    background-color: #064e3b;
    /* emerald-900 */
    color: #d1fae5;
    /* emerald-100 */
    border-color: #065f46;
}

body.dark-mode .text-emerald-700,
body.dark-mode .text-emerald-800,
body.dark-mode .text-emerald-900 {
    color: #6ee7b7;
    /* emerald-300 */
}

/* Amber Variants */
body.dark-mode .bg-amber-50,
body.dark-mode .bg-amber-100 {
    background-color: #78350f;
    /* amber-900 */
    color: #fef3c7;
    /* amber-100 */
    border-color: #92400e;
}

body.dark-mode .text-amber-700,
body.dark-mode .text-amber-800,
body.dark-mode .text-amber-900 {
    color: #fcd34d;
    /* amber-300 */
}

/* Fuchsia Variants */
body.dark-mode .bg-fuchsia-50,
body.dark-mode .bg-fuchsia-100 {
    background-color: #701a75;
    /* fuchsia-900 */
    color: #fae8ff;
    /* fuchsia-100 */
    border-color: #86198f;
}

body.dark-mode .text-fuchsia-700,
body.dark-mode .text-fuchsia-800,
body.dark-mode .text-fuchsia-900 {
    color: #f0abfc;
    /* fuchsia-300 */
}

/* Rose Variants */
body.dark-mode .bg-rose-50,
body.dark-mode .bg-rose-100 {
    background-color: #881337;
    /* rose-900 */
    color: #ffe4e6;
    /* rose-100 */
    border-color: #9f1239;
}

body.dark-mode .text-rose-700,
body.dark-mode .text-rose-800,
body.dark-mode .text-rose-900 {
    color: #fda4af;
    /* rose-300 */
}

/* Violet Variants */
body.dark-mode .bg-violet-50,
body.dark-mode .bg-violet-100 {
    background-color: #4c1d95;
    /* violet-900 */
    color: #ede9fe;
    /* violet-100 */
    border-color: #5b21b6;
}

body.dark-mode .text-violet-700,
body.dark-mode .text-violet-800,
body.dark-mode .text-violet-900 {
    color: #c4b5fd;
    /* violet-300 */
}

/* Sky Variants */
body.dark-mode .bg-sky-50,
body.dark-mode .bg-sky-100 {
    background-color: #0c4a6e;
    /* sky-900 */
    color: #e0f2fe;
    /* sky-100 */
    border-color: #075985;
}

body.dark-mode .text-sky-700,
body.dark-mode .text-sky-800,
body.dark-mode .text-sky-900 {
    color: #7dd3fc;
    /* sky-300 */
}

/* Lime Variants */
body.dark-mode .bg-lime-50,
body.dark-mode .bg-lime-100 {
    background-color: #365314;
    /* lime-900 */
    color: #ecfccb;
    /* lime-100 */
    border-color: #3f6212;
}

body.dark-mode .text-lime-700,
body.dark-mode .text-lime-800,
body.dark-mode .text-lime-900 {
    color: #bef264;
    /* lime-300 */
}

/* Missing Gradient Overrides */
body.dark-mode .from-yellow-50 {
    --tw-gradient-from: #713f12;
    /* yellow-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-red-50 {
    --tw-gradient-from: #7f1d1d;
    /* red-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-orange-50 {
    --tw-gradient-from: #7c2d12;
    /* orange-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-pink-50 {
    --tw-gradient-from: #831843;
    /* pink-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-cyan-50 {
    --tw-gradient-from: #164e63;
    /* cyan-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-emerald-50 {
    --tw-gradient-from: #064e3b;
    /* emerald-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-lime-50 {
    --tw-gradient-from: #365314;
    /* lime-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-amber-50 {
    --tw-gradient-from: #78350f;
    /* amber-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-fuchsia-50 {
    --tw-gradient-from: #701a75;
    /* fuchsia-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-rose-50 {
    --tw-gradient-from: #881337;
    /* rose-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-violet-50 {
    --tw-gradient-from: #4c1d95;
    /* violet-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}

body.dark-mode .from-sky-50 {
    --tw-gradient-from: #0c4a6e;
    /* sky-900 */
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
/* ==========================================
   Pedagogy + Interactive Visibility Overrides
   ========================================== */
body.dark-mode canvas {
    filter: none !important;
}

#content-area .dma-interactive-panel {
    background: radial-gradient(circle at top left, #18181b 0%, #121214 60%, #0e0e10 100%) !important;
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35), 0 10px 24px rgba(2, 6, 23, 0.25);
}

#content-area .dma-viz-host {
    position: relative;
    min-height: 220px;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: linear-gradient(160deg, #0e0e10 0%, #1a1a1e 100%);
    overflow: hidden;
}

#content-area .dma-viz-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 0.6rem;
    background: linear-gradient(160deg, #0e0e10 0%, #1a1a1e 100%);
}

#content-area .dma-toolkit-card {
    position: relative;
    overflow: hidden;
}

#content-area .dma-toolkit-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.12), transparent 45%);
}

#content-area .dma-toolkit-card mjx-container {
    color: inherit !important;
}

body.dark-mode #content-area .dma-toolkit-card {
    border-color: rgba(99, 102, 241, 0.35);
}

body.dark-mode #content-area .dma-viz-host,
body.dark-mode #content-area .dma-viz-canvas {
    border-color: rgba(125, 211, 252, 0.2);
    background: linear-gradient(160deg, #0e0e10 0%, #18181b 100%);
}
#content-area .dma-viz-host canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0.6rem;
    background: linear-gradient(160deg, #0e0e10 0%, #1a1a1e 100%);
}

/* ==========================================
   Global Search + Latex Eye UX
   ========================================== */
#globalSearchInput::-webkit-search-cancel-button {
    display: none;
}

#nav-container .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dma-latex-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 0.55rem;
    padding: 0.2rem 0.35rem;
    transition: background-color 0.2s ease;
}

.dma-latex-wrap.dma-latex-display {
    display: flex;
    width: 100%;
    justify-content: center;
    margin: 0.35rem 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(99, 102, 241, 0.22);
    background: rgba(238, 242, 255, 0.45);
}

.dma-latex-wrap .dma-latex-render {
    min-width: 0;
}

.dma-latex-wrap .dma-latex-eye {
    border: 0;
    border-radius: 0.45rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.85rem;
    line-height: 1;
    color: #4338ca;
    background: rgba(99, 102, 241, 0.15);
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    cursor: pointer;
}

.dma-latex-wrap.is-hover .dma-latex-eye,
.dma-latex-wrap:hover .dma-latex-eye,
.dma-latex-wrap.is-open .dma-latex-eye,
.dma-latex-wrap:focus-within .dma-latex-eye {
    opacity: 1;
    transform: translateY(0);
}

.dma-latex-wrap .dma-latex-eye:hover {
    background: rgba(99, 102, 241, 0.24);
}

.dma-latex-wrap .dma-latex-source {
    position: absolute;
    right: 0.2rem;
    bottom: calc(100% + 0.25rem);
    max-width: min(85vw, 560px);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 0.6rem;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: #ffffff;
    color: #1e1b4b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.35;
    padding: 0.5rem 0.6rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 30;
}

.dma-latex-wrap.is-open .dma-latex-source,
.dma-latex-wrap:focus-within .dma-latex-source {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

body.dark-mode .dma-latex-wrap.dma-latex-display {
    border-color: rgba(129, 140, 248, 0.45);
    background: rgba(30, 41, 59, 0.7);
}

body.dark-mode .dma-latex-wrap .dma-latex-eye {
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.35);
}

body.dark-mode .dma-latex-wrap .dma-latex-eye:hover {
    background: rgba(129, 140, 248, 0.45);
}

body.dark-mode .dma-latex-wrap .dma-latex-source {
    border-color: rgba(129, 140, 248, 0.5);
    background: #1a1a1e;
    color: #e2e8f0;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.55);
}

body.dark-mode #content-area .dma-interactive-panel {
    color: #e2e8f0;
}

body.dark-mode #content-area .dma-interactive-panel h3,
body.dark-mode #content-area .dma-interactive-panel h4,
body.dark-mode #content-area .dma-interactive-panel p,
body.dark-mode #content-area .dma-interactive-panel label,
body.dark-mode #content-area .dma-interactive-panel span,
body.dark-mode #content-area .dma-interactive-panel div {
    color: inherit;
}

body.dark-mode #globalSearchInput {
    background-color: rgba(2, 6, 23, 0.8);
    border-color: rgba(129, 140, 248, 0.5);
}

/* ==========================================
   Global Dark-Mode Readability Lock
   ========================================== */
body.dark-mode #content-area {
    color: #dbe7ff !important;
}

body.dark-mode #content-area h1,
body.dark-mode #content-area h2,
body.dark-mode #content-area h3,
body.dark-mode #content-area h4,
body.dark-mode #content-area h5,
body.dark-mode #content-area h6 {
    color: #f8fbff !important;
}

body.dark-mode #content-area p,
body.dark-mode #content-area li,
body.dark-mode #content-area label,
body.dark-mode #content-area dt,
body.dark-mode #content-area dd,
body.dark-mode #content-area small,
body.dark-mode #content-area span,
body.dark-mode #content-area strong,
body.dark-mode #content-area em {
    color: #d5e2ff !important;
}

body.dark-mode #content-area .text-slate-900,
body.dark-mode #content-area .text-slate-800,
body.dark-mode #content-area .text-slate-700,
body.dark-mode #content-area .text-slate-600,
body.dark-mode #content-area .text-slate-500,
body.dark-mode #content-area .text-gray-900,
body.dark-mode #content-area .text-gray-800,
body.dark-mode #content-area .text-gray-700,
body.dark-mode #content-area .text-gray-600,
body.dark-mode #content-area .text-gray-500,
body.dark-mode #content-area .text-indigo-900,
body.dark-mode #content-area .text-indigo-800,
body.dark-mode #content-area .text-indigo-700,
body.dark-mode #content-area .text-cyan-900,
body.dark-mode #content-area .text-cyan-800,
body.dark-mode #content-area .text-cyan-700,
body.dark-mode #content-area .text-emerald-900,
body.dark-mode #content-area .text-emerald-800,
body.dark-mode #content-area .text-amber-900,
body.dark-mode #content-area .text-amber-800,
body.dark-mode #content-area .text-purple-900,
body.dark-mode #content-area .text-purple-800,
body.dark-mode #content-area .text-blue-900,
body.dark-mode #content-area .text-blue-800,
body.dark-mode #content-area .text-rose-900,
body.dark-mode #content-area .text-rose-800 {
    color: #e3eeff !important;
}

body.dark-mode #content-area .bg-white,
body.dark-mode #content-area .bg-gray-50,
body.dark-mode #content-area .bg-gray-100,
body.dark-mode #content-area .bg-slate-50,
body.dark-mode #content-area .bg-slate-100,
body.dark-mode #content-area .bg-indigo-50,
body.dark-mode #content-area .bg-indigo-100,
body.dark-mode #content-area .bg-cyan-50,
body.dark-mode #content-area .bg-cyan-100,
body.dark-mode #content-area .bg-blue-50,
body.dark-mode #content-area .bg-blue-100,
body.dark-mode #content-area .bg-emerald-50,
body.dark-mode #content-area .bg-emerald-100,
body.dark-mode #content-area .bg-amber-50,
body.dark-mode #content-area .bg-amber-100,
body.dark-mode #content-area .bg-violet-50,
body.dark-mode #content-area .bg-violet-100,
body.dark-mode #content-area .bg-fuchsia-50,
body.dark-mode #content-area .bg-fuchsia-100,
body.dark-mode #content-area .bg-rose-50,
body.dark-mode #content-area .bg-rose-100,
body.dark-mode #content-area .bg-teal-50,
body.dark-mode #content-area .bg-teal-100,
body.dark-mode #content-area .bg-lime-50,
body.dark-mode #content-area .bg-lime-100,
body.dark-mode #content-area .bg-yellow-50,
body.dark-mode #content-area .bg-yellow-100 {
    background: #212126 !important;
}

body.dark-mode #content-area .border-gray-100,
body.dark-mode #content-area .border-gray-200,
body.dark-mode #content-area .border-slate-200,
body.dark-mode #content-area .border-indigo-100,
body.dark-mode #content-area .border-indigo-200,
body.dark-mode #content-area .border-cyan-100,
body.dark-mode #content-area .border-cyan-200,
body.dark-mode #content-area .border-emerald-100,
body.dark-mode #content-area .border-emerald-200,
body.dark-mode #content-area .border-amber-100,
body.dark-mode #content-area .border-amber-200 {
    border-color: rgba(148, 163, 184, 0.45) !important;
}

body.dark-mode #content-area .bg-gray-900,
body.dark-mode #content-area .bg-slate-900,
body.dark-mode #content-area .bg-black {
    border-color: rgba(148, 163, 184, 0.35) !important;
}

body.dark-mode #content-area input,
body.dark-mode #content-area select,
body.dark-mode #content-area textarea {
    background: #141417 !important;
    color: #f8fbff !important;
    border-color: rgba(129, 140, 248, 0.55) !important;
}

body.dark-mode #content-area option {
    background: #141417;
    color: #f8fbff;
}

body.dark-mode #content-area code,
body.dark-mode #content-area pre {
    color: #e2f0ff !important;
}

body.dark-mode #content-area .dma-latex-wrap .dma-latex-render,
body.dark-mode #content-area mjx-container {
    color: #eef5ff !important;
}

body.dark-mode #content-area .dma-viz-host,
body.dark-mode #content-area canvas {
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.28) inset;
}

body.dark-mode #content-area canvas {
    filter: brightness(1.08) contrast(1.08) saturate(1.06) !important;
}

body.dark-mode #content-area button,
body.dark-mode #content-area .btn,
body.dark-mode #content-area [role="button"] {
    color: #f8fbff !important;
}

body.dark-mode #content-area a {
    color: #7dd3fc !important;
}

/* Fix: bg-white opacity variants not caught by .bg-white */
body.dark-mode #content-area [class*="bg-white\/"] {
    background: rgba(21, 34, 56, 0.9) !important;
}

/* Fix: Missing border color overrides */
body.dark-mode #content-area .border-blue-300,
body.dark-mode #content-area .border-green-300,
body.dark-mode #content-area .border-indigo-300,
body.dark-mode #content-area .border-purple-100,
body.dark-mode #content-area .border-purple-200,
body.dark-mode #content-area .border-orange-100,
body.dark-mode #content-area .border-orange-200,
body.dark-mode #content-area .border-violet-200,
body.dark-mode #content-area .border-rose-200,
body.dark-mode #content-area .border-blue-200,
body.dark-mode #content-area .border-teal-200 {
    border-color: rgba(148, 163, 184, 0.45) !important;
}

/* Fix: Preserve semantic colors on spans with explicit color classes */
body.dark-mode #content-area span.text-red-500,
body.dark-mode #content-area span.text-red-600,
body.dark-mode #content-area span.text-blue-500,
body.dark-mode #content-area span.text-blue-600,
body.dark-mode #content-area span.text-green-500,
body.dark-mode #content-area span.text-green-600,
body.dark-mode #content-area span.text-purple-500,
body.dark-mode #content-area span.text-purple-600,
body.dark-mode #content-area span.text-orange-500,
body.dark-mode #content-area span.text-orange-600,
body.dark-mode #content-area span.text-emerald-500,
body.dark-mode #content-area span.text-emerald-600,
body.dark-mode #content-area span.text-cyan-500,
body.dark-mode #content-area span.text-cyan-600,
body.dark-mode #content-area span.text-amber-500,
body.dark-mode #content-area span.text-amber-600,
body.dark-mode #content-area span.text-pink-500,
body.dark-mode #content-area span.text-pink-600,
body.dark-mode #content-area span.text-violet-500,
body.dark-mode #content-area span.text-violet-600,
body.dark-mode #content-area span.text-indigo-500,
body.dark-mode #content-area span.text-indigo-600,
body.dark-mode #content-area span.text-rose-500,
body.dark-mode #content-area span.text-rose-600,
body.dark-mode #content-area span.text-yellow-500,
body.dark-mode #content-area span.text-yellow-600 {
    color: inherit !important;
}

/* Fix: Specific semantic dark-mode color mappings */
body.dark-mode #content-area .text-red-500,
body.dark-mode #content-area .text-red-600 { color: #fca5a5 !important; }
body.dark-mode #content-area .text-blue-500,
body.dark-mode #content-area .text-blue-600 { color: #93c5fd !important; }
body.dark-mode #content-area .text-green-500,
body.dark-mode #content-area .text-green-600 { color: #86efac !important; }
body.dark-mode #content-area .text-purple-500,
body.dark-mode #content-area .text-purple-600 { color: #d8b4fe !important; }
body.dark-mode #content-area .text-orange-500,
body.dark-mode #content-area .text-orange-600 { color: #fdba74 !important; }
body.dark-mode #content-area .text-emerald-500,
body.dark-mode #content-area .text-emerald-600 { color: #6ee7b7 !important; }
body.dark-mode #content-area .text-cyan-500,
body.dark-mode #content-area .text-cyan-600 { color: #67e8f9 !important; }
body.dark-mode #content-area .text-amber-500,
body.dark-mode #content-area .text-amber-600 { color: #fcd34d !important; }
body.dark-mode #content-area .text-pink-500,
body.dark-mode #content-area .text-pink-600 { color: #f9a8d4 !important; }
body.dark-mode #content-area .text-violet-500,
body.dark-mode #content-area .text-violet-600 { color: #c4b5fd !important; }
body.dark-mode #content-area .text-indigo-500,
body.dark-mode #content-area .text-indigo-600 { color: #a5b4fc !important; }
body.dark-mode #content-area .text-rose-500,
body.dark-mode #content-area .text-rose-600 { color: #fda4af !important; }
body.dark-mode #content-area .text-yellow-500,
body.dark-mode #content-area .text-yellow-600 { color: #fde047 !important; }

/* Fix: hover states in dark mode */
body.dark-mode #content-area .hover\:bg-gray-100:hover,
body.dark-mode #content-area .hover\:bg-gray-50:hover {
    background: #2c2c31 !important;
}
body.dark-mode #content-area .hover\:bg-indigo-50:hover {
    background: #312e81 !important;
}

/* ==========================================================
   CARTES CONCEPTS (cours quantum_cards / deep_cards)
   ========================================================== */
.qa-card {
    overflow: hidden;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.qa-card:hover {
    border-color: #a5b4fc;
}

.qa-card-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    cursor: pointer;
    user-select: none;
}

.qa-card-head:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
}

.qa-card-title {
    flex: 1;
    min-width: 0;
}

.qa-glyph {
    flex-shrink: 0;
    min-width: 3.25rem;
    padding: .4rem .6rem;
    border-radius: .6rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.5;
}

.qa-chevron {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 1.1rem;
    transition: transform .25s ease;
}

.qa-card.qa-collapsed .qa-chevron {
    transform: rotate(-90deg);
}

.qa-card-body {
    padding: 0 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.qa-card.qa-collapsed .qa-card-body {
    display: none;
}

#content-area .qa-glyph {
    color: #3730a3 !important;
}

body.dark-mode #content-area .qa-glyph {
    color: #c7d2fe !important;
}

/* ---- dark mode ---- */
body.dark-mode .qa-glyph {
    background: #312e81;
    border-color: #4f46e5;
}

body.dark-mode .qa-card:hover {
    border-color: #6366f1;
}

/* ==========================================================
   LABS INTERACTIFS DES CARTES
   ========================================================== */
.qa-lab {
    background: linear-gradient(180deg, #0B1220, #070C15);
    border: 1px solid rgba(200, 255, 61, .28);
    border-radius: 16px;
    padding: 20px;
    color: #E7EEF7;
}

.qa-lab h3 {
    font-size: 15px;
    font-weight: 600;
    color: #C8FF3D;
    letter-spacing: .03em;
}

.qa-lab h3 span {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px;
    color: #5A6678;
    margin-left: 10px;
    letter-spacing: .12em;
}

.qa-lab .qa-lab-exp {
    color: #8A96A8;
    font-size: 13px;
    margin-top: 6px;
    max-width: 760px;
    line-height: 1.6;
}

.qa-lab-loading {
    color: #5A6678;
    font-size: 13px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.qa-lab-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr);
    gap: 18px;
    margin-top: 16px;
    align-items: start;
}

@media (max-width: 900px) {
    .qa-lab-grid {
        grid-template-columns: 1fr;
    }
}

/* neutralise l'inversion globale des canvas en dark mode */
.qa-lab canvas,
body.dark-mode .qa-lab canvas {
    width: 100%;
    background: #03070C;
    border: 1px solid #16202F;
    border-radius: 10px;
    display: block;
    filter: none;
}

.qa-lab-ctrl {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qa-lab-ctrl label {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    color: #8A96A8;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.qa-lab-ctrl label output {
    color: #C8FF3D;
}

.qa-lab-ctrl input[type=range] {
    width: 100%;
    accent-color: #C8FF3D;
    background: transparent;
    border: 0;
    padding: 0;
}

.qa-lab-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qa-lab-btns button {
    flex: 1 1 auto;
}

.qa-lab-ctrl select,
.qa-lab-ctrl button {
    background: #0B1220;
    color: #E7EEF7;
    border: 1px solid #16202F;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.qa-lab-ctrl button:hover {
    border-color: #C8FF3D;
    color: #C8FF3D;
}

.qa-readout {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    color: #3DE8FF;
    background: #060B12;
    border: 1px solid #16202F;
    border-radius: 8px;
    padding: 10px 12px;
    white-space: pre-line;
    line-height: 1.55;
}

/* ==========================================================
   DERIVEE INTERACTIVE (analysis / derivee_interactive)
   CSS d'origine, integralement scope sous #deriv-lab pour
   ne pas entrer en collision avec les classes de la plateforme.
   ========================================================== */
#deriv-lab {
    --dv-text: #edf3ff;
    --dv-muted: #8fa0b8;
    --dv-curve: #79f2c9;
    --dv-tangent: #ffcf70;
    --dv-secant: #ff7ac8;
    --dv-dx: #7aa8ff;
    --dv-df: #ff8f70;
    --dv-radius: 22px;
    color: var(--dv-text);
}

#deriv-lab * {
    box-sizing: border-box;
}

#deriv-lab .dv-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 16px;
    align-items: stretch;
}

#deriv-lab .dv-stage,
#deriv-lab .dv-side {
    border: 1px solid rgba(255, 255, 255, .1);
    background: linear-gradient(180deg, rgba(17, 23, 34, .96), rgba(7, 10, 15, .96));
    border-radius: var(--dv-radius);
    box-shadow: 0 22px 80px rgba(0, 0, 0, .42);
    overflow: hidden;
    position: relative;
}

#deriv-lab .dv-stage {
    min-width: 0;
    height: 68vh;
    min-height: 460px;
}

/* Le canvas remplit la scene et rien d'autre ne doit y toucher.
   Selecteurs a deux id pour passer devant "#content-area .dma-viz-canvas"
   (classe posee par improveInteractiveVisibility) qui imposerait
   height:auto -- ce qui fait grossir le canvas a chaque resize -- et
   devant "body.dark-mode canvas" qui applique un invert() destructeur. */
#deriv-lab canvas,
#content-area #deriv-lab canvas,
body.dark-mode #content-area #deriv-lab canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    display: block;
    touch-action: none;
    cursor: grab;
    /* !important : "body.dark-mode #content-area canvas" pose lui aussi un
       filter !important, qu'une simple specificite superieure ne suffit pas
       a battre. */
    filter: none !important;
    border: 0;
    border-radius: 0;
    background: transparent;
}

#deriv-lab canvas.dv-dragging {
    cursor: grabbing;
}

#deriv-lab .dv-hud {
    position: absolute;
    left: 18px;
    top: 18px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: rgba(8, 12, 18, .72);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 18px;
    padding: 10px;
    max-width: calc(100% - 36px);
}

#deriv-lab .dv-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    font-size: 13px;
    white-space: nowrap;
}

#deriv-lab .dv-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

#deriv-lab .dv-dot.dv-curve { background: var(--dv-curve); }
#deriv-lab .dv-dot.dv-tangent { background: var(--dv-tangent); }
#deriv-lab .dv-dot.dv-secant { background: var(--dv-secant); }
#deriv-lab .dv-dot.dv-dx { background: var(--dv-dx); }
#deriv-lab .dv-dot.dv-df { background: var(--dv-df); }

#deriv-lab .dv-hint {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 2;
    background: rgba(8, 12, 18, .72);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 18px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.35;
    max-width: 680px;
}

#deriv-lab .dv-side {
    padding: 16px;
    overflow: auto;
    max-height: 68vh;
}

#deriv-lab .dv-title {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    margin: 2px 0 6px;
    letter-spacing: -.03em;
}

#deriv-lab .dv-subtitle {
    font-size: 13px;
    line-height: 1.38;
    margin-bottom: 16px;
}

#deriv-lab .dv-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 18px;
    padding: 14px;
    margin: 12px 0;
}

#deriv-lab label {
    font-size: 12px;
    display: block;
    margin-bottom: 7px;
}

#deriv-lab select,
#deriv-lab input[type="range"],
#deriv-lab button {
    width: 100%;
}

#deriv-lab select,
#deriv-lab button {
    border: 1px solid rgba(255, 255, 255, .12);
    background: #0b111a;
    color: var(--dv-text);
    border-radius: 13px;
    padding: 11px 12px;
    font-size: 14px;
}

#deriv-lab button {
    cursor: pointer;
    transition: .15s transform, .15s background;
}

#deriv-lab button:hover { background: #121b29; }
#deriv-lab button:active { transform: scale(.98); }
#deriv-lab input[type="range"] { accent-color: #79f2c9; background: transparent; border: 0; padding: 0; }

#deriv-lab .dv-row {
    display: grid;
    grid-template-columns: 1fr 86px;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
}

#deriv-lab .dv-value {
    font-variant-numeric: tabular-nums;
    background: rgba(0, 0, 0, .28);
    border: 1px solid rgba(255, 255, 255, .08);
    padding: 9px 10px;
    border-radius: 12px;
    text-align: right;
    font-size: 13px;
}

#deriv-lab .dv-math {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}

#deriv-lab .dv-big {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.04em;
    margin-top: 4px;
}

#deriv-lab .dv-equation {
    border-left: 3px solid var(--dv-curve);
    padding-left: 12px;
}

#deriv-lab .dv-equation.dv-der { border-left-color: var(--dv-tangent); }
#deriv-lab .dv-equation.dv-diff { border-left-color: var(--dv-dx); }

#deriv-lab .dv-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#deriv-lab .dv-metric {
    padding: 12px;
    background: rgba(0, 0, 0, .22);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 15px;
}

#deriv-lab .dv-metric b {
    display: block;
    font-size: 11px;
    margin-bottom: 5px;
    font-weight: 600;
}

#deriv-lab .dv-metric span {
    font-variant-numeric: tabular-nums;
    font-size: 18px;
    font-weight: 800;
}

#deriv-lab .dv-mini {
    font-size: 12px;
    line-height: 1.35;
}

#deriv-lab .dv-callout {
    background: linear-gradient(135deg, rgba(121, 242, 201, .12), rgba(255, 207, 112, .09));
    border: 1px solid rgba(121, 242, 201, .20);
    border-radius: 18px;
    padding: 13px;
    font-size: 13px;
    line-height: 1.42;
}

/* Teintes secondaires : selecteurs assez specifiques pour passer devant
   le "color: ... !important" global du dark mode. */
#deriv-lab .dv-subtitle,
#deriv-lab .dv-mini,
#deriv-lab .dv-hint,
#deriv-lab label,
#deriv-lab .dv-metric b,
body.dark-mode #content-area #deriv-lab .dv-subtitle,
body.dark-mode #content-area #deriv-lab .dv-mini,
body.dark-mode #content-area #deriv-lab .dv-hint,
body.dark-mode #content-area #deriv-lab label,
body.dark-mode #content-area #deriv-lab .dv-metric b {
    color: var(--dv-muted);
}

@media (max-width: 920px) {
    #deriv-lab .dv-app {
        grid-template-columns: 1fr;
    }

    #deriv-lab .dv-stage {
        height: 58vh;
        min-height: 380px;
    }

    #deriv-lab .dv-side {
        max-height: none;
        overflow: visible;
    }

    #deriv-lab .dv-hud {
        left: 10px;
        top: 10px;
        max-width: calc(100% - 20px);
        gap: 6px;
        padding: 7px;
    }

    #deriv-lab .dv-pill {
        font-size: 11px;
        padding: 6px 8px;
    }

    #deriv-lab .dv-hint {
        left: 10px;
        bottom: 10px;
        max-width: calc(100% - 20px);
        font-size: 12px;
    }
}

/* ==========================================================
   LOGO : cerveau / reseau de neurones anime (SVG + CSS)
   Taille pilotee par font-size : l'icone vaut 1.15em.
   ========================================================== */
.dma-brain {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    overflow: visible;
    color: #e4e4e7;
    --dma-brain-signal: #22d3ee;
    --dma-brain-node: #5eead4;
}

/* les deux hemispheres : trace continu qui respire */
.dma-brain-lobes path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .55;
    animation: dma-brain-breathe 4.5s ease-in-out infinite;
}

.dma-brain-lobes path:nth-child(2) {
    animation-delay: -2.25s;
}

/* les synapses : un signal parcourt les connexions */
.dma-brain-synapses {
    fill: none;
    stroke: var(--dma-brain-signal);
    stroke-width: 1.1;
    stroke-linecap: round;
    stroke-dasharray: 3 7;
    opacity: .8;
    animation: dma-brain-fire 2.4s linear infinite;
}

/* les neurones : pulsation decalee de proche en proche */
.dma-brain-nodes circle {
    fill: var(--dma-brain-node);
    transform-box: fill-box;
    transform-origin: center;
    animation: dma-brain-pulse 2.4s ease-in-out infinite;
}

.dma-brain-nodes circle:nth-child(1) { animation-delay: 0s; }
.dma-brain-nodes circle:nth-child(2) { animation-delay: .3s; }
.dma-brain-nodes circle:nth-child(3) { animation-delay: .3s; }
.dma-brain-nodes circle:nth-child(4) { animation-delay: .6s; }
.dma-brain-nodes circle:nth-child(5) { animation-delay: .6s; }
.dma-brain-nodes circle:nth-child(6) { animation-delay: .9s; }

@keyframes dma-brain-breathe {
    0%, 100% { opacity: .40; }
    50%      { opacity: .85; }
}

@keyframes dma-brain-fire {
    from { stroke-dashoffset: 20; }
    to   { stroke-dashoffset: 0; }
}

@keyframes dma-brain-pulse {
    0%, 100% { transform: scale(.75); opacity: .45; }
    45%      { transform: scale(1.15); opacity: 1; }
}

/* version ecran d'accueil : plus grande et halo lumineux */
.dma-brain-hero {
    width: 8rem;
    height: 8rem;
    filter: drop-shadow(0 0 18px rgba(34, 211, 238, .35));
}

@media (min-width: 768px) {
    .dma-brain-hero {
        width: 11rem;
        height: 11rem;
    }
}

.dma-brain-hero .dma-brain-lobes path { stroke-width: 1.3; }
.dma-brain-hero .dma-brain-synapses { stroke-width: .9; }

/* accessibilite : on fige tout si l'utilisateur refuse les animations */
@media (prefers-reduced-motion: reduce) {
    .dma-brain-lobes path,
    .dma-brain-synapses,
    .dma-brain-nodes circle {
        animation: none;
    }
    .dma-brain-lobes path { opacity: .7; }
    .dma-brain-nodes circle { transform: scale(1); opacity: 1; }
}

/* Le canvas de particules couvre tout l'ecran d'accueil : il doit rester
   transparent, sinon le "background: #1a1a1e" de la regle globale
   "body.dark-mode canvas" repeint le fond en bleu nuit par-dessus. */
#home-bg-canvas,
body.dark-mode #home-bg-canvas {
    background: transparent;
    filter: none;
}
