<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="Markitect {version}">
    <title>{title}</title>

    {css_content}

    <!-- Base styling for document content -->
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
            background-color: #ffffff;
        }

        /* Responsive design */
        @media (max-width: 768px) {
            body {
                padding: 1rem;
                font-size: 0.9rem;
            }
        }

        /* Content styling */
        h1, h2, h3, h4, h5, h6 {
            color: #2c3e50;
            margin-top: 2rem;
            margin-bottom: 1rem;
        }

        h1 { font-size: 2.5em; border-bottom: 3px solid #3498db; padding-bottom: 0.5rem; }
        h2 { font-size: 2em; border-bottom: 2px solid #3498db; padding-bottom: 0.3rem; }
        h3 { font-size: 1.5em; color: #34495e; }

        p {
            margin-bottom: 1.2rem;
            text-align: justify;
        }

        a {
            color: #3498db;
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        blockquote {
            border-left: 4px solid #3498db;
            margin: 1.5rem 0;
            padding-left: 1rem;
            color: #7f8c8d;
        }

        code {
            background-color: #f8f9fa;
            padding: 0.2rem 0.4rem;
            border-radius: 3px;
            font-family: 'Courier New', monospace;
        }

        pre {
            background-color: #f8f9fa;
            padding: 1rem;
            border-radius: 5px;
            overflow-x: auto;
            border: 1px solid #e9ecef;
        }

        img {
            max-width: 100%;
            height: auto;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        table {
            border-collapse: collapse;
            width: 100%;
            margin: 1.5rem 0;
        }

        th, td {
            border: 1px solid #dee2e6;
            padding: 0.75rem;
            text-align: left;
        }

        th {
            background-color: #f8f9fa;
            font-weight: 600;
        }

        /* Print styles */
        @media print {
            .control-panel {
                display: none !important;
            }

            body {
                font-size: 12pt;
                line-height: 1.4;
            }
        }
    </style>

    <!-- Control system styles -->
    <link rel="stylesheet" href="markitect/static/css/controls.css">

    <!-- External dependencies -->
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"
            onerror="console.error('CDN library failed to load - network or firewall blocking marked.js'); window.markitectMarkedError = true;"></script>
</head>
<body>
    <div id="markitect-content">
        {content}
    </div>

    <!-- Core JavaScript modules from TestDrive-JSUI capability -->
    <script src="capabilities/testdrive-jsui/js/core/debug-system.js"></script>

    <!-- Control system -->
    <script src="capabilities/testdrive-jsui/js/controls/control-base.js"></script>
    <script src="capabilities/testdrive-jsui/js/controls/status-control.js"></script>
    <script src="capabilities/testdrive-jsui/js/controls/debug-control.js"></script>
    <script src="capabilities/testdrive-jsui/js/controls/contents-control.js"></script>
    <script src="capabilities/testdrive-jsui/js/controls/edit-control.js"></script>

    <!-- Main application -->
    <script src="capabilities/testdrive-jsui/js/main.js"></script>

    <!-- Handle CDN loading errors -->
    <script>
        window.addEventListener('load', function() {
            if (window.markitectMarkedError) {
                console.error("CDN library failed to load - network or firewall blocking marked.js");
            }
        });
    </script>
</body>
</html>