* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: #f5f5f5;
}

h1 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
}

.config-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.config-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-section label {
    font-weight: 500;
}

.config-section input[type="text"],
.config-section input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.config-section input[type="number"] {
    width: 80px;
}

#learning-rate {
    width: 90px;
}

#iterations {
    width: 100px;
}

#ms-per-iter {
    width: 70px;
}

#batch-size {
    width: 60px;
}

.training-config {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.training-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.loss-chart-container {
    width: 200px;
    height: 60px;
    flex-shrink: 0;
}

.loss-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

#target-function {
    width: 250px;
    font-family: monospace;
}

.config-section button {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.config-section button:hover {
    background: #0056b3;
}

.config-section button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.config-section button.stop {
    background: #dc3545;
}

.config-section button.stop:hover {
    background: #c82333;
}

.config-section button.step {
    background: #28a745;
}

.config-section button.step:hover {
    background: #218838;
}

.presets-divider {
    color: #ccc;
    margin: 0 5px;
}

/* Preset buttons - must come after general button styles */
.config-section button.preset-btn {
    padding: 4px 10px;
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    font-size: 12px;
}

.config-section button.preset-btn:hover {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

.status {
    font-size: 0.9rem;
    color: #666;
    font-family: monospace;
}

/* Main container - left panel + chart */
.main-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 0 0 380px;
}

.network-diagram {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.network-diagram h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #666;
}

.network-diagram svg {
    width: 100%;
    height: 220px;
}

/* Edge highlighting */
.network-diagram svg .edge-hitarea {
    cursor: pointer;
}

.network-diagram svg .edge-visual {
    pointer-events: none;
    transition: stroke 0.15s ease, filter 0.15s ease;
}

.network-diagram svg .edge-visual.highlighted {
    stroke: #ffc107 !important;
    filter: drop-shadow(0 0 8px #ffc107);
}

.sliders-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-height: 350px;
    overflow-y: auto;
}

.slider-group {
    margin-bottom: 15px;
}

.slider-group h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.slider-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.slider-row.highlighted {
    background-color: #fff3cd;
}

.slider-row label {
    width: 80px;
    font-size: 0.85rem;
    font-family: monospace;
    flex-shrink: 0;
}

.slider-row input[type="range"] {
    flex: 1;
    margin: 0 10px;
    min-width: 80px;
}

.slider-row input[type="number"].value-input {
    width: 65px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: monospace;
    text-align: right;
}

.slider-row input[type="number"].value-input:focus {
    outline: none;
    border-color: #007bff;
}

/* Chart container - takes remaining width */
.chart-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex: 1;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.chart-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
}

.chart-controls input[type="checkbox"] {
    cursor: pointer;
}

canvas {
    max-width: 100%;
}

.error {
    color: #dc3545;
    font-size: 0.85rem;
}
