:root {
    --border-color: #dee2e6;
    --primary-blue: #1a73e8;
    --dark-surface: #282c34;
    --dark-text: #abb2bf;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 0; background-color: #f8f9fa; height: 100vh; display: flex; flex-direction: column; }
.lab-wrapper { padding: 24px; flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.lab-tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 24px; flex-shrink: 0; }
.tab-link { padding: 12px 20px; cursor: pointer; border: none; background: none; font-size: 16px; font-weight: 500; color: #495057; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-link:hover { background-color: #e9ecef; }
.tab-link.active { color: var(--primary-blue); border-color: var(--primary-blue); }
.tab-content { display: none; flex-grow: 1; min-height: 0; overflow-y: auto; }
.tab-content.active { display: flex; flex-direction: column; }
.concept-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; }
.concept-card { background-color: #fff; border: 1px solid var(--border-color); border-radius: 8px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.concept-card h3 { margin-top: 0; color: #1967d2; }
.concept-card p { line-height: 1.6; }
.concept-card code { background-color: #f1f3f4; padding: 2px 5px; border-radius: 4px; }
.interactive-neuron .control-row { display: flex; align-items: center; margin-bottom: 10px; }
.interactive-neuron .control-row label { width: 80px; }
.interactive-neuron .control-row input[type="range"] { flex-grow: 1; }
.interactive-neuron .control-row span { width: 40px; text-align: right; font-weight: bold; }
.interactive-neuron .output { margin-top: 15px; padding: 10px; background-color: #e8f0fe; border-radius: 6px; text-align: center; font-size: 16px; }
.animation-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
    height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
}
.animation-controls { flex-shrink: 0; width: 200px; }
.animation-controls button { display: block; width: 100%; padding: 10px; font-size: 16px; cursor: pointer; margin-bottom: 10px; }
.animation-group {
    display: flex;
    flex-direction: row;
    gap: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}
.animation-container {
    flex: 0 0 60%;
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}
#animation-svg { width: 100%; max-width: 600px; }
#animation-status { font-weight: bold; font-size: 18px; min-height: 25px; }
@keyframes flow { to { stroke-dashoffset: 0; } }
.signal { stroke: #fbbc05; stroke-width: 2.5px; stroke-dasharray: 20; stroke-dashoffset: 20; animation: flow 0.5s forwards; }
.back-signal { stroke: #ea4335; stroke-width: 2.5px; stroke-dasharray: 20; stroke-dashoffset: 20; animation: flow 0.5s forwards; }
#tab-lab { gap: 16px; }
.mission-accordion { 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: #fff; 
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    margin-bottom: 20px;
}

.mission-header { 
    padding: 12px 20px; 
    font-size: 16px; 
    font-weight: 600; 
    color: #d93025; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    background: #fff;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.mission-accordion:not(.collapsed) .mission-header {
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid var(--border-color);
}

.mission-header::after { 
    content: '▼'; 
    font-size: 14px; 
    color: #5f6368; 
    transition: transform 0.3s ease;
}

.mission-accordion.collapsed .mission-header::after { 
    transform: rotate(-180deg);
}

.mission-body { 
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0; 
    background: #fff;
    border-radius: 0 0 8px 8px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(-10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 99;
}

.mission-accordion:not(.collapsed) .mission-body {
    max-height: 500px;
    padding: 20px;
    opacity: 1;
    transform: translateY(0);
}

.mission-body ul { 
    padding-left: 20px; 
    margin: 0; 
}

.mission-body li { 
    margin: 15px 0;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: calc(var(--item-index, 0) * 0.1s);
}

.mission-accordion:not(.collapsed) .mission-body li {
    opacity: 1;
    transform: translateY(0);
}
.lab-container-wrapper { flex-grow: 1; display: flex; gap: 16px; min-height: 0; }
.lab-container { display: flex; flex-grow: 1; min-width: 0; }
.panel { padding: 20px; height: 100%; box-sizing: border-box; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border-color); border-radius: 8px; }
.visualizer-panel { flex: 1; }
.codelab-panel { flex: 1.5; padding: 0; }
h2 { margin-top: 0; color: var(--primary-blue); font-size: 20px; margin-bottom: 16px; padding: 0 20px; }
.codelab-panel h2 { color: #e37400; display: flex; justify-content: space-between; align-items: center; }
#code-editor-container { flex-grow: 1; min-height: 0; }
.CodeMirror { height: 100%; font-size: 15px; }
.terminal-wrapper { display: flex; flex-direction: column; flex-shrink: 0; }
.terminal { background-color: var(--dark-surface); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); margin-top: 16px;}
.terminal-header { background: #e0e0e0; padding: 8px; border-top-left-radius: 6px; border-top-right-radius: 6px; display: flex; align-items: center; }
.terminal-dots { display: flex; }
.terminal-dot { width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.dot-red { background: #ff5f56; } .dot-yellow { background: #ffbd2e; } .dot-green { background: #27c93f; }
.terminal-title { color: #333; font-weight: 500; }
#output-console { color: var(--dark-text); padding: 15px; height: 180px; overflow-y: auto; white-space: pre-wrap; font-family: 'Fira Code', 'JetBrains Mono', monospace; font-size: 14px; }
#run-button { background-color: var(--primary-blue); color: white; border: none; padding: 10px 20px; font-size: 16px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; }
#run-button:disabled { background-color: #9e9e9e; cursor: not-allowed; }

/* MNIST Preview Styles */
.mnist-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#mnist-canvas {
    border: 2px solid #ccc;
    border-radius: 8px;
    background: white;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.prediction-result {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    width: 100%;
    max-width: 280px;
}

.prediction-result h4 {
    margin: 0 0 10px 0;
    color: #4e54c8;
}

#prediction-display {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.upload-container {
    width: 100%;
    max-width: 280px;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.upload-container h4 {
    margin: 0 0 10px 0;
    color: #4e54c8;
}

.file-input {
    width: 100%;
    padding: 10px;
    border: 2px dashed #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    margin-bottom: 10px;
}

.file-input:hover {
    border-color: #4e54c8;
}

.upload-hint {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.control-button {
    background-color: #4e54c8;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.control-button:hover {
    background-color: #3f43a0;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .mnist-preview {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
    }
    
    .canvas-container {
        margin-right: 20px;
    }
}

/* Prediction Results Styles */
.main-prediction {
    font-size: 24px;
    font-weight: bold;
    color: #4e54c8;
    margin-bottom: 15px;
}

.confidence-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.confidence-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.confidence-item .digit {
    font-weight: bold;
    color: #333;
    font-size: 18px;
}

.confidence-item .probability {
    color: #666;
    font-size: 14px;
}

.confidence-item:first-child {
    background: #e8f0fe;
    border: 1px solid #4e54c8;
}

.confidence-item:first-child .digit {
    color: #4e54c8;
}

.confidence-item:first-child .probability {
    color: #4e54c8;
    font-weight: bold;
}

/* Instruction Box Styles */
.instruction-box {
    background: #e8f0fe;
    border: 1px solid #4e54c8;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    max-width: 600px;
}

.instruction-box h3 {
    color: #4e54c8;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
}

.instruction-box ol {
    margin: 0;
    padding-left: 20px;
}

.instruction-box li {
    margin: 10px 0;
    line-height: 1.5;
}

.instruction-box strong {
    color: #4e54c8;
    font-weight: 600;
}

/* Visualization Tab Layout */
.visualization-wrapper {
    display: flex;
    flex-direction: row;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 200px); /* Adjust based on your header height */
    overflow: hidden;
}

.instruction-box {
    flex: 0 0 300px; /* Fixed width */
    background: #e8f0fe;
    border: 1px solid #4e54c8;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    margin: 0;
}

.visualizer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mnist-preview {
    display: flex;
    flex-direction: row;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 400px;
}

.upload-container {
    flex: 0 0 250px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    height: fit-content;
}

/* Remove scrollbar but keep functionality */
.visualization-wrapper::-webkit-scrollbar {
    display: none;
}

.visualization-wrapper {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Animation Tab Styles */
.animation-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.animation-gif {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.animation-explanation {
    flex: 0 0 40%;
    background: #e8f0fe;
    border: 1px solid #4e54c8;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    max-height: 450px;
    box-sizing: border-box;
}

.animation-explanation h3 {
    color: #4e54c8;
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
    padding-bottom: 6px;
    border-bottom: 2px solid #4e54c8;
}

.explanation-content {
    color: #333;
    line-height: 1.5;
    font-size: 15px;
}

.explanation-content p {
    margin-bottom: 12px;
}

.explanation-content ol,
.explanation-content ul {
    margin: 0 0 12px 15px;
    padding: 0;
}

.explanation-content li {
    margin-bottom: 8px;
}

.explanation-content strong {
    color: #4e54c8;
    font-weight: 600;
}

/* Ensure no horizontal scroll on any element */
* {
    box-sizing: border-box;
    max-width: 100%;
}

/* Hide scrollbars but keep functionality */
.animation-wrapper::-webkit-scrollbar,
.animation-explanation::-webkit-scrollbar {
    display: none;
}

.animation-wrapper,
.animation-explanation {
    -ms-overflow-style: none;
    scrollbar-width: none;
}