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

/* =========================================================
   DESIGN TOKENS  —  Light / Split Theme
   ========================================================= */
:root {
    /* Layout */
    --bg-base:           #d1d7db;
    --bg-sidebar:        #ffffff;
    --bg-surface:        #ffffff;
    --bg-surface-hover:  #f1f5f9;
    --bg-card:           #ffffff;

    /* Text */
    --text-main:         #0f172a;
    --text-muted:        #475569;
    --text-dim:          #64748b;
    --text-sidebar:      #111827;

    /* Subject Accent */
    --subject-primary:        #2563eb;
    --subject-secondary:      #3b82f6;
    --subject-hover:          #1d4ed8;
    --subject-hover-bg:       rgba(37, 99, 235, 0.08);

    --accent-primary:    var(--subject-primary);
    --accent-secondary:  var(--subject-secondary);
    --accent-hover:      var(--subject-hover);
    --accent-hover-bg:   var(--subject-hover-bg);

    /* Code Block (Dark) */
    --bg-code-box:       #1e2128;
    --bg-code-header:    #181a20;
    --text-code-muted:   #7f848e;
    --border-code:       rgba(0,0,0,0.2);

    /* Borders */
    --border-subtle:     rgba(0,0,0,0.06);
    --border-active:     var(--subject-primary);

    /* Dimensions */
    --sidebar-width:     340px;
    --header-height:     70px;
    --footer-height:     40px;
    --radius-sm:         8px;
    --radius-md:         12px;
    --radius-lg:         20px;

    /* Transitions */
    --transition-fast:   0.15s ease;
    --transition-mid:    0.25s ease;
}

/* =========================================================
   RESET & BASE
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   TOP HEADER BAR
   ========================================================= */
#app-header {
    height: var(--header-height);
    background: var(--bg-base);
    display: flex;
    align-items: center;
    padding: 0 30px;
    gap: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

#menu-toggle {
    display: none;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
    color: var(--text-main);
    padding: 8px 12px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-badge {
    width: 36px; height: 36px;
    border-radius: 8px;
    object-fit: contain;
}

.header-title-block { display: flex; flex-direction: column; }

.header-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.header-subtitle {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
}

.header-spacer { flex: 1; }

.header-search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.05);
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}
.hotkey {
    background: rgba(0,0,0,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    margin-left: 4px;
}

#menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 6px 8px;
    cursor: pointer;
}


/* =========================================================
   MAIN LAYOUT & SIDEBAR (DRAWER)
   ========================================================= */
#app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transform: translateX(-105%);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform var(--transition-mid);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    border-right: 1px solid rgba(0,0,0,0.1);
}
#sidebar.open { transform: translateX(0); }

#sidebar-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(4px);
    z-index: 900;
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--transition-mid), visibility var(--transition-mid);
    cursor: pointer;
}
#sidebar.open ~ #sidebar-backdrop {
    visibility: visible;
    opacity: 1;
}

#sidebar-inner { flex: 1; overflow-y: auto; padding: 40px 24px; }
#sidebar-inner::-webkit-scrollbar { width: 6px; }
#sidebar-inner::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.sidebar-author-footer {
    margin: 0 24px;
    padding: 24px 0;
    border-top: 1px solid rgba(0,0,0,0.08);
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}
.sidebar-author-footer strong {
    color: #0f172a;
    font-weight: 800;
    margin-left: 4px;
}
.sidebar-author-footer .author-icon {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    margin-right: 4px;
}

#sidebar-search-wrap { display: none; /* hidden per new design */ }

.sidebar-header-box {
    margin-bottom: 24px;
}
.sidebar-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}
.sidebar-divider {
    border: none;
    height: 2px;
    background: #111827;
    width: 100%;
}

.sidebar-home-btn {
    width: 100%;
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 30px;
    transition: background var(--transition-fast);
}
.sidebar-home-btn:hover {
    background: #1e293b;
}

.nav-category { margin-bottom: 12px; }
.nav-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}
.nav-category-header:hover { background: #f1f5f9; }

.nav-category-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-category-chevron { font-size: 1.1rem; color: #94a3b8; transition: transform 0.2s; font-weight: 600; line-height: 1; }
.nav-category-label { font-size: 0.78rem; font-weight: 700; color: #1e293b; text-transform: uppercase; letter-spacing: 0.08em; }

.nav-category.open .nav-category-chevron { transform: rotate(90deg); }

.nav-topic-list-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-category.open .nav-topic-list-wrapper {
    grid-template-rows: 1fr;
}
.nav-topic-list {
    overflow: hidden;
}
.nav-topic-inner-container {
    padding: 8px 0 16px 30px;
}

.nav-topic {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.nav-topic:hover { background: #f1f5f9; color: #0f172a; }
.nav-topic.active { background: #f1f5f9; color: #0f172a; font-weight: 600; }
.nav-topic.pending { opacity: 0.5; cursor: default; }
.nav-topic-text { flex: 1; }

.nav-circle-icon {
    width: 14px; height: 14px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    flex-shrink: 0;
}
.nav-topic.active .nav-circle-icon {
    border-color: #10b981;
    border-width: 3px;
    background: transparent;
}

/* =========================================================
   CONTENT AREA & WELCOME SPLIT SCREEN
   ========================================================= */
#content-area { flex: 1; overflow-y: auto; position: relative; padding: 20px 40px; }

#content-area::-webkit-scrollbar { width: 8px; }
#content-area::-webkit-scrollbar-track { background: transparent; }
#content-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
#content-area::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* =========================================================
   TOC RIGHT SIDEBAR
   ========================================================= */
#toc-sidebar {
    width: 250px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-subtle);
    background: transparent;
    padding: 30px 20px;
    overflow-y: auto;
    display: none; /* hidden by default, shown when topic is loaded */
}

#toc-sidebar::-webkit-scrollbar { width: 6px; }
#toc-sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.toc-header {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.toc-item {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 0;
    line-height: 1.4;
    transition: color 0.2s;
    cursor: pointer;
}

.toc-item:hover {
    color: var(--subject-primary);
}

.toc-item.level-3 {
    padding-left: 15px;
    font-size: 0.75rem;
}


#welcome-screen {
    display: flex; align-items: center; justify-content: center; height: 100%; width: 100%;
}

.welcome-container {
    display: flex; gap: 40px; width: 100%; max-width: 1000px; height: 85vh;
}

.welcome-card {
    flex: 1;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.04);
    background: #ffffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.left-card {
    background: #f8fafc;
    align-items: center;
    justify-content: center;
}

.bg-pattern {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0.1;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%230f172a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(40, 60)'%3E%3Ccircle cx='20' cy='20' r='8' /%3E%3Ccircle cx='80' cy='0' r='6' /%3E%3Ccircle cx='70' cy='60' r='10' /%3E%3Cline x1='27' y1='17' x2='73' y2='3' /%3E%3Cline x1='25' y1='25' x2='63' y2='54' /%3E%3Cline x1='78' y1='6' x2='72' y2='50' /%3E%3C/g%3E%3Cg transform='translate(320, 300)'%3E%3Ccircle cx='10' cy='10' r='4' /%3E%3Ccircle cx='50' cy='-10' r='5' /%3E%3Ccircle cx='40' cy='40' r='6' /%3E%3Cline x1='14' y1='6' x2='46' y2='-6' /%3E%3Cline x1='13' y1='13' x2='37' y2='37' /%3E%3Cline x1='48' y1='-5' x2='42' y2='34' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%230f172a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(240, 80)'%3E%3Ccircle cx='0' cy='0' r='6' /%3E%3Ccircle cx='0' cy='40' r='6' /%3E%3Ccircle cx='50' cy='-20' r='8' /%3E%3Ccircle cx='50' cy='20' r='8' /%3E%3Ccircle cx='50' cy='60' r='8' /%3E%3Ccircle cx='100' cy='20' r='10' /%3E%3Cline x1='6' y1='-2' x2='42' y2='-16' /%3E%3Cline x1='6' y1='2' x2='42' y2='16' /%3E%3Cline x1='6' y1='4' x2='42' y2='56' /%3E%3Cline x1='6' y1='38' x2='42' y2='-14' /%3E%3Cline x1='6' y1='40' x2='42' y2='22' /%3E%3Cline x1='6' y1='42' x2='42' y2='58' /%3E%3Cline x1='58' y1='-16' x2='92' y2='14' /%3E%3Cline x1='58' y1='20' x2='90' y2='20' /%3E%3Cline x1='58' y1='56' x2='92' y2='26' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%230f172a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(80, 260)'%3E%3Crect x='0' y='0' width='24' height='24' rx='6' /%3E%3Crect x='60' y='20' width='20' height='20' rx='6' /%3E%3Crect x='30' y='80' width='28' height='28' rx='6' /%3E%3Cline x1='24' y1='12' x2='60' y2='26' /%3E%3Cline x1='12' y1='24' x2='40' y2='80' /%3E%3Cline x1='70' y1='40' x2='50' y2='80' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 400px 400px, 450px 450px, 350px 350px;
    z-index: 1;
    animation: panMultiLayers 40s ease-in-out infinite;
    pointer-events: none;
}

@keyframes panMultiLayers {
    0%   { background-position: 0px 0px, 0px 0px, 0px 0px; }
    25%  { background-position: -150px 80px, 120px -100px, 80px 150px; }
    50%  { background-position: -200px -150px, -50px -250px, -120px 200px; }
    75%  { background-position: 100px -200px, -200px 100px, 150px -50px; }
    100% { background-position: 0px 0px, 0px 0px, 0px 0px; }
}

.card-content { 
    position: relative; 
    z-index: 2; 
    text-align: center;
    background: transparent;
    padding: 40px;
    border-radius: 20px;
    box-shadow: none;
    border: none;
}

.card-title {
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.04em;
    margin-bottom: 12px;
    line-height: 1;
}

.card-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.card-buttons { display: flex; gap: 16px; justify-content: center; margin-bottom: 48px; }

.pedagogical-guidance {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 32px 48px;
    max-width: 650px;
    margin: 0 auto;
    text-align: center;
    color: #475569;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05), inset 0 2px 10px rgba(255,255,255,1);
}

.pedagogical-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 12px;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.pedagogical-guidance p { margin: 0; }

.btn-primary {
    background: #111827;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.2);
    transition: transform 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); }

.btn-secondary {
    background: #e2e8f0;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
}

/* Right code card styles */
.right-card { background: var(--bg-code-box); border: 1px solid var(--border-code); }
.code-box-header { 
    position: absolute;
    top: 56px;
    right: 56px;
    display: flex; 
    align-items: center; 
    gap: 16px; 
    z-index: 10;
}
.code-box-filename { 
    color: #94a3b8; 
    font-family: 'Inter', sans-serif; 
    font-size: 0.75rem; 
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.code-box-actions { display: flex; gap: 8px; align-items: center; }
.action-btn { 
    background: #f1f5f9; 
    border: none; 
    color: #64748b; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.action-btn:hover {
    background: #e2e8f0;
    color: #334155;
}
.zoom-indicator { 
    font-family: 'Inter', sans-serif; 
    font-size: 0.75rem; 
    color: #64748b;
    font-weight: 500;
}

/* =========================================================
   READING PANE & PROSE (When a topic is selected)
   ========================================================= */
#reading-pane {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 40px 80px;
}

/* Nav Pills */
.topic-nav-pills {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
}
.nav-pill {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid rgba(0,0,0,0.05);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    transition: transform 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.nav-pill:hover { background: #f8fafc; transform: translateY(-1px); }

.nav-arrow-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.nav-pill.prev:hover .nav-arrow-icon {
    transform: translateX(-4px);
}
.nav-pill.next:hover .nav-arrow-icon {
    transform: translateX(4px);
}

.topic-header { padding-bottom: 10px; }
.topic-title-main { font-size: 3rem; font-weight: 800; letter-spacing: -0.02em; color: #1e293b; margin-bottom: 24px; }

.prose { color: #334155; line-height: 1.8; font-size: 1.1rem; }
.prose h1, .prose h2, .prose h3 { color: #0f172a; font-weight: 800; margin-top: 2em; margin-bottom: 0.8em; letter-spacing: -0.01em; }
.prose h1 { font-size: 2.2rem; }
.prose h2 { font-size: 1.8rem; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 10px; }
.prose p { margin-bottom: 1.2em; }
.prose ul, .prose ol { margin-left: 20px; margin-bottom: 1.5em; }
.prose li { margin-bottom: 8px; }

.prose hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(100, 116, 139, 0.25), transparent);
    margin: 3.5rem 0;
}

.prose code { background: rgba(0,0,0,0.05); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.85em; color: #ef4444; }
.prose pre { background: var(--bg-code-box); padding: 20px; border-radius: var(--radius-md); overflow: auto; color: #e2e8f0; font-family: 'JetBrains Mono', monospace; margin-bottom: 1.5em; }
.prose pre code { background: none; color: inherit; padding: 0; }
/* Upgraded Table Styling for Math & Data */
.prose table { 
    width: 100%; 
    border-collapse: collapse; 
    margin: 32px 0; 
    background: transparent;
}
.prose thead {
    border-bottom: 2px solid rgba(0,0,0,0.1);
}
.prose th, .prose td { 
    padding: 16px 24px; 
    border-bottom: 1px solid rgba(0,0,0,0.06); 
    text-align: left; 
    vertical-align: middle;
}
.prose th { 
    font-weight: 700; 
    color: #0f172a; 
    font-size: 0.95rem;
}
.prose td {
    color: #334155;
}

/* Custom Styling for Math Formulas (Block KaTeX) */
.prose .katex-display {
    background: #e2e8f0;
    padding: 32px;
    border-radius: 8px;
    border-left: 5px solid #1e293b;
    margin: 32px 0;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.prose .katex-display::-webkit-scrollbar {
    height: 8px;
}
.prose .katex-display::-webkit-scrollbar-track {
    background: transparent;
    border-bottom-right-radius: 8px;
}
.prose .katex-display::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
.prose .katex-display::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}


/* Custom Styling for Notes/Important Callouts (Blockquotes) */
.prose blockquote {
    padding: 24px 32px;
    border-radius: 8px;
    margin: 32px 0;
}
.prose blockquote p {
    margin-bottom: 0;
}
.prose blockquote p:not(:last-child) {
    margin-bottom: 12px;
}

/* Callout Title style */
.prose blockquote .callout-title {
    display: inline-block;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

/* Note Callout (Blue-gray / Slate) */
.prose blockquote.callout-note-box {
    background: #f8fafc;
    border-left: 5px solid #64748b;
    color: #334155;
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.05);
}
.prose blockquote.callout-note-box .callout-title {
    color: #475569;
}
.prose blockquote.callout-note-box strong:not(.callout-title) {
    color: #0f172a;
}

/* Important Callout (Red) */
.prose blockquote.callout-important-box {
    background: #fef2f2;
    border-left: 5px solid #ef4444;
    color: #7f1d1d;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.05);
}
.prose blockquote.callout-important-box .callout-title {
    color: #b91c1c;
}
.prose blockquote.callout-important-box strong:not(.callout-title) {
    color: #991b1b;
}

/* Warning Callout (Amber/Orange) */
.prose blockquote.callout-warning-box {
    background: #fffbeb;
    border-left: 5px solid #d97706;
    color: #78350f;
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.05);
}
.prose blockquote.callout-warning-box .callout-title {
    color: #b45309;
}
.prose blockquote.callout-warning-box strong:not(.callout-title) {
    color: #78350f;
}

/* Tip Callout (Green) */
.prose blockquote.callout-tip-box {
    background: #f0fdf4;
    border-left: 5px solid #16a34a;
    color: #14532d;
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.05);
}
.prose blockquote.callout-tip-box .callout-title {
    color: #15803d;
}
.prose blockquote.callout-tip-box strong:not(.callout-title) {
    color: #14532d;
}

/* Generic / Analogy / Remark Blockquote (Cream / Stone) */
.prose blockquote.callout-generic {
    background: #fafaf9;
    border-left: 5px solid #d6d3d1;
    color: #57534e;
    box-shadow: 0 4px 15px rgba(120, 113, 108, 0.03);
}
.prose blockquote.callout-generic strong {
    color: #292524;
}

/* Custom Styling for Questions / Exercises */
.prose .question-box {
    background: #f0fdf4;
    padding: 24px 32px;
    border-radius: 8px;
    border-left: 5px solid #22c55e;
    margin: 32px 0;
    color: #14532d;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.05);
}
.prose .question-box h3, .prose .question-box h4, .prose .question-box strong {
    margin-top: 0;
    color: #166534;
    margin-bottom: 12px;
}
.prose .question-box p:last-child {
    margin-bottom: 0;
}
.prose th, .prose td { padding: 14px; border-bottom: 1px solid rgba(0,0,0,0.05); text-align: left; }
.prose th { font-weight: 700; color: #0f172a; }

.interactive-code-box {
    margin: 32px 0;
    padding: 40px;
    background: #e2e8f0;
    border-radius: 16px;
    position: relative;
}

.interactive-code-box pre {
    margin: 0 !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    padding: 70px 30px 30px 30px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    color: #1e293b !important;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow: auto;
}

.interactive-code-box pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.interactive-code-box pre::-webkit-scrollbar-track {
    background: transparent;
}
.interactive-code-box pre::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.interactive-code-box pre::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Light Theme Prism Overrides inside the new code box */
.interactive-code-box .token.comment, .interactive-code-box .token.prolog, .interactive-code-box .token.doctype, .interactive-code-box .token.cdata { color: #94a3b8; font-style: italic; }
.interactive-code-box .token.punctuation { color: #64748b; }
.interactive-code-box .token.namespace { opacity: .7; }
.interactive-code-box .token.property, .interactive-code-box .token.tag, .interactive-code-box .token.boolean, .interactive-code-box .token.number, .interactive-code-box .token.constant, .interactive-code-box .token.symbol, .interactive-code-box .token.deleted { color: #d946ef; }
.interactive-code-box .token.selector, .interactive-code-box .token.attr-name, .interactive-code-box .token.string, .interactive-code-box .token.char, .interactive-code-box .token.builtin, .interactive-code-box .token.inserted { color: #10b981; }
.interactive-code-box .token.operator, .interactive-code-box .token.entity, .interactive-code-box .token.url, .interactive-code-box .language-css .token.string, .interactive-code-box .style .token.string { color: #0ea5e9; }
.interactive-code-box .token.atrule, .interactive-code-box .token.attr-value, .interactive-code-box .token.keyword { color: #3b82f6; }
.interactive-code-box .token.function, .interactive-code-box .token.class-name { color: #f59e0b; }
.interactive-code-box .token.regex, .interactive-code-box .token.important, .interactive-code-box .token.variable { color: #f43f5e; }

.diagram-box {
    margin: 32px 0;
    padding: 40px;
    background: #e2e8f0;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

.diagram-box pre {
    margin: 0 !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    padding: 30px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    color: #1e293b !important;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.diagram-box pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.diagram-box pre::-webkit-scrollbar-track {
    background: transparent;
}
.diagram-box pre::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.diagram-box pre::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}


/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
    .welcome-container { flex-direction: column; height: auto; }
    .left-card, .right-card { min-height: 400px; }
    #reading-pane { padding: 40px; }
}
@media (max-width: 768px) {
    #menu-toggle { display: block; }
    .header-btn, .header-search-btn { display: none; }
    #content-area { padding: 15px; }
    #reading-pane { padding: 25px; }
    .topic-nav-pills { flex-direction: column; gap: 10px; }
    .nav-pill { text-align: center; }
}

/* =========================================================
   SEARCH MODAL
   ========================================================= */
#search-backdrop {
    visibility: hidden; opacity: 0;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    transition: opacity 0.25s, visibility 0.25s;
}
#search-backdrop.show { visibility: visible; opacity: 1; }

#search-modal {
    visibility: hidden; opacity: 0;
    position: fixed; top: 10vh; left: 50%;
    transform: translate(-50%, -15px) scale(0.98);
    width: 90%; max-width: 600px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    z-index: 2001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}
#search-modal.show { visibility: visible; opacity: 1; transform: translate(-50%, 0) scale(1); }

.search-modal-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.search-icon { color: #64748b; flex-shrink: 0; }
#modal-search-input {
    flex: 1; border: none; outline: none;
    font-size: 1.1rem; color: #0f172a; background: transparent;
    font-family: inherit;
}
#modal-search-input::placeholder { color: #94a3b8; }
.esc-hint {
    font-size: 0.7rem; font-weight: 700; color: #64748b;
    border: 1px solid #cbd5e1; border-radius: 4px; padding: 2px 6px;
    flex-shrink: 0;
}

#search-results {
    overflow-y: auto;
    padding: 10px 0 20px;
}
#search-results::-webkit-scrollbar { width: 6px; }
#search-results::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.search-res-category {
    font-size: 0.75rem; font-weight: 800; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 18px 20px 8px;
}
.search-res-topic {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
}
.search-res-topic:hover, .search-res-topic.selected { background: #f8fafc; }
.search-res-icon { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: #94a3b8; font-weight: 600; flex-shrink: 0; }
.search-res-title { font-size: 0.95rem; font-weight: 600; color: #1e293b; }

/* Content-match search results */
.search-res-content-match { align-items: flex-start; padding: 10px 20px; }
.search-res-content-match .search-res-icon { margin-top: 2px; color: #6366f1; }
.search-res-match-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-res-match-topic { font-size: 0.75rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.03em; }
.search-res-match-heading { font-size: 0.9rem; font-weight: 600; color: #6366f1; }
.search-res-snippet { font-size: 0.78rem; color: #64748b; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* =========================================================
   FOOTER BAR
   ========================================================= */
#app-footer {
    height: 36px;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    z-index: 100;
}

#app-footer .footer-left {
    color: #94a3b8;
}

#app-footer .footer-right {
    color: #64748b;
}

#app-footer .footer-right strong {
    color: #e2e8f0;
    font-weight: 700;
    margin-left: 4px;
}

#app-footer .author-icon {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    margin-right: 4px;
}

/* =========================================================
   ALGORITHM BLOCKS (AUTO-PARSED)
   ========================================================= */
.algo-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
    margin: 36px 0;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

.algo-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.algo-icon {
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e7ff;
    border-radius: 6px;
    padding: 6px;
}

.algo-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.algo-steps {
    padding: 12px 24px;
}

.algo-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.algo-step-num {
    background: #f1f5f9;
    color: #64748b;
    font-weight: 700;
    font-size: 0.85rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}

.algo-step-content {
    color: #334155;
    line-height: 1.6;
    font-size: 0.95rem;
    padding-top: 4px;
}

/* =========================================================
   RESPONSIVE DESIGN (MOBILE)
   ========================================================= */
@media (max-width: 900px) {
    #app-header {
        padding: 0 16px;
        gap: 12px;
    }
    #topics-btn { display: none; }
    #menu-toggle { display: flex; align-items: center; justify-content: center; }
    
    .header-title { font-size: 0.95rem; }
    .header-subtitle { font-size: 0.55rem; letter-spacing: 0.05em; }
    .header-search-btn { display: none; }
    .hotkey { display: none; }

    .welcome-container { flex-direction: column; height: auto; gap: 24px; padding-bottom: 40px; padding: 20px; }
    .welcome-card { min-height: 350px; }
    .card-content { padding: 40px 24px; }
    .card-title { font-size: 2.2rem; }
    .card-subtitle { font-size: 0.95rem; }
    
    .card-buttons { flex-direction: column; align-items: stretch; width: 100%; gap: 12px; }
    .btn-primary, .btn-secondary { width: 100%; justify-content: center; text-align: center; }

    #app-body { flex-direction: column; }
    
    #content-area { padding: 16px 20px; }
    .topic-title-main { font-size: 1.8rem; }
    .topic-nav-pills { flex-direction: column; gap: 12px; }
    
    #sidebar { width: 300px; }
    
    #toc-sidebar {
        display: none !important;
    }
    
    .interactive-code-box {
        padding: 16px;
        margin: 24px 0;
    }
    
    .interactive-code-box pre {
        padding: 60px 16px 16px 16px !important;
        font-size: 0.8rem;
    }
    
    .code-box-header {
        top: 24px;
        left: 24px;
        right: 24px;
    }
    
    html, body {
        overflow-x: hidden;
    }
    
    #reading-pane {
        padding: 0 0 60px;
    }
    
    .prose blockquote {
        padding: 16px;
    }
    
    .prose {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}
