#demo-figure * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Override body styles only within the demo figure */
#demo-figure {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

#demo-figure .demo-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

#demo-figure .container {
    display: flex;
    height: 500px;
    background: #f8f8f8;
}

#demo-figure .code-panel {
    width: 50%;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin: 8px;
    overflow: hidden;
}


#demo-figure .code-header {
    background: #f5f5f5;
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    color: #444;
    font-weight: 600;
    text-align: left;
}

#demo-figure .code-content {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
    line-height: 18px;
    background: white;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
    overscroll-behavior-y: contain;
    padding-bottom: 45px;
}

/* Style scrollbar for Chrome, Safari and Opera */
#demo-figure .code-content::-webkit-scrollbar {
    width: 8px;
}

#demo-figure .code-content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

#demo-figure .code-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

#demo-figure .code-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

#demo-figure .code-line {
    display: flex;
    align-items: flex-start;
    transition: background-color 0.3s ease;
    padding: 1px 0;
    border-left: 3px solid transparent;
}

#demo-figure .line-number {
    color: #999;
    width: 38px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 9px;
    user-select: none;
    font-size: 12px;
}

#demo-figure .line-content {
    flex: 1;
    white-space: pre;
    padding-right: 12px;
    text-align: left;
}


#demo-figure .added {
    background-color: #d4edda !important;
}

#demo-figure .deleted {
    background-color: #ffebee !important;
    opacity: 0.7;
}

#demo-figure .modified {
    background-color: #fff3cd;
    border-left: 3px solid #ffc107;
    animation: slideInYellow 0.5s ease;
}


@keyframes slideInRed {
    from { 
        background-color: #dc3545;
        color: white;
        transform: translateX(-5px);
    }
    to { 
        background-color: #ffebee;
        color: inherit;
        transform: translateX(0);
    }
}

@keyframes slideInYellow {
    from { 
        background-color: #ffc107;
        color: white;
        transform: translateX(-5px);
    }
    to { 
        background-color: #fff3cd;
        color: inherit;
        transform: translateX(0);
    }
}


/* Status badge */
#demo-figure .status-badge {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 9px 15px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

/* Phase indicator */
#demo-figure .phase-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    background: #666;
    transition: all 0.3s ease;
}

#demo-figure .phase-indicator.phase-loading {
    background: #ff9800;
    animation: pulse 1s infinite;
}

#demo-figure .phase-indicator.phase-library {
    background: #2196F3;
    animation: pulse 1s infinite;
}

#demo-figure .phase-indicator.phase-solution {
    background: #4CAF50;
    animation: pulse 1s infinite;
}

#demo-figure .phase-indicator.phase-complete {
    background: #9C27B0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}


/* Syntax highlighting */
#demo-figure .keyword { 
    color: #0066cc; 
    font-weight: bold; 
}

#demo-figure .builtin {
    color: #3366cc;
    font-weight: 500;
}

#demo-figure .string { 
    color: #009900; 
}

#demo-figure .docstring {
    color: #006600;
    font-style: italic;
}

#demo-figure .comment { 
    color: #808080; 
    font-style: italic; 
}

#demo-figure .function { 
    color: #cc6600; 
    font-weight: bold; 
}

#demo-figure .number { 
    color: #ff6600; 
}

#demo-figure .decorator {
    color: #9966cc;
    font-weight: bold;
}

#demo-figure .type {
    color: #006666;
    font-style: italic;
}

#demo-figure figcaption {
	font-family: 'Noto Serif', Georgia, serif;
	font-style: italic;
	font-size: 90%;
	color: var(--nord3);
}

/* Mobile responsive font sizes */
@media (max-width: 768px) {
    #demo-figure .code-header {
        font-size: 12px;
    }
    
    #demo-figure .code-content {
        font-size: 9px;
        line-height: 10px;
    }
    
    #demo-figure .line-number {
        font-size: 9px;
        width: 22px;
        padding-right: 4px;
    }
    
    #demo-figure .status-badge {
        font-size: 10px;
        padding: 2px 10px;
        bottom: 10px;
    }
}

@media (max-width: 480px) {
    #demo-figure .code-header {
        font-size: 10px;
    }
    
    #demo-figure .code-content {
        font-size: 7px;
        line-height: 8px;
    }
    
    #demo-figure .line-number {
        font-size: 7px;
        width: 17px;
        padding-right: 3px;
    }
    
    #demo-figure .status-badge {
        font-size: 8px;
        padding: 1px 6px;
        bottom: 5px;
    }
}
