.viz-layout {
    align-self: center;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-columns: 200px 470px 200px;
    gap: 1rem;
    height: 450px;
    margin-bottom: 30px;
}

.canvas-wrapper {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.7rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

canvas {
    border-radius: 3px;
    display: block;
    width: 100%;
    height: 100%;
}

.sidebar-left, .sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.sidebar-left .panel, .sidebar-right .panel {
    flex: 1;
}

.panel {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.panel h3 {
    font-size: 1rem;
    margin-bottom: 0.7rem;
    color: var(--text-main);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.3rem;
}

.control-group {
    margin-bottom: 0.7rem;
}

.control-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

select {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: #fff;
    font-size: 0.75rem;
    color: var(--text-main);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s ease-in-out;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

#step-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.button-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.7rem;
}

.btn-control {
    font-size: 0.75rem;
    flex: 1;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-control:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    font-weight: 600;
    color: var(--text-main);
}

.panel {
    display: flex;
    flex-direction: column;
}

.legend {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-top: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.color-box {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 4px;
}

.bg-default { background-color: #94a3b8; }
.bg-yellow { background-color: #fbbf24; }
.bg-red { background-color: #ef4444; }
.bg-green { background-color: #22c55e; }

@media (max-width: 900px) {
    .viz-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .canvas-wrapper {
        order: -1;
        width: 100%;
        height: 300px;
        padding: 0.5rem;
    }

    canvas {
        width: 100% !important;
        height: auto !important;
    }

    select,
    input[type=number],
    input[type=range],
    .btn-control {
        font-size: 0.9rem;
    }

    .button-row .btn-control {
        flex: 1 1 calc(50% - 0.4rem);
    }
}