:root {
    --ict-bg: #ffffff;
    --ict-sidebar: #f7f9fc;
    --ict-content-bg: #ffffff;
    --ict-accent: #007acc;
    --ict-text: #2c3e50;
    --ict-border: #e1e4e8;
    --ict-console: #1e1e1e;
    --ict-success: #28a745;
    --ict-error: #dc3545;
}

/* Force Box Sizing */
#ict-container, #ict-container * {
    box-sizing: border-box;
}

/* Main Layout Container */
#ict-container.ict-layout-fixed {
    display: flex !important;
    flex-direction: row !important;
    height: 85vh !important; /* Force fixed viewport height */
    min-height: 650px !important;
    width: 100% !important;
    background: var(--ict-bg);
    color: var(--ict-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    border: 1px solid var(--ict-border);
    border-radius: 6px;
    overflow: hidden !important; /* Prevent outer scroll */
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    margin: 0 !important;
}

/* --- Sidebar (Left Column) --- */
.ict-sidebar {
    width: 280px !important;
    height: 100% !important;
    background: var(--ict-sidebar);
    border-right: 1px solid var(--ict-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Internal Scroll */
    flex-shrink: 0 !important;
    z-index: 5;
}

.ict-sidebar h3 {
    display: none; /* Hide original single header */
}

.ict-sidebar-group-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    padding: 15px 20px;
    background: #e9ecef;
    cursor: pointer;
    border-bottom: 1px solid #e1e4e8;
    border-top: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.ict-sidebar-group-title:first-child {
    border-top: none;
}

.ict-sidebar-group-title::after {
    content: '▼';
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
}

.ict-sidebar-group-title.collapsed::after {
    transform: rotate(-90deg);
}

.ict-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: block;
}

.ict-sidebar-list.collapsed {
    display: none;
}

#ict-lesson-list li {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 15px;
    color: #444;
    border-left: 4px solid transparent;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    transition: background 0.1s;
}

#ict-lesson-list li:hover {
    background: #eef1f5;
    color: #000;
}

#ict-lesson-list li.active {
    background: #fff;
    color: var(--ict-accent);
    border-left-color: var(--ict-accent);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* --- Content Pane (Right Column) --- */
.ict-tutorial-pane {
    flex: 1 !important;
    height: 100% !important;
    overflow-y: auto !important; /* Internal Scroll */
    padding: 40px 60px;
    background: var(--ict-content-bg);
    position: relative;
}

/* Content Typography */
.ict-tutorial-pane h2 {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    font-size: 28px;
    color: #24292e;
}

.ict-tutorial-pane h3 {
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 20px;
    color: #24292e;
}

.ict-tutorial-pane p, .ict-tutorial-pane li {
    font-size: 16px;
    line-height: 1.7;
    color: #444;
    margin-bottom: 12px;
}

.ict-tutorial-pane code {
    background: #f6f8fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: #d73a49;
    font-size: 0.9em;
}

.ict-tutorial-pane pre {
    background: #f6f8fa;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #eaecef;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    color: #24292e;
}

/* --- Floating Workspace (Modal) --- */
.ict-workspace {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 90vh;
    background: #1e1e1e;
    color: #d4d4d4;
    z-index: 10001; /* Higher than backdrop */
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    border-radius: 8px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #444;
}

.ict-workspace.active {
    display: flex;
}

.ict-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 9999;
}

.ict-modal-backdrop.active {
    display: block;
}

/* Toolbar */
.ict-toolbar {
    height: 50px;
    background: #252526;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.ict-toolbar-title {
    font-weight: bold;
    color: #fff;
}

#ict-run-btn {
    background: var(--ict-success);
    border: none;
    color: white;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    margin-right: 10px;
}

#ict-run-btn:hover { background: #218838; }
#ict-run-btn:disabled { background: #555; cursor: wait; }

.ict-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.ict-close-btn:hover { color: #fff; }

/* Split Layout Body */
.ict-workspace-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Column: Editor */
.ict-col-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    min-width: 0;
}

.ict-editor-wrapper {
    flex: 1;
    position: relative;
    background: #1e1e1e;
    overflow: hidden;
}

/* Monaco Styles Overrides if needed */
.monaco-editor {
    padding-top: 5px;
}

.ict-monaco-breakpoint {
    background: #e51400;
    border-radius: 50%;
    width: 10px !important;
    height: 10px !important;
    /* Position roughly in center of standard line height */
    margin-top: 4px; 
    margin-left: 5px;
    opacity: 0.9;
    cursor: pointer;
}

.ict-monaco-current-line {
    background: rgba(255, 255, 0, 0.15);
}

.ict-monaco-current-arrow {
    /* CSS Arrow */
    width: 0; 
    height: 0; 
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid #e51400; /* Same red as BP */
    margin-top: 4px;
    margin-left: 6px;
}

.ict-console {
    height: 150px;
    background: #111;
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.ict-console-header {
    background: #222;
    color: #888;
    padding: 5px 10px;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
}

#ict-output {
    flex: 1;
    padding: 10px;
    margin: 0;
    color: #ccc;
    font-family: 'Consolas', monospace;
    overflow: auto;
    font-size: 13px;
    white-space: pre-wrap;
}

/* Right Column: Visualizer */
.ict-col-viz {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e; /* Dark theme */
    color: #d4d4d4;
    min-width: 0;
}

#ict-mermaid-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* changed from auto to avoid double scrolls if possible */
    padding: 10px;
    background: #1e1e1e; /* Dark theme */
    position: relative;
}

#ict-mermaid-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* The wrapper div created by Mermaid or our script */
.mermaid {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1; /* Take available height */
    overflow: hidden;
}

.mermaid svg {
    width: 100% !important;
    height: auto !important;
    max-height: 100% !important; /* Scale down if too tall */
    max-width: none !important;
}

.ict-viz-controls {
    padding: 10px;
    border-top: 1px solid #333; /* Dark theme border */
    display: flex;
    gap: 10px;
    justify-content: center;
    background: #252526; /* Dark theme */
    align-items: center;
}

.ict-viz-controls button {
    padding: 6px 12px;
    border: 1px solid #555; /* Dark theme border */
    background: #333; /* Dark theme background */
    cursor: pointer;
    border-radius: 4px;
    color: #f8f8f8; /* Light text */
}
.ict-viz-controls button:hover {
    background: #444; /* Darker hover */
}

/* Responsive: Stack on Mobile */
@media (max-width: 768px) {
    .ict-workspace {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .ict-workspace-body {
        flex-direction: column;
    }
    .ict-col-editor, .ict-col-viz {
        flex: 1;
        height: 50%;
    }
}