:root {
            /* Light Theme (Default) */
            --bg-color: #f8f9fa;
            --card-bg: #ffffff;
            --card-border: rgba(0, 0, 0, 0.08);
            --text-color: #1e293b;
            --primary-accent: #6854c7;
            --terminal-bg: #0f1419;
            --code-bg: #ffffff;
            --toolbar-bg: #f1f5f9;
            --accent-glow: rgba(104, 84, 199, 0.15);
        }

        html.dark-theme {
            /* Dark Theme */
            --bg-color: #0d0e12;
            --card-bg: #15161e;
            --card-border: rgba(255, 255, 255, 0.08);
            --text-color: #f1f5f9;
            --primary-accent: #8f7ce0;
            --terminal-bg: #090a0f;
            --code-bg: #15161e;
            --toolbar-bg: #1a1b26;
            --accent-glow: rgba(143, 124, 224, 0.25);
        }

        body {
            background-color: var(--bg-color) !important;
            color: var(--text-color) !important;
            font-family: 'Outfit', sans-serif;
            height: 100vh;
            margin: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .visualizer-navbar {
            background-color: var(--card-bg);
            border-bottom: 1px solid var(--card-border);
            padding: 5px 14px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 40px;
            gap: 12px;
        }

        .visualizer-title {
            font-size: 0.92rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 7px;
            flex: 0 0 auto;
        }

        .visualizer-title i {
            color: var(--primary-accent);
        }

        .program-title-strip {
            flex: 1 1 auto;
            min-width: 0;
            color: #475569;
            font-size: 0.78rem;
            font-weight: 600;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .main-workspace {
            display: flex;
            flex: 1;
            overflow: hidden;
            min-height: 0;
        }

        .code-panel {
            width: 60%;
            border-right: 1px solid var(--card-border);
            padding: 10px 20px 12px;
            background-color: var(--bg-color);
            display: flex;
            flex-direction: column;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        .viz-panel {
            width: 40%;
            display: flex;
            flex-direction: column;
            padding: 10px 20px 12px;
            background-color: var(--card-bg);
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        .panel-title {
            flex: 0 0 auto;
            margin: 0 0 8px !important;
            font-size: 0.95rem;
            font-weight: 600;
            line-height: 1.2;
            color: #64748b;
        }

        .console-title {
            position: relative;
            display: flex;
            align-items: center;
            min-height: 20px;
        }

        .console-brand {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            font-family: "Outfit", Arial, sans-serif;
            font-size: 1.05rem;
            font-weight: 800;
            letter-spacing: 0;
            white-space: nowrap;
        }

        .console-brand .brand-vignaan {
            color: #0d6efd;
        }

        .console-brand .brand-kosh {
            color: #dc3545;
        }

        .console-brand .brand-dotcom {
            color: #0d6efd;
        }

        .console-mobile-meta {
            display: none;
        }

        .code-container {
            background-color: var(--code-bg);
            border: 1px solid var(--card-border);
            border-radius: 8px;
            padding: 7px 12px;
            position: relative;
            flex: 1 1 auto;
            min-height: 0 !important;
            overflow: auto !important;
            overscroll-behavior: contain;
            scrollbar-gutter: stable;
            scrollbar-width: thin;
        }

        .code-container::-webkit-scrollbar,
        .console-container::-webkit-scrollbar,
        #sample-output-box::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }

        .code-container::-webkit-scrollbar-track,
        .console-container::-webkit-scrollbar-track,
        #sample-output-box::-webkit-scrollbar-track {
            background: rgba(148, 163, 184, 0.16);
            border-radius: 8px;
        }

        .code-container::-webkit-scrollbar-thumb,
        .console-container::-webkit-scrollbar-thumb,
        #sample-output-box::-webkit-scrollbar-thumb {
            background: rgba(100, 116, 139, 0.75);
            border-radius: 8px;
        }

        pre {
            margin: 0;
            padding: 0;
            background: transparent !important;
            border: none !important;
        }

        code {
            font-family: 'Fira Code', 'Courier New', Courier, monospace !important;
            font-size: 0.9rem;
            line-height: 1.35 !important; /* Tight line height to reduce vertical gaps */
            color: var(--text-color) !important;
        }

        /* Line Highlighting & Inline Comments */
        .code-line {
            display: block;
            width: 100%;
            padding-left: 8px;
            padding-right: 8px;
            padding-top: 2px;
            padding-bottom: 2px;
            margin: 0;
            border-left: 3px solid transparent;
            transition: all 0.2s ease;
            line-height: 1.35 !important;
            font-family: 'Fira Code', monospace;
            font-size: 0.9rem;
            position: relative;
        }

        .code-line.indent-1 { padding-left: 30px; }
        .code-line.indent-2 { padding-left: 52px; }
        .code-line.indent-3 { padding-left: 74px; }
        .code-line.indent-4 { padding-left: 96px; }
        .code-line.indent-5 { padding-left: 118px; }
        .code-line.indent-6 { padding-left: 140px; }
        .code-line.indent-7 { padding-left: 162px; }
        .code-line.indent-8 { padding-left: 184px; }

        .code-line.highlighted-exec {
            background: #fff7cc !important;
            border-left-color: #f59e0b !important;
            box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.65);
            color: #111827 !important;
            font-weight: 700;
        }

        .code-line.highlighted-exec::before {
            content: ">";
            position: absolute;
            left: 2px;
            top: 50%;
            transform: translateY(-50%);
            color: #f59e0b;
            font-size: 0.85rem;
            font-weight: 900;
        }

        .code-line.highlighted-exec .code-text {
            color: #111827 !important;
        }

        .code-line .code-text {
            color: #111827 !important;
            font-weight: 500;
        }

        html.dark-theme .code-line .code-text {
            color: #f8fafc !important;
            font-weight: 500;
        }

        html.dark-theme .code-line.highlighted-exec {
            background: #f8d95c !important;
            border-left-color: #f59e0b !important;
            color: #111827 !important;
        }

        .inline-var-comment {
            display: inline;
            color: #94a3b8 !important;
            font-style: italic;
            margin-left: 12px;
            font-family: 'Fira Code', monospace;
            font-weight: 400;
            line-height: 1.45;
            white-space: pre-wrap;
            overflow-wrap: break-word;
        }

        html.dark-theme .inline-var-comment {
            color: #94a3b8 !important;
        }

        .code-line.highlighted-exec .inline-var-comment {
            color: #94a3b8 !important;
            font-weight: 400;
        }

        html.dark-theme .code-line.highlighted-exec .inline-var-comment {
            color: #64748b !important;
        }

        /* Toolbar and Controls */
        .controls-toolbar {
            background-color: var(--toolbar-bg);
            border: 1px solid var(--card-border);
            border-radius: 8px;
            padding: 6px 10px;
            display: flex;
            flex-wrap: nowrap !important;
            align-items: center;
            gap: 6px;
            margin-bottom: 15px;
            min-height: 36px;
            flex: 0 0 auto;
        }

        .controls-toolbar button {
            font-weight: 600;
            font-size: 0.8rem;
            border-radius: 4px;
        }

        .controls-toolbar #prev-btn,
        .controls-toolbar #next-btn {
            color: #0f172a !important;
            background-color: #ffffff !important;
            border-color: #94a3b8 !important;
            opacity: 1 !important;
            min-width: 28px;
        }

        .controls-toolbar #prev-btn:hover,
        .controls-toolbar #next-btn:hover,
        .controls-toolbar #prev-btn:focus,
        .controls-toolbar #next-btn:focus {
            color: #0f172a !important;
            background-color: #e2e8f0 !important;
            border-color: #64748b !important;
            box-shadow: 0 0 0 0.15rem rgba(100, 116, 139, 0.25);
        }

        html.dark-theme .controls-toolbar #prev-btn,
        html.dark-theme .controls-toolbar #next-btn {
            color: #e5e7eb !important;
            background-color: #111827 !important;
            border-color: #64748b !important;
        }

        html.dark-theme .controls-toolbar #prev-btn:hover,
        html.dark-theme .controls-toolbar #next-btn:hover,
        html.dark-theme .controls-toolbar #prev-btn:focus,
        html.dark-theme .controls-toolbar #next-btn:focus {
            color: #ffffff !important;
            background-color: #1f2937 !important;
            border-color: #94a3b8 !important;
        }

        .speed-select {
            font-weight: 600;
            font-size: 13px;
            border-radius: 4px;
            height: 34px;
            cursor: pointer;
            width: 122px;
            min-width: 122px;
            max-width: 122px;
            flex: 0 0 122px;
        }

        .voice-select {
            font-weight: 600;
            font-size: 13px;
            border-radius: 4px;
            height: 34px;
            cursor: pointer;
            width: 88px;
            min-width: 88px;
            max-width: 88px;
            flex: 0 0 88px;
        }

        /* Terminal Console */
        .console-container {
            background-color: var(--terminal-bg);
            border: 1px solid var(--card-border);
            border-top: none;
            border-radius: 0 0 8px 8px;
            padding: 16px;
            flex: 1 1 auto;
            min-height: 0 !important;
            overflow: auto;
            overscroll-behavior: contain;
            scrollbar-gutter: stable;
            scrollbar-width: thin;
            font-family: 'Fira Code', 'Courier New', Courier, monospace;
            font-size: 0.85rem;
            box-shadow: inset 0 4px 20px rgba(0,0,0,0.5);
            white-space: pre-wrap;
            line-height: 1.25; /* Tighter line height in console */
            color: #bfdbfe;
        }

        .console-container::before {
            content: ">";
            display: block;
            font-family: 'Outfit', sans-serif;
            font-weight: 700;
            font-size: 0.7rem;
            color: #4b5563;
            margin-bottom: 8px;
            letter-spacing: 0.5px;
            border-bottom: 1px solid #1f2937;
            padding-bottom: 4px;
        }

        .console-empty {
            color: #4b5563;
            font-style: italic;
        }

        #sample-output-box {
            flex: 0 0 auto;
            max-height: 160px;
            overflow: auto;
            overscroll-behavior: contain;
        }

        #sample-output-box code {
            color: #38bdf8 !important; /* High contrast cyan for excellent dark theme readability */
            font-weight: 600;
        }

        /* Premium Visualizer Animations & Styles */
        @keyframes pulse-border {
            0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(104, 84, 199, 0.4); }
            70% { transform: scale(1.03); box-shadow: 0 0 0 5px rgba(104, 84, 199, 0); }
            100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(104, 84, 199, 0); }
        }
        @keyframes update-fade {
            0% { background-color: rgba(16, 185, 129, 0.2); }
            100% { background-color: transparent; }
        }
        .animate-update {
            animation: update-fade 2s ease-out;
        }
        
        /* Custom scrollbar styling for cards and lists */
        .table-responsive::-webkit-scrollbar, #array-cells::-webkit-scrollbar {
            height: 6px;
            width: 6px;
        }
        .table-responsive::-webkit-scrollbar-track, #array-cells::-webkit-scrollbar-track {
            background: transparent;
        }
        .table-responsive::-webkit-scrollbar-thumb, #array-cells::-webkit-scrollbar-thumb {
            background: #4b5563;
            border-radius: 3px;
        }
        .table-responsive::-webkit-scrollbar-thumb:hover, #array-cells::-webkit-scrollbar-thumb:hover {
            background: #6b7280;
        }

        @media (max-width: 900px) {
            body.visualizer-page {
                height: 100dvh;
                overflow: hidden;
            }

            .visualizer-navbar {
                display: none;
            }

            .visualizer-title {
                font-size: 0.8rem;
                line-height: 1.2;
            }

            .program-title-strip {
                font-size: 0.68rem;
                text-align: left;
            }

            .console-title {
                gap: 8px;
            }

            .console-brand {
                display: none;
            }

            .console-mobile-meta {
                display: inline-flex;
                align-items: center;
                gap: 6px;
                min-width: 0;
                color: #0f172a;
                font-size: 0.72rem;
                font-weight: 700;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .console-mobile-meta > span {
                flex: 0 0 auto;
                color: #ffffff;
                background: #64748b;
                border-radius: 6px;
                padding: 2px 6px;
                font-size: 0.68rem;
                line-height: 1.1;
            }

            .main-workspace {
                flex-direction: column;
                overflow: hidden;
            }

            .viz-panel {
                order: 2;
                width: 100%;
                flex: 0 0 42dvh;
                max-height: 42dvh;
                border-top: 1px solid var(--card-border);
                padding: 7px 10px 8px;
            }

            .code-panel {
                order: 1;
                width: 100%;
                flex: 1 1 auto;
                border-right: none;
                padding: 7px 10px 8px;
            }

            .panel-title {
                font-size: 0.82rem;
                margin-bottom: 5px !important;
            }

            .controls-toolbar {
                padding: 4px 6px;
                gap: 4px !important;
                margin-bottom: 6px !important;
                min-height: 32px;
                overflow-x: visible;
                white-space: normal;
                flex-wrap: nowrap !important;
                justify-content: flex-start !important;
            }

            .controls-toolbar .btn {
                min-width: 30px;
            }

            #step-badge {
                min-width: 66px !important;
                padding-left: 5px !important;
                padding-right: 5px !important;
                font-size: 0.68rem !important;
            }

            .controls-toolbar #close-btn {
                width: 32px;
                min-width: 32px;
                height: 34px;
                flex: 0 0 32px;
                margin-left: 0 !important;
                padding-left: 0 !important;
                padding-right: 0 !important;
            }

            .speed-select {
                width: 104px !important;
                min-width: 104px !important;
                max-width: 104px !important;
                flex-basis: 104px !important;
            }

            .voice-select {
                width: 76px !important;
                min-width: 76px !important;
                max-width: 76px !important;
                flex-basis: 76px !important;
            }

            .console-container {
                font-size: 0.78rem;
                padding: 8px 10px;
            }

            .code-container {
                font-size: 0.78rem;
                padding: 7px 8px;
            }

            #sample-output-box {
                max-height: 72px;
                font-size: 0.72rem !important;
                padding: 8px !important;
                margin-top: 8px !important;
            }

            .code-line {
                font-size: 0.78rem;
                white-space: pre;
                min-width: max-content;
            }

            .code-line.indent-1 { padding-left: 26px; }
            .code-line.indent-2 { padding-left: 44px; }
            .code-line.indent-3 { padding-left: 62px; }
            .code-line.indent-4 { padding-left: 80px; }
            .code-line.indent-5 { padding-left: 98px; }
            .code-line.indent-6 { padding-left: 116px; }
            .code-line.indent-7 { padding-left: 134px; }
            .code-line.indent-8 { padding-left: 152px; }

            .inline-var-comment {
                display: block;
                margin-left: 14px;
                margin-top: 2px;
                white-space: normal;
            }
        }

        @media (max-width: 480px) {
            .viz-panel {
                flex-basis: 45dvh;
                max-height: 45dvh;
            }

            .controls-toolbar {
                flex-wrap: wrap !important;
                justify-content: flex-start !important;
            }

            .visualizer-title span {
                max-width: 110px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .form-check-label {
                font-size: 0.75rem !important;
            }
        }

/* Glossy visualizer polish: keeps layout intact while improving the teaching screen. */
body.visualizer-page {
    background: linear-gradient(135deg, #f6f8fc 0%, #edf5ff 42%, #f8fafc 100%) !important;
}

.visualizer-navbar {
    background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(241,247,255,0.92)) !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
}

.visualizer-title {
    color: #10233f;
    letter-spacing: 0;
}

.visualizer-title i,
.panel-title i {
    color: #2563eb !important;
    filter: drop-shadow(0 3px 8px rgba(37, 99, 235, 0.24));
}

.program-title-strip {
    color: #14213d !important;
    font-size: 0.86rem !important;
    font-weight: 700 !important;
}

.main-workspace {
    background: linear-gradient(90deg, rgba(255,255,255,0.42), rgba(236,244,255,0.72));
}

.code-panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(244,248,255,0.9)) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.26) !important;
}

.viz-panel {
    background: linear-gradient(180deg, rgba(248,251,255,0.96), rgba(235,243,255,0.92)) !important;
}

.panel-title {
    color: #475569 !important;
    font-size: 0.98rem !important;
    font-weight: 700 !important;
}

.code-container {
    background: linear-gradient(180deg, #ffffff, #fbfdff) !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
    border-radius: 10px !important;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.95);
}

.controls-toolbar {
    background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(226,238,255,0.96)) !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
    border-radius: 10px !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255,255,255,0.95);
}

.controls-toolbar .btn,
.controls-toolbar .form-select,
.controls-toolbar .form-check-input,
#step-badge {
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12) !important;
}

.controls-toolbar #play-btn {
    background: linear-gradient(135deg, #2563eb, #06b6d4) !important;
    border-color: transparent !important;
}

.controls-toolbar #prev-btn,
.controls-toolbar #next-btn {
    background: linear-gradient(180deg, #ffffff, #eef4ff) !important;
    border-color: rgba(100, 116, 139, 0.32) !important;
}

.controls-toolbar .form-select {
    background-color: #111827 !important;
    border-color: rgba(37, 99, 235, 0.28) !important;
    color: #ffffff !important;
}

#step-badge {
    background: linear-gradient(135deg, #07111f, #14213d) !important;
    border: 1px solid rgba(14, 165, 233, 0.32) !important;
    color: #22d3ee !important;
}

.console-container {
    background: linear-gradient(180deg, #09111d, #05080d) !important;
    border: 1px solid rgba(37, 99, 235, 0.24) !important;
    border-radius: 10px !important;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.22), inset 0 1px 0 rgba(255,255,255,0.08);
}

.console-container::before {
    color: #38bdf8 !important;
    border-bottom-color: rgba(56, 189, 248, 0.16) !important;
}

.code-line.highlighted-exec {
    background: linear-gradient(90deg, #fff2a8, #fde68a) !important;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.42), 0 5px 14px rgba(245, 158, 11, 0.18) !important;
}

html.dark-theme body.visualizer-page {
    background: linear-gradient(135deg, #080b11 0%, #101827 52%, #090d14 100%) !important;
}

html.dark-theme .visualizer-navbar,
html.dark-theme .code-panel,
html.dark-theme .viz-panel {
    background: linear-gradient(180deg, rgba(17,24,39,0.96), rgba(10,15,25,0.94)) !important;
}

html.dark-theme .program-title-strip,
html.dark-theme .visualizer-title {
    color: #e5eefc !important;
}

@media (max-width: 900px) {
    .code-container,
    .console-container,
    .controls-toolbar {
        border-radius: 8px !important;
    }
}

.seo-readable-content {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* Final visualizer dark-mode readability overrides. */
html.dark-theme .code-container {
    background: #0f172a !important;
    border-color: rgba(148, 163, 184, 0.24) !important;
}

html.dark-theme .code-container code,
html.dark-theme .code-line,
html.dark-theme .code-line .code-text {
    color: #e5e7eb !important;
    opacity: 1 !important;
}

html.dark-theme .inline-var-comment {
    color: #93a4bd !important;
    opacity: 1 !important;
}

html.dark-theme .code-line.highlighted-exec {
    background: #fde68a !important;
    border-left-color: #f59e0b !important;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.62) !important;
}

html.dark-theme .code-line.highlighted-exec,
html.dark-theme .code-line.highlighted-exec .code-text {
    color: #111827 !important;
}

html.dark-theme .code-line.highlighted-exec .inline-var-comment {
    color: #64748b !important;
}

/* Final toolbar readability and compact sizing. */
.speed-select,
.controls-toolbar .speed-select {
    width: 104px !important;
    min-width: 104px !important;
    max-width: 104px !important;
    flex: 0 0 104px !important;
}

html.dark-theme .controls-toolbar #prev-btn,
html.dark-theme .controls-toolbar #next-btn {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    opacity: 1 !important;
}

html.dark-theme .controls-toolbar #prev-btn i,
html.dark-theme .controls-toolbar #next-btn i {
    color: #0f172a !important;
    opacity: 1 !important;
}

html.dark-theme .controls-toolbar #prev-btn:hover,
html.dark-theme .controls-toolbar #next-btn:hover,
html.dark-theme .controls-toolbar #prev-btn:focus,
html.dark-theme .controls-toolbar #next-btn:focus {
    background: #dbeafe !important;
    border-color: #60a5fa !important;
    color: #0b1220 !important;
}
