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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
    border-bottom: 2px solid #21262d;
}

h1 {
    color: #58a6ff;
    margin-bottom: 20px;
    font-size: 2.5em;
}

.lesson-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.lesson-btn {
    background: #21262d;
    color: #c9d1d9;
    border: 2px solid #30363d;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

.lesson-btn:hover {
    background: #30363d;
    border-color: #58a6ff;
}

.lesson-btn.active {
    background: #58a6ff;
    color: #0d1117;
    border-color: #58a6ff;
}

.lesson {
    display: none;
    animation: fadeIn 0.5s;
}

.lesson.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

h2 {
    color: #58a6ff;
    margin-bottom: 15px;
    font-size: 2em;
}

.description {
    background: #161b22;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 30px;
    border-left: 4px solid #58a6ff;
}

code {
    background: #21262d;
    padding: 2px 6px;
    border-radius: 3px;
    color: #79c0ff;
}

.controls {
    background: #161b22;
    padding: 25px;
    border-radius: 6px;
    margin-bottom: 30px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #8b949e;
    font-weight: 500;
}

.control-group span {
    color: #58a6ff;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #21262d;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #58a6ff;
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #58a6ff;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

select {
    width: 100%;
    padding: 10px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
}

.visualization {
    background: #161b22;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
}

canvas {
    border-radius: 6px;
    background: #0d1117;
}

.output-display {
    background: #161b22;
    padding: 20px;
    border-radius: 6px;
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
}

.output-display span {
    color: #58a6ff;
    font-weight: bold;
}

.action-btn {
    background: #238636;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    margin-right: 10px;
    margin-top: 10px;
    transition: background 0.3s;
}

.action-btn:hover {
    background: #2ea043;
}

.action-btn:disabled {
    background: #30363d;
    cursor: not-allowed;
    opacity: 0.6;
}

.action-btn.small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.backprop-explanation {
    background: #161b22;
    padding: 25px;
    border-radius: 6px;
    border-left: 4px solid #58a6ff;
}

.backprop-explanation h3 {
    color: #58a6ff;
    margin-bottom: 15px;
}

.backprop-explanation h4 {
    color: #79c0ff;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.backprop-explanation ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

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

.backprop-explanation strong {
    color: #79c0ff;
}

.backprop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.backprop-step {
    background: #0d1117;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #30363d;
}

.backprop-step p {
    margin: 5px 0;
    font-size: 0.9em;
}

.backprop-step span {
    color: #58a6ff;
    font-weight: bold;
}

.weight-changes {
    background: #0d1117;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
}

#weight-change-log {
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #8b949e;
}

#weight-change-log::-webkit-scrollbar {
    width: 8px;
}

#weight-change-log::-webkit-scrollbar-track {
    background: #161b22;
    border-radius: 4px;
}

#weight-change-log::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

.weight-log-entry {
    padding: 5px;
    margin: 3px 0;
    border-left: 2px solid #30363d;
    padding-left: 10px;
}

.weight-log-entry.positive {
    border-left-color: #238636;
}

.weight-log-entry.negative {
    border-left-color: #f85149;
}

.lesson2-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.training-data-section,
.training-controls-section {
    background: #161b22;
    padding: 20px;
    border-radius: 6px;
}

.training-data-section h3,
.training-controls-section h3 {
    color: #58a6ff;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.section-description {
    color: #8b949e;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.data-input-form {
    margin-bottom: 15px;
}

.form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.form-row input[type="number"] {
    flex: 1;
    padding: 8px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 0.9em;
}

.form-row input[type="number"]:focus {
    outline: none;
    border-color: #58a6ff;
}

.data-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #0d1117;
}

.data-list::-webkit-scrollbar {
    width: 8px;
}

.data-list::-webkit-scrollbar-track {
    background: #161b22;
    border-radius: 4px;
}

.data-list::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

.data-item {
    padding: 10px;
    border-bottom: 1px solid #21262d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.data-item:hover {
    background: #161b22;
}

.data-item.active {
    background: #1c2128;
    border-left: 3px solid #58a6ff;
}

.data-item-content {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #c9d1d9;
}

.data-item-delete {
    background: #f85149;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 0.2s;
}

.data-item-delete:hover {
    background: #da3633;
}

.preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.button-group .action-btn {
    margin: 0;
}

@media (max-width: 968px) {
    .lesson2-layout {
        grid-template-columns: 1fr;
    }
}

.mnist-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.mnist-controls {
    background: #161b22;
    padding: 25px;
    border-radius: 6px;
    grid-column: 1 / -1;
}

.mnist-drawing {
    background: #161b22;
    padding: 25px;
    border-radius: 6px;
}

.mnist-drawing h3 {
    color: #58a6ff;
    margin-bottom: 15px;
}

#drawing-canvas {
    cursor: crosshair;
    border: 2px solid #30363d;
}

.mnist-prediction {
    background: #161b22;
    padding: 25px;
    border-radius: 6px;
}

.mnist-prediction h3 {
    color: #58a6ff;
    margin-bottom: 15px;
}

#prediction-result {
    text-align: center;
    margin-bottom: 20px;
}

.predicted-digit {
    font-size: 4em;
    color: #58a6ff;
    font-weight: bold;
    margin-bottom: 10px;
}

.confidence {
    color: #8b949e;
    font-size: 1.1em;
}

#probability-bars {
    margin-top: 20px;
}

.prob-bar {
    margin-bottom: 10px;
}

.prob-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.prob-fill {
    height: 20px;
    background: #21262d;
    border-radius: 3px;
    overflow: hidden;
}

.prob-fill-inner {
    height: 100%;
    background: linear-gradient(90deg, #58a6ff, #79c0ff);
    transition: width 0.3s;
}

@media (max-width: 768px) {
    .mnist-container {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .lesson-nav {
        flex-direction: column;
    }
}
